gecko 相關process分析 參考檔案,程式碼
NS_InitXPCOM2x重點分析:b2g process
| |-NS_InitXPCOM2 (xpcom/build/XPCOMInit.cpp) | |-sMessageLoop = new MessageLoopForUI(MessageLoop::TYPE_MOZILLA_UI);//建立UI的messageloop,與介面請求相關,點選等 | |-ioThread = MakeUnique<BrowserProcessSubThread>(BrowserProcessSubThread::IO); |-ioThread->StartWithOptions | |-nsThreadManager::get()->Init(); | |-nsTimerImpl::Startup(); | |-nsComponentManagerImpl::gComponentManager = new nsComponentManagerImpl(); | |-nsCycleCollector_init | |-nsCycleCollector_startup | |-JS_Init | |-nsComponentManagerImpl::gComponentManager->Init();(xpcom/components/nsComponentManager.cpp) | | | |-nsComponentManagerImpl::InitializeStaticModules() | | | |-RegisterModule(...) | | | |-greOmnijar =mozilla::Omnijar::GetReader(mozilla::Omnijar::GRE); | | | |-cl->location.Init(greOmnijar, "chrome.manifest"); | | | |-nsComponentManagerImpl::RereadChromeManifests | | | |-nsComponentManagerImpl::RegisterManifest | | | |-DoRegisterManifest | | | |-ParseManifest | | | |-... | | | |-nsComponentManagerImpl::ManifestContract | |-XPTInterfaceInfoManager::GetSingleton(); | |-nsDirectoryService::gService->RegisterCategoryProviders(); | |-SharedThreadPool::InitStatics(); | |-AbstractThread::InitStatics(); | |-mozilla::scache::StartupCache::GetSingleton(); | |-mozilla::AvailableMemoryTracker::Activate(); | |-NS_CreateServicesFromCategory(...) | |-mozilla::HangMonitor::Startup(); | |-mozilla::BackgroundHangMonitor::Startup(); | |-sMainHangMonitor = new mozilla::BackgroundHangMonitor |
NS_initxpcom 總結性: NS_InitXPCOM2,在b2g程序中呼叫NS_InitXPCOM2完成了以下工作: 設定掛起時間, 設定執行緒型別,建立並初始化主執行緒,啟動localfile服務用於獲取各檔案(app 或gre 檔案,在omni.jar中)路徑,建立元件服務和管理,自動註冊各元件,初始化js 引擎,共享執行緒和抽象執行緒初始化,例項化jsloader服務,啟動掛起監控,啟動後臺掛起監控,呼叫訊息佇列迴圈messageloop,再新建一個後臺掛起監控。
Omnijar.h
```
/** * Initializes the Omnijar API with the given directory or file for GRE and * APP. Each of the paths given can be: * - a file path, pointing to the omnijar file, * - a directory path, pointing to a directory containing an "omni.jar" file, * - nullptr for autodetection of an "omni.jar" file. */ static void Init(nsIFile* aGrePath = nullptr, nsIFile* aAppPath = nullptr);
```
完整的log: