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

Side by Side Diff: chrome/browser/chromeos/net/network_change_notifier_chromeos.cc

Issue 8423077: chromeos: Split NetworkChangeNotifierChromeos initialization. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix browser_tests Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/net/network_change_notifier_chromeos.h" 5 #include "chrome/browser/chromeos/net/network_change_notifier_chromeos.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "chrome/browser/chromeos/cros/cros_library.h" 8 #include "chrome/browser/chromeos/cros/cros_library.h"
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 10
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 NetworkChangeNotifierChromeos* parent_; 58 NetworkChangeNotifierChromeos* parent_;
59 bool is_online_; 59 bool is_online_;
60 bool should_report_; 60 bool should_report_;
61 }; 61 };
62 62
63 NetworkChangeNotifierChromeos::NetworkChangeNotifierChromeos() 63 NetworkChangeNotifierChromeos::NetworkChangeNotifierChromeos()
64 : has_active_network_(false), 64 : has_active_network_(false),
65 connection_state_(chromeos::STATE_UNKNOWN), 65 connection_state_(chromeos::STATE_UNKNOWN),
66 online_notification_task_(NULL) { 66 online_notification_task_(NULL) {
67 67
68 chromeos::NetworkLibrary* net =
69 chromeos::CrosLibrary::Get()->GetNetworkLibrary();
70 net->AddNetworkManagerObserver(this);
71
72 chromeos::PowerLibrary* power =
73 chromeos::CrosLibrary::Get()->GetPowerLibrary();
74 power->AddObserver(this);
75
76 UpdateNetworkState(net);
77 BrowserThread::PostDelayedTask( 68 BrowserThread::PostDelayedTask(
78 BrowserThread::UI, FROM_HERE, 69 BrowserThread::UI, FROM_HERE,
79 base::Bind( 70 base::Bind(
80 &NetworkChangeNotifierChromeos::UpdateInitialState, this), 71 &NetworkChangeNotifierChromeos::UpdateInitialState, this),
81 kInitialNotificationCheckDelayMS); 72 kInitialNotificationCheckDelayMS);
82 } 73 }
83 74
84 NetworkChangeNotifierChromeos::~NetworkChangeNotifierChromeos() { 75 NetworkChangeNotifierChromeos::~NetworkChangeNotifierChromeos() {
85 if (online_notification_task_) { 76 if (online_notification_task_) {
86 online_notification_task_->Cancel(); 77 online_notification_task_->Cancel();
87 online_notification_task_ = NULL; 78 online_notification_task_ = NULL;
88 } 79 }
89 if (!chromeos::CrosLibrary::Get()) 80 if (!chromeos::CrosLibrary::Get())
90 return; 81 return;
91 chromeos::NetworkLibrary* lib = 82 chromeos::NetworkLibrary* lib =
92 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); 83 chromeos::CrosLibrary::Get()->GetNetworkLibrary();
93 lib->RemoveNetworkManagerObserver(this); 84 lib->RemoveNetworkManagerObserver(this);
94 lib->RemoveObserverForAllNetworks(this); 85 lib->RemoveObserverForAllNetworks(this);
95 86
96 chromeos::PowerLibrary* power = 87 chromeos::PowerLibrary* power =
97 chromeos::CrosLibrary::Get()->GetPowerLibrary(); 88 chromeos::CrosLibrary::Get()->GetPowerLibrary();
98 power->RemoveObserver(this); 89 power->RemoveObserver(this);
99 } 90 }
100 91
92 void NetworkChangeNotifierChromeos::Init(chromeos::NetworkLibrary* cros) {
93 UpdateNetworkState(cros);
94 }
95
101 void NetworkChangeNotifierChromeos::PowerChanged( 96 void NetworkChangeNotifierChromeos::PowerChanged(
102 const PowerSupplyStatus& status) { 97 const PowerSupplyStatus& status) {
103 } 98 }
104 99
105 void NetworkChangeNotifierChromeos::SystemResumed() { 100 void NetworkChangeNotifierChromeos::SystemResumed() {
106 // Force invalidation of various net resources on system resume. 101 // Force invalidation of various net resources on system resume.
107 BrowserThread::PostTask( 102 BrowserThread::PostTask(
108 BrowserThread::IO, FROM_HERE, 103 BrowserThread::IO, FROM_HERE,
109 base::Bind( 104 base::Bind(
110 &NetworkChangeNotifier::NotifyObserversOfIPAddressChange)); 105 &NetworkChangeNotifier::NotifyObserversOfIPAddressChange));
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 } 245 }
251 246
252 // static 247 // static
253 void NetworkChangeNotifierChromeos::UpdateInitialState( 248 void NetworkChangeNotifierChromeos::UpdateInitialState(
254 NetworkChangeNotifierChromeos* self) { 249 NetworkChangeNotifierChromeos* self) {
255 chromeos::NetworkLibrary* net = 250 chromeos::NetworkLibrary* net =
256 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); 251 chromeos::CrosLibrary::Get()->GetNetworkLibrary();
257 self->UpdateNetworkState(net); 252 self->UpdateNetworkState(net);
258 } 253 }
259 254
260 } // namespace net 255 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698