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/prefs/pref_registry_simple.h" | 8 #include "base/prefs/pref_registry_simple.h" |
9 #include "chromecast/common/chromecast_config.h" | 9 #include "chromecast/common/chromecast_config.h" |
10 #include "chromecast/metrics/cast_metrics_service_client.h" | 10 #include "chromecast/metrics/cast_metrics_service_client.h" |
11 #include "chromecast/net/network_change_notifier_cast.h" | 11 #include "chromecast/net/network_change_notifier_cast.h" |
12 #include "chromecast/net/network_change_notifier_factory_cast.h" | 12 #include "chromecast/net/network_change_notifier_factory_cast.h" |
13 #include "chromecast/service/cast_service.h" | 13 #include "chromecast/service/cast_service.h" |
14 #include "chromecast/shell/browser/cast_browser_context.h" | 14 #include "chromecast/shell/browser/cast_browser_context.h" |
| 15 #include "chromecast/shell/browser/cast_browser_process.h" |
15 #include "chromecast/shell/browser/devtools/remote_debugging_server.h" | 16 #include "chromecast/shell/browser/devtools/remote_debugging_server.h" |
16 #include "chromecast/shell/browser/url_request_context_factory.h" | 17 #include "chromecast/shell/browser/url_request_context_factory.h" |
17 #include "chromecast/shell/browser/webui/webui_cast.h" | 18 #include "chromecast/shell/browser/webui/webui_cast.h" |
18 #include "content/public/common/content_switches.h" | 19 #include "content/public/common/content_switches.h" |
19 | 20 |
20 namespace chromecast { | 21 namespace chromecast { |
21 namespace shell { | 22 namespace shell { |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
(...skipping 17 matching lines...) Expand all Loading... |
42 ++i; | 43 ++i; |
43 } | 44 } |
44 } | 45 } |
45 | 46 |
46 } // namespace | 47 } // namespace |
47 | 48 |
48 CastBrowserMainParts::CastBrowserMainParts( | 49 CastBrowserMainParts::CastBrowserMainParts( |
49 const content::MainFunctionParams& parameters, | 50 const content::MainFunctionParams& parameters, |
50 URLRequestContextFactory* url_request_context_factory) | 51 URLRequestContextFactory* url_request_context_factory) |
51 : BrowserMainParts(), | 52 : BrowserMainParts(), |
| 53 cast_browser_process_(new CastBrowserProcess()), |
52 url_request_context_factory_(url_request_context_factory) { | 54 url_request_context_factory_(url_request_context_factory) { |
53 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 55 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
54 AddDefaultCommandLineSwitches(command_line); | 56 AddDefaultCommandLineSwitches(command_line); |
55 } | 57 } |
56 | 58 |
57 CastBrowserMainParts::~CastBrowserMainParts() { | 59 CastBrowserMainParts::~CastBrowserMainParts() { |
58 } | 60 } |
59 | 61 |
60 void CastBrowserMainParts::PreMainMessageLoopStart() { | 62 void CastBrowserMainParts::PreMainMessageLoopStart() { |
61 net::NetworkChangeNotifier::SetFactory( | 63 net::NetworkChangeNotifier::SetFactory( |
62 new NetworkChangeNotifierFactoryCast()); | 64 new NetworkChangeNotifierFactoryCast()); |
63 } | 65 } |
64 | 66 |
65 void CastBrowserMainParts::PostMainMessageLoopStart() { | 67 void CastBrowserMainParts::PostMainMessageLoopStart() { |
66 NOTIMPLEMENTED(); | 68 NOTIMPLEMENTED(); |
67 } | 69 } |
68 | 70 |
69 int CastBrowserMainParts::PreCreateThreads() { | 71 int CastBrowserMainParts::PreCreateThreads() { |
70 ChromecastConfig::Create(new PrefRegistrySimple()); | 72 ChromecastConfig::Create(new PrefRegistrySimple()); |
71 return 0; | 73 return 0; |
72 } | 74 } |
73 | 75 |
74 void CastBrowserMainParts::PreMainMessageLoopRun() { | 76 void CastBrowserMainParts::PreMainMessageLoopRun() { |
75 url_request_context_factory_->InitializeOnUIThread(); | 77 url_request_context_factory_->InitializeOnUIThread(); |
76 | 78 |
77 browser_context_.reset(new CastBrowserContext(url_request_context_factory_)); | 79 cast_browser_process_->SetBrowserContext( |
78 metrics_service_client_.reset(metrics::CastMetricsServiceClient::Create( | 80 new CastBrowserContext(url_request_context_factory_)); |
79 ChromecastConfig::GetInstance()->pref_service(), | 81 cast_browser_process_->SetMetricsServiceClient( |
80 browser_context_->GetRequestContext())); | 82 metrics::CastMetricsServiceClient::Create( |
81 dev_tools_.reset(new RemoteDebuggingServer()); | 83 ChromecastConfig::GetInstance()->pref_service(), |
| 84 cast_browser_process_->browser_context()->GetRequestContext())); |
| 85 cast_browser_process_->SetRemoteDebuggingServer(new RemoteDebuggingServer()); |
82 | 86 |
83 InitializeWebUI(); | 87 InitializeWebUI(); |
84 | 88 |
85 cast_service_.reset(CastService::Create(browser_context_.get())); | 89 cast_browser_process_->SetCastService( |
86 cast_service_->Start(); | 90 CastService::Create(cast_browser_process_->browser_context())); |
| 91 cast_browser_process_->cast_service()->Start(); |
87 } | 92 } |
88 | 93 |
89 bool CastBrowserMainParts::MainMessageLoopRun(int* result_code) { | 94 bool CastBrowserMainParts::MainMessageLoopRun(int* result_code) { |
90 base::MessageLoopForUI::current()->Run(); | 95 base::MessageLoopForUI::current()->Run(); |
91 return true; | 96 return true; |
92 } | 97 } |
93 | 98 |
94 void CastBrowserMainParts::PostMainMessageLoopRun() { | 99 void CastBrowserMainParts::PostMainMessageLoopRun() { |
95 cast_service_->Stop(); | 100 cast_browser_process_->cast_service()->Stop(); |
96 | 101 cast_browser_process_.reset(); |
97 cast_service_.reset(); | |
98 dev_tools_.reset(); | |
99 metrics_service_client_.reset(); | |
100 browser_context_.reset(); | |
101 } | 102 } |
102 | 103 |
103 } // namespace shell | 104 } // namespace shell |
104 } // namespace chromecast | 105 } // namespace chromecast |
OLD | NEW |