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" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 } | 49 } |
50 } | 50 } |
51 | 51 |
52 } // namespace | 52 } // namespace |
53 | 53 |
54 CastBrowserMainParts::CastBrowserMainParts( | 54 CastBrowserMainParts::CastBrowserMainParts( |
55 const content::MainFunctionParams& parameters, | 55 const content::MainFunctionParams& parameters, |
56 URLRequestContextFactory* url_request_context_factory) | 56 URLRequestContextFactory* url_request_context_factory) |
57 : BrowserMainParts(), | 57 : BrowserMainParts(), |
58 cast_browser_process_(new CastBrowserProcess()), | 58 cast_browser_process_(new CastBrowserProcess()), |
| 59 parameters_(parameters), |
59 url_request_context_factory_(url_request_context_factory) { | 60 url_request_context_factory_(url_request_context_factory) { |
60 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 61 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
61 AddDefaultCommandLineSwitches(command_line); | 62 AddDefaultCommandLineSwitches(command_line); |
62 } | 63 } |
63 | 64 |
64 CastBrowserMainParts::~CastBrowserMainParts() { | 65 CastBrowserMainParts::~CastBrowserMainParts() { |
65 } | 66 } |
66 | 67 |
67 void CastBrowserMainParts::PreMainMessageLoopStart() { | 68 void CastBrowserMainParts::PreMainMessageLoopStart() { |
68 #if defined(OS_ANDROID) | 69 #if defined(OS_ANDROID) |
(...skipping 28 matching lines...) Expand all Loading... |
97 cast_browser_process_->SetRemoteDebuggingServer(new RemoteDebuggingServer()); | 98 cast_browser_process_->SetRemoteDebuggingServer(new RemoteDebuggingServer()); |
98 | 99 |
99 InitializeWebUI(); | 100 InitializeWebUI(); |
100 | 101 |
101 cast_browser_process_->SetCastService( | 102 cast_browser_process_->SetCastService( |
102 CastService::Create(cast_browser_process_->browser_context())); | 103 CastService::Create(cast_browser_process_->browser_context())); |
103 cast_browser_process_->cast_service()->Start(); | 104 cast_browser_process_->cast_service()->Start(); |
104 } | 105 } |
105 | 106 |
106 bool CastBrowserMainParts::MainMessageLoopRun(int* result_code) { | 107 bool CastBrowserMainParts::MainMessageLoopRun(int* result_code) { |
107 base::MessageLoopForUI::current()->Run(); | 108 // 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. |
| 110 if (parameters_.ui_task) { |
| 111 parameters_.ui_task->Run(); |
| 112 } else { |
| 113 base::MessageLoopForUI::current()->Run(); |
| 114 } |
108 return true; | 115 return true; |
109 } | 116 } |
110 | 117 |
111 void CastBrowserMainParts::PostMainMessageLoopRun() { | 118 void CastBrowserMainParts::PostMainMessageLoopRun() { |
112 cast_browser_process_->cast_service()->Stop(); | 119 cast_browser_process_->cast_service()->Stop(); |
113 cast_browser_process_.reset(); | 120 cast_browser_process_.reset(); |
114 } | 121 } |
115 | 122 |
116 } // namespace shell | 123 } // namespace shell |
117 } // namespace chromecast | 124 } // namespace chromecast |
OLD | NEW |