Example #1
0
// called after FrameworkView::Run() drops into the event dispatch loop
void
MetroApp::Initialize()
{
  HRESULT hr;
  LogThread();

  static bool xpcomInit;
  if (!xpcomInit) {
    xpcomInit = true;
    Log(L"XPCOM startup initialization began");
    nsresult rv = XRE_metroStartup();
    Log(L"XPCOM startup initialization complete");
    if (NS_FAILED(rv)) {
      Log(L"XPCOM startup initialization failed, bailing. rv=%X", rv);
      CoreExit();
      return;
    }
  }

  sFrameworkView->SetupContracts();

  hr = sCoreApp->add_Suspending(Callback<__FIEventHandler_1_Windows__CApplicationModel__CSuspendingEventArgs_t>(
    this, &MetroApp::OnSuspending).Get(), &mSuspendEvent);
  AssertHRESULT(hr);

  hr = sCoreApp->add_Resuming(Callback<__FIEventHandler_1_IInspectable_t>(
    this, &MetroApp::OnResuming).Get(), &mResumeEvent);
  AssertHRESULT(hr);

  mozilla::widget::StartAudioSession();
}
void
MetroApp::Run()
{
  LogThread();

  // Name this thread for debugging and register it with the profiler
  // as the main gecko thread.
  char aLocal;
  PR_SetCurrentThreadName(gGeckoThreadName);
  profiler_register_thread(gGeckoThreadName, &aLocal);

  HRESULT hr;
  hr = sCoreApp->add_Suspending(Callback<__FIEventHandler_1_Windows__CApplicationModel__CSuspendingEventArgs_t>(
    this, &MetroApp::OnSuspending).Get(), &mSuspendEvent);
  AssertHRESULT(hr);

  hr = sCoreApp->add_Resuming(Callback<__FIEventHandler_1_IInspectable_t>(
    this, &MetroApp::OnResuming).Get(), &mResumeEvent);
  AssertHRESULT(hr);

  Log("XPCOM startup initialization began");
  nsresult rv = XRE_metroStartup(true);
  Log("XPCOM startup initialization complete");
  if (NS_FAILED(rv)) {
    Log("XPCOM startup initialization failed, bailing. rv=%X", rv);
    CoreExit();
  }
}