RefPtr<CompositorSession> GPUProcessManager::CreateTopLevelCompositor(nsBaseWidget* aWidget, LayerManager* aLayerManager, CSSToLayoutDeviceScale aScale, const CompositorOptions& aOptions, bool aUseExternalSurfaceSize, const gfx::IntSize& aSurfaceSize) { uint64_t layerTreeId = AllocateLayerTreeId(); EnsureImageBridgeChild(); EnsureVRManager(); RefPtr<CompositorSession> session; if (EnsureGPUReady()) { session = CreateRemoteSession( aWidget, aLayerManager, layerTreeId, aScale, aOptions, aUseExternalSurfaceSize, aSurfaceSize); if (!session) { // We couldn't create a remote compositor, so abort the process. DisableGPUProcess("Failed to create remote compositor"); } } if (!session) { session = InProcessCompositorSession::Create( aWidget, aLayerManager, layerTreeId, aScale, aOptions, aUseExternalSurfaceSize, aSurfaceSize, AllocateNamespace()); } #if defined(MOZ_WIDGET_ANDROID) if (session) { // Nothing to do if controller gets a nullptr RefPtr<UiCompositorControllerChild> controller = CreateUiCompositorController(aWidget, session->RootLayerTreeId()); session->SetUiCompositorControllerChild(controller); } #endif // defined(MOZ_WIDGET_ANDROID) return session; }
/**** * ParseEventLogInternal * * DESC: * Gets the most recent event log record * * ARGS: * server - IP or host to connect to * domain - domain within the host (empty string for none) * username - username within the domain * password - password for above user * logName - event log to open (default to "Application" if NULL) * query - XPath query to retrieve (see remarks) * outputFormat - set to 0 (JSON) otherwise XML * debug - set to 0 (none) 1 (basic) or 2 (verbose) * mode - mode to run the parser (see remarks) * * REMARKS: * XPath: * * The Windows Event log is structurally an XML document. You * may therefore use XPath queries to retrieve the information * you want. Pre-defined XPath queries have been built into the * supplementary Perl module. However, you are free to modify * that module to include newer queries, based on your requirements * * mode: * * Can be set to either MODE_FETCH_LAST_RECORD or MODE_DEFAULT. The * former will simply return the Event Log Record ID of the topmost * (i.e. the latest) event record. The latter will do the actual * processing of parsing an event log record to the screen. * * Note: As per previous discussions, output format is forced as * JSON here. To re-allow XML, simply replace OUTPUT_FORMAT_JSON * with outputFormat, in the line of code, below */ DWORD64 ParseEventLogInternal(LPWSTR server, LPWSTR domain, LPWSTR username, LPWSTR password, LPWSTR logName, LPWSTR query, INT outputFormat, INT debug, INT mode) { bool getLastRecord = false; DWORD64 result = 0; if( debug > DEBUG_L1 ) { wprintf(L"[ParseEventLogInternal]: Attempting to connect to '%s' on domain '%s' using %s:%s...\n", server, domain, username, password); } // If no domain was supplied if( wcslen(domain) == 0 ) { // Official MSDN specs request NULL instead of an empty string domain = NULL; if( debug >= DEBUG_L1 ) { wprintf(L"[ParseEventLogInternal]: Empty domain supplied. Default to NULL\n"); } } // If a blank query was supplied, assume no query (NULL) if( lstrlen(query) == 0 ) query = NULL; // If the supplied query is our special token that retrieves the last record if( lstrcmpW( query, L"LAST_RECORD") == 0 ) { if( debug >= DEBUG_L1 ) { wprintf(L"[ParseEventLogInternal]: Mode is last record fetch\n"); } // Flag the processing routine to only fetch the lastest record getLastRecord = true; // Force an empty query so that the last record is not affected by query filters // An empty query means it will get ALL records, in which case we are guaranteed // the latest record (i.e. the record ID we want) is the first to be retrieved query = NULL; } else { if( debug >= DEBUG_L1 ) { if( query == NULL ) { wprintf(L"[ParseEventLogInternal]: (no query specified)\n"); } else { wprintf(L"[ParseEventLogInternal]: Using query: %s\n", query); } } } // Create a remote context to the external server EVT_HANDLE hRemote = CreateRemoteSession(server, domain, username, password); if (hRemote != NULL) { // NOTE: Reaching here does not mean the connection succeeded. It merely // means that we successfully created the remote context if( debug >= DEBUG_L1 ) { wprintf(L"[ParseEventLogInternal]: Attempting to query the EventLog...\n\n", hRemote); } // Attempt to query event log in reverse chronological order (newest to oldest) EVT_HANDLE hResults = EvtQuery( hRemote, logName, query, EvtQueryChannelPath | EvtQueryReverseDirection); // If the query was successful if (hResults != NULL) { // Process the first event found DumpEventInfo(hRemote, hResults, outputFormat, getLastRecord ? MODE_FETCH_LAST_RECORD : 0, debug); // Process subsequent events result = ProcessResults(hRemote, hResults, outputFormat, getLastRecord ? MODE_FETCH_LAST_RECORD : 0, debug); } else { // Query was not successful. Get the error code DWORD dwError = GetLastError(); if (dwError == ERROR_EVT_CHANNEL_NOT_FOUND) { fwprintf(stderr, L"[Error][ParseEventLog]: Could not open the '%s' log on this machine.\n", logName); } else if (dwError == ERROR_EVT_INVALID_QUERY) { // You can call the EvtGetExtendedStatus function to try to get // additional information as to what is wrong with the query. fwprintf(stderr, L"[Error][ParseEventLog]: The specified search query is not valid.\n"); } else { fwprintf(stderr, L"[Error][ParseEventLog]: Could not read event logs due to the following Windows error: %lu.\n", dwError); } } // Close the handle to the query we opened EvtClose(hRemote); } else { fwprintf(stderr, L"[Error][ParseEventLog]: Failed to connect to remote computer. Error code is %d.\n", GetLastError()); } return result; }