Commit ec6d20ec authored by gunsch's avatar gunsch Committed by Commit bot

Chromecast: moves all service startup code to PreMainMessageLoopRun.

On Android, CastService::Start is never called (!). This is because
Android uses a Java-based UI message loop after
BrowserMainRunner::Initialize is completed, and BrowserMainRunner:Run is
never called (nor should it be).

See ChromeBrowserMainParts for similar handling of the Android case.

R=lcwu@chromium.org,byungchul@chromium.org
BUG=internal b/18934906

Review URL: https://codereview.chromium.org/953283002

Cr-Commit-Position: refs/heads/master@{#318136}
parent 13d97085
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
namespace { namespace {
#if !defined(OS_ANDROID)
int kSignalsToRunClosure[] = { SIGTERM, SIGINT, }; int kSignalsToRunClosure[] = { SIGTERM, SIGINT, };
// Closure to run on SIGTERM and SIGINT. // Closure to run on SIGTERM and SIGINT.
...@@ -82,6 +83,7 @@ void RegisterClosureOnSignal(const base::Closure& closure) { ...@@ -82,6 +83,7 @@ void RegisterClosureOnSignal(const base::Closure& closure) {
// Get the first signal to exit when the parent process dies. // Get the first signal to exit when the parent process dies.
prctl(PR_SET_PDEATHSIG, kSignalsToRunClosure[0]); prctl(PR_SET_PDEATHSIG, kSignalsToRunClosure[0]);
} }
#endif // !defined(OS_ANDROID)
} // namespace } // namespace
...@@ -245,11 +247,16 @@ void CastBrowserMainParts::PreMainMessageLoopRun() { ...@@ -245,11 +247,16 @@ void CastBrowserMainParts::PreMainMessageLoopRun() {
cast_browser_process_->metrics_service_client() cast_browser_process_->metrics_service_client()
->Initialize(cast_browser_process_->cast_service()); ->Initialize(cast_browser_process_->cast_service());
url_request_context_factory_->InitializeNetworkDelegates(); url_request_context_factory_->InitializeNetworkDelegates();
}
bool CastBrowserMainParts::MainMessageLoopRun(int* result_code) {
cast_browser_process_->cast_service()->Start(); cast_browser_process_->cast_service()->Start();
}
bool CastBrowserMainParts::MainMessageLoopRun(int* result_code) {
#if defined(OS_ANDROID)
// Android does not use native main MessageLoop.
NOTREACHED();
return true;
#else
base::RunLoop run_loop; base::RunLoop run_loop;
base::Closure quit_closure(run_loop.QuitClosure()); base::Closure quit_closure(run_loop.QuitClosure());
RegisterClosureOnSignal(quit_closure); RegisterClosureOnSignal(quit_closure);
...@@ -265,12 +272,18 @@ bool CastBrowserMainParts::MainMessageLoopRun(int* result_code) { ...@@ -265,12 +272,18 @@ bool CastBrowserMainParts::MainMessageLoopRun(int* result_code) {
cast_browser_process_->cast_service()->Stop(); cast_browser_process_->cast_service()->Stop();
return true; return true;
#endif
} }
void CastBrowserMainParts::PostMainMessageLoopRun() { void CastBrowserMainParts::PostMainMessageLoopRun() {
#if defined(OS_ANDROID)
// Android does not use native main MessageLoop.
NOTREACHED();
#else
cast_browser_process_->cast_service()->Finalize(); cast_browser_process_->cast_service()->Finalize();
cast_browser_process_->metrics_service_client()->Finalize(); cast_browser_process_->metrics_service_client()->Finalize();
cast_browser_process_.reset(); cast_browser_process_.reset();
#endif
} }
} // namespace shell } // namespace shell
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment