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

Side by Side Diff: chrome/browser/chromeos/chrome_browser_main_chromeos.cc

Issue 11469044: Implement new network change notifier that uses NetworkStateHandler (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: address comments + move back to chromeos/ Created 8 years 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
« no previous file with comments | « no previous file | chromeos/chromeos.gyp » ('j') | chromeos/network/network_state.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/chromeos/chrome_browser_main_chromeos.h" 5 #include "chrome/browser/chromeos/chrome_browser_main_chromeos.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 #include "chrome/common/chrome_version_info.h" 77 #include "chrome/common/chrome_version_info.h"
78 #include "chrome/common/logging_chrome.h" 78 #include "chrome/common/logging_chrome.h"
79 #include "chrome/common/pref_names.h" 79 #include "chrome/common/pref_names.h"
80 #include "chromeos/chromeos_switches.h" 80 #include "chromeos/chromeos_switches.h"
81 #include "chromeos/cryptohome/async_method_caller.h" 81 #include "chromeos/cryptohome/async_method_caller.h"
82 #include "chromeos/dbus/dbus_thread_manager.h" 82 #include "chromeos/dbus/dbus_thread_manager.h"
83 #include "chromeos/dbus/power_manager_client.h" 83 #include "chromeos/dbus/power_manager_client.h"
84 #include "chromeos/dbus/session_manager_client.h" 84 #include "chromeos/dbus/session_manager_client.h"
85 #include "chromeos/disks/disk_mount_manager.h" 85 #include "chromeos/disks/disk_mount_manager.h"
86 #include "chromeos/display/output_configurator.h" 86 #include "chromeos/display/output_configurator.h"
87 #include "chromeos/network/network_change_notifier_chromeos.h"
88 #include "chromeos/network/network_change_notifier_factory_chromeos.h"
87 #include "chromeos/network/network_configuration_handler.h" 89 #include "chromeos/network/network_configuration_handler.h"
88 #include "chromeos/network/network_event_log.h" 90 #include "chromeos/network/network_event_log.h"
89 #include "chromeos/network/network_state_handler.h" 91 #include "chromeos/network/network_state_handler.h"
90 #include "chromeos/power/power_state_override.h" 92 #include "chromeos/power/power_state_override.h"
91 #include "content/public/browser/notification_service.h" 93 #include "content/public/browser/notification_service.h"
92 #include "content/public/common/main_function_params.h" 94 #include "content/public/common/main_function_params.h"
93 #include "grit/platform_locale_settings.h" 95 #include "grit/platform_locale_settings.h"
94 #include "net/base/network_change_notifier.h" 96 #include "net/base/network_change_notifier.h"
95 #include "net/url_request/url_request.h" 97 #include "net/url_request/url_request.h"
96 98
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 CrosDBusService::Initialize(); 248 CrosDBusService::Initialize();
247 249
248 // This function and SystemKeyEventListener use InputMethodManager. 250 // This function and SystemKeyEventListener use InputMethodManager.
249 chromeos::input_method::Initialize(); 251 chromeos::input_method::Initialize();
250 disks::DiskMountManager::Initialize(); 252 disks::DiskMountManager::Initialize();
251 cryptohome::AsyncMethodCaller::Initialize(); 253 cryptohome::AsyncMethodCaller::Initialize();
252 254
253 // Initialize the network change notifier for Chrome OS. The network 255 // Initialize the network change notifier for Chrome OS. The network
254 // change notifier starts to monitor changes from the power manager and 256 // change notifier starts to monitor changes from the power manager and
255 // the network manager. 257 // the network manager.
256 CrosNetworkChangeNotifierFactory::GetInstance()->Init(); 258 if (!CommandLine::ForCurrentProcess()->HasSwitch(
259 chromeos::switches::kEnableNewNetworkHandlers)) {
260 CrosNetworkChangeNotifierFactory::GetInstance()->Init();
261 }
257 262
258 // Likewise, initialize the upgrade detector for Chrome OS. The upgrade 263 // Likewise, initialize the upgrade detector for Chrome OS. The upgrade
259 // detector starts to monitor changes from the update engine. 264 // detector starts to monitor changes from the update engine.
260 UpgradeDetectorChromeos::GetInstance()->Init(); 265 UpgradeDetectorChromeos::GetInstance()->Init();
261 266
262 if (base::chromeos::IsRunningOnChromeOS()) { 267 if (base::chromeos::IsRunningOnChromeOS()) {
263 // Disable Num Lock on X start up for http://crosbug.com/29169. 268 // Disable Num Lock on X start up for http://crosbug.com/29169.
264 input_method::GetInputMethodManager()->GetXKeyboard()-> 269 input_method::GetInputMethodManager()->GetXKeyboard()->
265 SetNumLockEnabled(false); 270 SetNumLockEnabled(false);
266 } 271 }
(...skipping 12 matching lines...) Expand all
279 // longer required. (Switch is set in about_flags.cc and not applied until 284 // longer required. (Switch is set in about_flags.cc and not applied until
280 // after DBusServices() is called). 285 // after DBusServices() is called).
281 void InitializeNetworkHandlers() { 286 void InitializeNetworkHandlers() {
282 if (!CommandLine::ForCurrentProcess()->HasSwitch( 287 if (!CommandLine::ForCurrentProcess()->HasSwitch(
283 chromeos::switches::kEnableNewNetworkHandlers)) 288 chromeos::switches::kEnableNewNetworkHandlers))
284 return; 289 return;
285 chromeos::network_event_log::Initialize(); 290 chromeos::network_event_log::Initialize();
286 chromeos::NetworkStateHandler::Initialize(); 291 chromeos::NetworkStateHandler::Initialize();
287 chromeos::NetworkConfigurationHandler::Initialize(); 292 chromeos::NetworkConfigurationHandler::Initialize();
288 network_handlers_initialized_ = true; 293 network_handlers_initialized_ = true;
294 // TODO(gauravsh): This needs re-factoring. NetworkChangeNotifier choice
295 // needs to be made before about:flags are processed.
296 NetworkChangeNotifierFactoryChromeos::GetInstance()->Initialize();
289 } 297 }
290 298
291 ~DBusServices() { 299 ~DBusServices() {
292 // CrosLibrary is shut down before DBusThreadManager even though it 300 // CrosLibrary is shut down before DBusThreadManager even though it
293 // is initialized first becuase some of its libraries depend on DBus 301 // is initialized first becuase some of its libraries depend on DBus
294 // clients. 302 // clients.
295 // TODO(hashimoto): Resolve this situation by removing CrosLibrary. 303 // TODO(hashimoto): Resolve this situation by removing CrosLibrary.
296 // (crosbug.com/26160) 304 // (crosbug.com/26160)
297 if (cros_initialized_ && CrosLibrary::Get()) 305 if (cros_initialized_ && CrosLibrary::Get())
298 CrosLibrary::Shutdown(); 306 CrosLibrary::Shutdown();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 ::switches::kLoginProfile).value(); 378 ::switches::kLoginProfile).value();
371 } 379 }
372 380
373 ChromeBrowserMainPartsLinux::PreEarlyInitialization(); 381 ChromeBrowserMainPartsLinux::PreEarlyInitialization();
374 } 382 }
375 383
376 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopStart() { 384 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopStart() {
377 // Replace the default NetworkChangeNotifierFactory with ChromeOS specific 385 // Replace the default NetworkChangeNotifierFactory with ChromeOS specific
378 // implementation. This must be done before BrowserMainLoop calls 386 // implementation. This must be done before BrowserMainLoop calls
379 // net::NetworkChangeNotifier::Create() in MainMessageLoopStart(). 387 // net::NetworkChangeNotifier::Create() in MainMessageLoopStart().
380 net::NetworkChangeNotifier::SetFactory( 388 net::NetworkChangeNotifierFactory* network_change_factory;
381 new CrosNetworkChangeNotifierFactory()); 389 // Note: At the time this is called, we have not processed about:flags
382 390 // so this requires that the network handler flag was passed in at the command
391 // line.
392 if (!CommandLine::ForCurrentProcess()->HasSwitch(
393 chromeos::switches::kEnableNewNetworkHandlers)) {
394 network_change_factory = new CrosNetworkChangeNotifierFactory();
395 } else {
396 LOG(WARNING) << "Using new connection change notifier.";
397 network_change_factory = new NetworkChangeNotifierFactoryChromeos();
398 }
399 net::NetworkChangeNotifier::SetFactory(network_change_factory);
383 ChromeBrowserMainPartsLinux::PreMainMessageLoopStart(); 400 ChromeBrowserMainPartsLinux::PreMainMessageLoopStart();
384 } 401 }
385 402
386 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() { 403 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() {
387 MessageLoopForUI* message_loop = MessageLoopForUI::current(); 404 MessageLoopForUI* message_loop = MessageLoopForUI::current();
388 message_loop->AddObserver(g_message_loop_observer.Pointer()); 405 message_loop->AddObserver(g_message_loop_observer.Pointer());
389 406
390 dbus_services_.reset(new internal::DBusServices(parameters())); 407 dbus_services_.reset(new internal::DBusServices(parameters()));
391 408
392 ChromeBrowserMainPartsLinux::PostMainMessageLoopStart(); 409 ChromeBrowserMainPartsLinux::PostMainMessageLoopStart();
393 } 410 }
394 411
395 // Threads are initialized between MainMessageLoopStart and MainMessageLoopRun. 412 // Threads are initialized between MainMessageLoopStart and MainMessageLoopRun.
396 // about_flags settings are applied in ChromeBrowserMainParts::PreCreateThreads. 413 // about_flags settings are applied in ChromeBrowserMainParts::PreCreateThreads.
397
398 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() { 414 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() {
399 // Must be called after about_flags settings are applied (see note above). 415 // Must be called after about_flags settings are applied (see note above).
400 dbus_services_->InitializeNetworkHandlers(); 416 dbus_services_->InitializeNetworkHandlers();
401 417
402 AudioHandler::Initialize(); 418 AudioHandler::Initialize();
403 imageburner::BurnManager::Initialize(); 419 imageburner::BurnManager::Initialize();
404 420
405 // Listen for system key events so that the user will be able to adjust the 421 // Listen for system key events so that the user will be able to adjust the
406 // volume on the login screen, if Chrome is running on Chrome OS 422 // volume on the login screen, if Chrome is running on Chrome OS
407 // (i.e. not Linux desktop), and in non-test mode. 423 // (i.e. not Linux desktop), and in non-test mode.
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 // Shutdown the upgrade detector for Chrome OS. The upgrade detector 643 // Shutdown the upgrade detector for Chrome OS. The upgrade detector
628 // stops monitoring changes from the update engine. 644 // stops monitoring changes from the update engine.
629 if (UpgradeDetectorChromeos::GetInstance()) 645 if (UpgradeDetectorChromeos::GetInstance())
630 UpgradeDetectorChromeos::GetInstance()->Shutdown(); 646 UpgradeDetectorChromeos::GetInstance()->Shutdown();
631 647
632 // Shutdown the network change notifier for Chrome OS. The network 648 // Shutdown the network change notifier for Chrome OS. The network
633 // change notifier stops monitoring changes from the power manager and 649 // change notifier stops monitoring changes from the power manager and
634 // the network manager. 650 // the network manager.
635 if (CrosNetworkChangeNotifierFactory::GetInstance()) 651 if (CrosNetworkChangeNotifierFactory::GetInstance())
636 CrosNetworkChangeNotifierFactory::GetInstance()->Shutdown(); 652 CrosNetworkChangeNotifierFactory::GetInstance()->Shutdown();
653 if (NetworkChangeNotifierFactoryChromeos::GetInstance())
654 NetworkChangeNotifierFactoryChromeos::GetInstance()->Shutdown();
637 655
638 if (chromeos::NetworkPortalDetector::IsEnabled() && 656 if (chromeos::NetworkPortalDetector::IsEnabled() &&
639 chromeos::NetworkPortalDetector::GetInstance()) { 657 chromeos::NetworkPortalDetector::GetInstance()) {
640 chromeos::NetworkPortalDetector::GetInstance()->Shutdown(); 658 chromeos::NetworkPortalDetector::GetInstance()->Shutdown();
641 } 659 }
642 660
643 // Tell DeviceSettingsService to stop talking to session_manager. 661 // Tell DeviceSettingsService to stop talking to session_manager.
644 DeviceSettingsService::Get()->Shutdown(); 662 DeviceSettingsService::Get()->Shutdown();
645 663
646 // We should remove observers attached to D-Bus clients before 664 // We should remove observers attached to D-Bus clients before
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 } else if (trial->group() == margin_200mb) { 747 } else if (trial->group() == margin_200mb) {
730 LOG(WARNING) << "low_mem: Part of '200MB' experiment"; 748 LOG(WARNING) << "low_mem: Part of '200MB' experiment";
731 LowMemoryObserver::SetLowMemoryMargin(200); 749 LowMemoryObserver::SetLowMemoryMargin(200);
732 } else { 750 } else {
733 LOG(WARNING) << "low_mem: Part of 'default' experiment"; 751 LOG(WARNING) << "low_mem: Part of 'default' experiment";
734 } 752 }
735 } 753 }
736 } 754 }
737 755
738 } // namespace chromeos 756 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chromeos/chromeos.gyp » ('j') | chromeos/network/network_state.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698