/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** * IChannelHook exposes six methods: The Client* methods are called when * a client is sending an IPC request, whereas the Server* methods are called * when a server is receiving an IPC request. * * For our purposes, we only care about the client-side methods. The COM * runtime invokes the methods in the following order: * 1. ClientGetSize, where the hook specifies the size of its payload; * 2. ClientFillBuffer, where the hook fills the channel's buffer with its * payload information. NOTE: This method is only called when ClientGetSize * specifies a non-zero payload size. For our purposes, since we are not * sending a payload, this method will never be called! * 3. ClientNotify, when the response has been received from the server. * * Since we want to use these hooks to record the beginning and end of a COM * IPC call, we use ClientGetSize for logging the start, and ClientNotify for * logging the end. * * Finally, our implementation responds to any request matching our extension * ID, however we only care about main thread COM calls.
*/
// We don't care about the server-side notifications, so leave as no-ops.
STDMETHODIMP_(void)
ServerNotify(REFGUID aExtensionId, REFIID aIid, ULONG aDataSize, void* aDataBuf, DWORD aDataRep) override {}
// Once we've set the channel hook, we don't care about this notification // anymore; our channel hook will remain set for the lifetime of the process.
nsCOMPtr<nsIObserverService> obsServ(mozilla::services::GetObserverService());
MOZ_ASSERT(!!obsServ); if (!obsServ) { return NS_OK;
}
void InitProfilerMarkers() { if (!XRE_IsParentProcess()) { return;
}
MOZ_ASSERT(NS_IsMainThread()); if (!NS_IsMainThread()) { return;
}
if (profiler_is_active()) { // If the profiler is already running, we'll immediately register our // channel hook.
RegisterChannelHook(); return;
}
// The profiler is not running yet. To avoid unnecessary invocations of the // channel hook, we won't bother with installing it until the profiler starts. // Set up an observer to watch for this.
nsCOMPtr<nsIObserverService> obsServ(mozilla::services::GetObserverService());
MOZ_ASSERT(!!obsServ); if (!obsServ) { return;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.