OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chromecast/shell/browser/cast_browser_main_parts.h" | 5 #include "chromecast/shell/browser/cast_browser_main_parts.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/prefs/pref_registry_simple.h" | 9 #include "base/prefs/pref_registry_simple.h" |
10 #include "chromecast/common/chromecast_config.h" | 10 #include "chromecast/common/chromecast_config.h" |
11 #include "chromecast/metrics/cast_metrics_service_client.h" | 11 #include "chromecast/metrics/cast_metrics_service_client.h" |
12 #include "chromecast/net/network_change_notifier_cast.h" | 12 #include "chromecast/net/network_change_notifier_cast.h" |
13 #include "chromecast/net/network_change_notifier_factory_cast.h" | 13 #include "chromecast/net/network_change_notifier_factory_cast.h" |
14 #include "chromecast/service/cast_service.h" | 14 #include "chromecast/service/cast_service.h" |
15 #include "chromecast/shell/browser/cast_browser_context.h" | 15 #include "chromecast/shell/browser/cast_browser_context.h" |
16 #include "chromecast/shell/browser/cast_browser_process.h" | 16 #include "chromecast/shell/browser/cast_browser_process.h" |
17 #include "chromecast/shell/browser/devtools/remote_debugging_server.h" | 17 #include "chromecast/shell/browser/devtools/remote_debugging_server.h" |
18 #include "chromecast/shell/browser/url_request_context_factory.h" | 18 #include "chromecast/shell/browser/url_request_context_factory.h" |
19 #include "chromecast/shell/browser/webui/webui_cast.h" | 19 #include "chromecast/shell/browser/webui/webui_cast.h" |
| 20 #include "content/public/browser/browser_thread.h" |
20 #include "content/public/common/content_switches.h" | 21 #include "content/public/common/content_switches.h" |
21 | 22 |
22 #if defined(OS_ANDROID) | 23 #if defined(OS_ANDROID) |
23 #include "net/android/network_change_notifier_factory_android.h" | 24 #include "net/android/network_change_notifier_factory_android.h" |
24 #endif // defined(OS_ANDROID) | 25 #endif // defined(OS_ANDROID) |
25 | 26 |
26 namespace chromecast { | 27 namespace chromecast { |
27 namespace shell { | 28 namespace shell { |
28 | 29 |
29 namespace { | 30 namespace { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 return 0; | 87 return 0; |
87 } | 88 } |
88 | 89 |
89 void CastBrowserMainParts::PreMainMessageLoopRun() { | 90 void CastBrowserMainParts::PreMainMessageLoopRun() { |
90 url_request_context_factory_->InitializeOnUIThread(); | 91 url_request_context_factory_->InitializeOnUIThread(); |
91 | 92 |
92 cast_browser_process_->SetBrowserContext( | 93 cast_browser_process_->SetBrowserContext( |
93 new CastBrowserContext(url_request_context_factory_)); | 94 new CastBrowserContext(url_request_context_factory_)); |
94 cast_browser_process_->SetMetricsServiceClient( | 95 cast_browser_process_->SetMetricsServiceClient( |
95 metrics::CastMetricsServiceClient::Create( | 96 metrics::CastMetricsServiceClient::Create( |
| 97 content::BrowserThread::GetBlockingPool(), |
96 ChromecastConfig::GetInstance()->pref_service(), | 98 ChromecastConfig::GetInstance()->pref_service(), |
97 cast_browser_process_->browser_context()->GetRequestContext())); | 99 cast_browser_process_->browser_context()->GetRequestContext())); |
98 cast_browser_process_->SetRemoteDebuggingServer(new RemoteDebuggingServer()); | 100 cast_browser_process_->SetRemoteDebuggingServer(new RemoteDebuggingServer()); |
99 | 101 |
100 InitializeWebUI(); | 102 InitializeWebUI(); |
101 | 103 |
102 cast_browser_process_->SetCastService( | 104 cast_browser_process_->SetCastService( |
103 CastService::Create(cast_browser_process_->browser_context())); | 105 CastService::Create(cast_browser_process_->browser_context())); |
104 cast_browser_process_->cast_service()->Start(); | 106 cast_browser_process_->cast_service()->Start(); |
105 } | 107 } |
106 | 108 |
107 bool CastBrowserMainParts::MainMessageLoopRun(int* result_code) { | 109 bool CastBrowserMainParts::MainMessageLoopRun(int* result_code) { |
108 // If parameters_.ui_task is not NULL, we are running browser tests. In this | 110 // If parameters_.ui_task is not NULL, we are running browser tests. In this |
109 // case, the browser's main message loop will not run. | 111 // case, the browser's main message loop will not run. |
110 if (parameters_.ui_task) { | 112 if (parameters_.ui_task) { |
111 parameters_.ui_task->Run(); | 113 parameters_.ui_task->Run(); |
112 } else { | 114 } else { |
113 base::MessageLoopForUI::current()->Run(); | 115 base::MessageLoopForUI::current()->Run(); |
114 } | 116 } |
115 return true; | 117 return true; |
116 } | 118 } |
117 | 119 |
118 void CastBrowserMainParts::PostMainMessageLoopRun() { | 120 void CastBrowserMainParts::PostMainMessageLoopRun() { |
119 cast_browser_process_->cast_service()->Stop(); | 121 cast_browser_process_->cast_service()->Stop(); |
120 cast_browser_process_.reset(); | 122 cast_browser_process_.reset(); |
121 } | 123 } |
122 | 124 |
123 } // namespace shell | 125 } // namespace shell |
124 } // namespace chromecast | 126 } // namespace chromecast |
OLD | NEW |