Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(416)

Side by Side Diff: chrome/browser/chrome_browser_main.cc

Issue 1423063004: Allow Chrome to bind an Application request from mojo_runner. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@callback
Patch Set: . Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/chrome_browser_main.h" 5 #include "chrome/browser/chrome_browser_main.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 #include "chrome/browser/component_updater/swiftshader_component_installer.h" 56 #include "chrome/browser/component_updater/swiftshader_component_installer.h"
57 #include "chrome/browser/component_updater/widevine_cdm_component_installer.h" 57 #include "chrome/browser/component_updater/widevine_cdm_component_installer.h"
58 #include "chrome/browser/defaults.h" 58 #include "chrome/browser/defaults.h"
59 #include "chrome/browser/first_run/first_run.h" 59 #include "chrome/browser/first_run/first_run.h"
60 #include "chrome/browser/gpu/gl_string_manager.h" 60 #include "chrome/browser/gpu/gl_string_manager.h"
61 #include "chrome/browser/gpu/three_d_api_observer.h" 61 #include "chrome/browser/gpu/three_d_api_observer.h"
62 #include "chrome/browser/media/media_capture_devices_dispatcher.h" 62 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
63 #include "chrome/browser/memory/tab_manager.h" 63 #include "chrome/browser/memory/tab_manager.h"
64 #include "chrome/browser/metrics/field_trial_synchronizer.h" 64 #include "chrome/browser/metrics/field_trial_synchronizer.h"
65 #include "chrome/browser/metrics/thread_watcher.h" 65 #include "chrome/browser/metrics/thread_watcher.h"
66 #include "chrome/browser/mojo_runner_util.h"
66 #include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h" 67 #include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h"
67 #include "chrome/browser/net/crl_set_fetcher.h" 68 #include "chrome/browser/net/crl_set_fetcher.h"
68 #include "chrome/browser/performance_monitor/performance_monitor.h" 69 #include "chrome/browser/performance_monitor/performance_monitor.h"
69 #include "chrome/browser/plugins/plugin_prefs.h" 70 #include "chrome/browser/plugins/plugin_prefs.h"
70 #include "chrome/browser/power/process_power_collector.h" 71 #include "chrome/browser/power/process_power_collector.h"
71 #include "chrome/browser/prefs/chrome_pref_service_factory.h" 72 #include "chrome/browser/prefs/chrome_pref_service_factory.h"
72 #include "chrome/browser/prefs/command_line_pref_store.h" 73 #include "chrome/browser/prefs/command_line_pref_store.h"
73 #include "chrome/browser/prefs/incognito_mode_prefs.h" 74 #include "chrome/browser/prefs/incognito_mode_prefs.h"
74 #include "chrome/browser/prefs/pref_metrics_service.h" 75 #include "chrome/browser/prefs/pref_metrics_service.h"
75 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" 76 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 241
241 #if defined(USE_AURA) 242 #if defined(USE_AURA)
242 #include "ui/aura/env.h" 243 #include "ui/aura/env.h"
243 #endif // defined(USE_AURA) 244 #endif // defined(USE_AURA)
244 245
245 #if !defined(OS_ANDROID) && !defined(OS_IOS) 246 #if !defined(OS_ANDROID) && !defined(OS_IOS)
246 #include "chrome/browser/chrome_webusb_browser_client.h" 247 #include "chrome/browser/chrome_webusb_browser_client.h"
247 #include "components/webusb/webusb_detector.h" 248 #include "components/webusb/webusb_detector.h"
248 #endif 249 #endif
249 250
251 #if defined(MOJO_RUNNER_CLIENT)
252 #include "mojo/application/public/cpp/application_delegate.h"
253 #include "mojo/application/public/cpp/application_impl.h"
254 #include "mojo/runner/child/runner_connection.h"
255 #endif
256
250 using content::BrowserThread; 257 using content::BrowserThread;
251 258
252 namespace { 259 namespace {
253 260
254 // This function provides some ways to test crash and assertion handling 261 // This function provides some ways to test crash and assertion handling
255 // behavior of the program. 262 // behavior of the program.
256 void HandleTestParameters(const base::CommandLine& command_line) { 263 void HandleTestParameters(const base::CommandLine& command_line) {
257 // This parameter causes a null pointer crash (crash reporter trigger). 264 // This parameter causes a null pointer crash (crash reporter trigger).
258 if (command_line.HasSwitch(switches::kBrowserCrashTest)) { 265 if (command_line.HasSwitch(switches::kBrowserCrashTest)) {
259 int* bad_pointer = NULL; 266 int* bad_pointer = NULL;
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 #endif // defined(OS_WIN) 571 #endif // defined(OS_WIN)
565 572
566 #if defined(OS_WIN) 573 #if defined(OS_WIN)
567 // TODO(port) This should be used on Linux Aura as well. http://crbug.com/338969 574 // TODO(port) This should be used on Linux Aura as well. http://crbug.com/338969
568 const char kMissingLocaleDataMessage[] = 575 const char kMissingLocaleDataMessage[] =
569 "Unable to find locale data files. Please reinstall."; 576 "Unable to find locale data files. Please reinstall.";
570 #endif // defined(OS_WIN) 577 #endif // defined(OS_WIN)
571 578
572 } // namespace chrome_browser 579 } // namespace chrome_browser
573 580
581 #if defined(MOJO_RUNNER_CLIENT)
582 class ChromeApplicationDelegate : public mojo::ApplicationDelegate {
583 public:
584 ChromeApplicationDelegate() {}
585 ~ChromeApplicationDelegate() override {}
586
587 // Runs the current thread's message loop until we receive an Initialize()
588 // call from the shell.
589 void RunUntilInitialize() {
590 base::MessageLoop::current()->Run();
sky 2015/11/05 00:29:34 You sure you want to run a nested message loop her
591 }
592
593 private:
594 void Initialize(mojo::ApplicationImpl* application) override {
595 // TODO(beng): Connect to the window manager.
596 base::MessageLoop::current()->QuitNow();
597 }
598 bool ConfigureIncomingConnection(
599 mojo::ApplicationConnection* connection) override {
600 return false;
601 }
602
603 DISALLOW_COPY_AND_ASSIGN(ChromeApplicationDelegate);
604 };
605 #endif // defined(MOJO_RUNNER_CLIENT)
606
574 // BrowserMainParts ------------------------------------------------------------ 607 // BrowserMainParts ------------------------------------------------------------
575 608
576 ChromeBrowserMainParts::ChromeBrowserMainParts( 609 ChromeBrowserMainParts::ChromeBrowserMainParts(
577 const content::MainFunctionParams& parameters) 610 const content::MainFunctionParams& parameters)
578 : parameters_(parameters), 611 : parameters_(parameters),
579 parsed_command_line_(parameters.command_line), 612 parsed_command_line_(parameters.command_line),
580 result_code_(content::RESULT_CODE_NORMAL_EXIT), 613 result_code_(content::RESULT_CODE_NORMAL_EXIT),
581 startup_watcher_(new StartupTimeBomb()), 614 startup_watcher_(new StartupTimeBomb()),
582 shutdown_watcher_(new ShutdownWatcherHelper()), 615 shutdown_watcher_(new ShutdownWatcherHelper()),
583 browser_field_trials_(parameters.command_line), 616 browser_field_trials_(parameters.command_line),
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 } 1238 }
1206 1239
1207 int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { 1240 int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
1208 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreMainMessageLoopRunImpl"); 1241 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreMainMessageLoopRunImpl");
1209 TRACK_SCOPED_REGION( 1242 TRACK_SCOPED_REGION(
1210 "Startup", "ChromeBrowserMainParts::PreMainMessageLoopRunImpl"); 1243 "Startup", "ChromeBrowserMainParts::PreMainMessageLoopRunImpl");
1211 1244
1212 SCOPED_UMA_HISTOGRAM_LONG_TIMER("Startup.PreMainMessageLoopRunImplLongTime"); 1245 SCOPED_UMA_HISTOGRAM_LONG_TIMER("Startup.PreMainMessageLoopRunImplLongTime");
1213 const base::TimeTicks start_time_step1 = base::TimeTicks::Now(); 1246 const base::TimeTicks start_time_step1 = base::TimeTicks::Now();
1214 1247
1248 #if defined(MOJO_RUNNER_CLIENT)
1249 if (chrome::IsRunningInMojoRunner()) {
1250 // When run from the Mojo Runner, block until we can bind an Application
1251 // request from the runner's shell, and run the main message loop until
1252 // our bound ApplicationImpl is ready to use.
1253 mojo::InterfaceRequest<mojo::Application> application_request;
1254 runner_connection_.reset(
1255 mojo::runner::RunnerConnection::ConnectToRunner(&application_request));
1256 application_delegate_.reset(new ChromeApplicationDelegate);
1257 application_impl_.reset(new mojo::ApplicationImpl(
1258 application_delegate_.get(), application_request.Pass()));
1259 application_delegate_->RunUntilInitialize();
1260 }
1261 #endif // defined(MOJO_RUNNER_CLIENT)
1262
1215 #if defined(OS_WIN) 1263 #if defined(OS_WIN)
1216 // Windows parental controls calls can be slow, so we do an early init here 1264 // Windows parental controls calls can be slow, so we do an early init here
1217 // that calculates this value off of the UI thread. 1265 // that calculates this value off of the UI thread.
1218 IncognitoModePrefs::InitializePlatformParentalControls(); 1266 IncognitoModePrefs::InitializePlatformParentalControls();
1219 #endif 1267 #endif
1220 1268
1221 #if defined(ENABLE_EXTENSIONS) 1269 #if defined(ENABLE_EXTENSIONS)
1222 if (!variations::GetVariationParamValue( 1270 if (!variations::GetVariationParamValue(
1223 "LightSpeed", "EarlyInitStartup").empty()) { 1271 "LightSpeed", "EarlyInitStartup").empty()) {
1224 // Try to compute this early on another thread so that we don't spend time 1272 // Try to compute this early on another thread so that we don't spend time
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
1850 chromeos::CrosSettings::Shutdown(); 1898 chromeos::CrosSettings::Shutdown();
1851 #endif // defined(OS_CHROMEOS) 1899 #endif // defined(OS_CHROMEOS)
1852 #endif // defined(OS_ANDROID) 1900 #endif // defined(OS_ANDROID)
1853 } 1901 }
1854 1902
1855 // Public members: 1903 // Public members:
1856 1904
1857 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { 1905 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) {
1858 chrome_extra_parts_.push_back(parts); 1906 chrome_extra_parts_.push_back(parts);
1859 } 1907 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698