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/prefs/pref_registry_simple.h" | 9 #include "base/prefs/pref_registry_simple.h" |
9 #include "chromecast/common/chromecast_config.h" | 10 #include "chromecast/common/chromecast_config.h" |
10 #include "chromecast/metrics/cast_metrics_service_client.h" | 11 #include "chromecast/metrics/cast_metrics_service_client.h" |
11 #include "chromecast/net/network_change_notifier_cast.h" | 12 #include "chromecast/net/network_change_notifier_cast.h" |
12 #include "chromecast/net/network_change_notifier_factory_cast.h" | 13 #include "chromecast/net/network_change_notifier_factory_cast.h" |
13 #include "chromecast/service/cast_service.h" | 14 #include "chromecast/service/cast_service.h" |
14 #include "chromecast/shell/browser/cast_browser_context.h" | 15 #include "chromecast/shell/browser/cast_browser_context.h" |
15 #include "chromecast/shell/browser/cast_browser_process.h" | 16 #include "chromecast/shell/browser/cast_browser_process.h" |
16 #include "chromecast/shell/browser/devtools/remote_debugging_server.h" | 17 #include "chromecast/shell/browser/devtools/remote_debugging_server.h" |
17 #include "chromecast/shell/browser/url_request_context_factory.h" | 18 #include "chromecast/shell/browser/url_request_context_factory.h" |
18 #include "chromecast/shell/browser/webui/webui_cast.h" | 19 #include "chromecast/shell/browser/webui/webui_cast.h" |
19 #include "content/public/common/content_switches.h" | 20 #include "content/public/common/content_switches.h" |
20 | 21 |
| 22 #if defined(OS_ANDROID) |
| 23 #include "net/android/network_change_notifier_factory_android.h" |
| 24 #endif // defined(OS_ANDROID) |
| 25 |
21 namespace chromecast { | 26 namespace chromecast { |
22 namespace shell { | 27 namespace shell { |
23 | 28 |
24 namespace { | 29 namespace { |
25 | 30 |
26 struct DefaultCommandLineSwitch { | 31 struct DefaultCommandLineSwitch { |
27 const char* const switch_name; | 32 const char* const switch_name; |
28 const char* const switch_value; | 33 const char* const switch_value; |
29 }; | 34 }; |
30 | 35 |
(...skipping 22 matching lines...) Expand all Loading... |
53 cast_browser_process_(new CastBrowserProcess()), | 58 cast_browser_process_(new CastBrowserProcess()), |
54 url_request_context_factory_(url_request_context_factory) { | 59 url_request_context_factory_(url_request_context_factory) { |
55 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 60 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
56 AddDefaultCommandLineSwitches(command_line); | 61 AddDefaultCommandLineSwitches(command_line); |
57 } | 62 } |
58 | 63 |
59 CastBrowserMainParts::~CastBrowserMainParts() { | 64 CastBrowserMainParts::~CastBrowserMainParts() { |
60 } | 65 } |
61 | 66 |
62 void CastBrowserMainParts::PreMainMessageLoopStart() { | 67 void CastBrowserMainParts::PreMainMessageLoopStart() { |
| 68 #if defined(OS_ANDROID) |
| 69 net::NetworkChangeNotifier::SetFactory( |
| 70 new net::NetworkChangeNotifierFactoryAndroid()); |
| 71 #else |
63 net::NetworkChangeNotifier::SetFactory( | 72 net::NetworkChangeNotifier::SetFactory( |
64 new NetworkChangeNotifierFactoryCast()); | 73 new NetworkChangeNotifierFactoryCast()); |
| 74 #endif // defined(OS_ANDROID) |
65 } | 75 } |
66 | 76 |
67 void CastBrowserMainParts::PostMainMessageLoopStart() { | 77 void CastBrowserMainParts::PostMainMessageLoopStart() { |
68 NOTIMPLEMENTED(); | 78 #if defined(OS_ANDROID) |
| 79 base::MessageLoopForUI::current()->Start(); |
| 80 #endif // defined(OS_ANDROID) |
69 } | 81 } |
70 | 82 |
71 int CastBrowserMainParts::PreCreateThreads() { | 83 int CastBrowserMainParts::PreCreateThreads() { |
72 ChromecastConfig::Create(new PrefRegistrySimple()); | 84 ChromecastConfig::Create(new PrefRegistrySimple()); |
73 return 0; | 85 return 0; |
74 } | 86 } |
75 | 87 |
76 void CastBrowserMainParts::PreMainMessageLoopRun() { | 88 void CastBrowserMainParts::PreMainMessageLoopRun() { |
77 url_request_context_factory_->InitializeOnUIThread(); | 89 url_request_context_factory_->InitializeOnUIThread(); |
78 | 90 |
(...skipping 17 matching lines...) Expand all Loading... |
96 return true; | 108 return true; |
97 } | 109 } |
98 | 110 |
99 void CastBrowserMainParts::PostMainMessageLoopRun() { | 111 void CastBrowserMainParts::PostMainMessageLoopRun() { |
100 cast_browser_process_->cast_service()->Stop(); | 112 cast_browser_process_->cast_service()->Stop(); |
101 cast_browser_process_.reset(); | 113 cast_browser_process_.reset(); |
102 } | 114 } |
103 | 115 |
104 } // namespace shell | 116 } // namespace shell |
105 } // namespace chromecast | 117 } // namespace chromecast |
OLD | NEW |