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

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

Issue 4482003: Landing change for ers@chromium.org: http://codereview.chromium.org/4134012/s... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/network_state_notifier.h" 5 #include "chrome/browser/chromeos/network_state_notifier.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "chrome/browser/browser_thread.h" 9 #include "chrome/browser/browser_thread.h"
10 #include "chrome/browser/chromeos/cros/cros_library.h" 10 #include "chrome/browser/chromeos/cros/cros_library.h"
(...skipping 16 matching lines...) Expand all
27 // TODO(oshima): make this instance method so that 27 // TODO(oshima): make this instance method so that
28 // we can mock this for ui_tests. 28 // we can mock this for ui_tests.
29 // http://crbug.com/4825 . 29 // http://crbug.com/4825 .
30 return base::Time::Now() - Get()->offline_start_time_; 30 return base::Time::Now() - Get()->offline_start_time_;
31 } 31 }
32 32
33 NetworkStateNotifier::NetworkStateNotifier() 33 NetworkStateNotifier::NetworkStateNotifier()
34 : ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), 34 : ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)),
35 state_(RetrieveState()), 35 state_(RetrieveState()),
36 offline_start_time_(Time::Now()) { 36 offline_start_time_(Time::Now()) {
37 // Note that this gets added as a NetworkManagerObserver
38 // in browser_init.cc
37 } 39 }
38 40
39 void NetworkStateNotifier::NetworkChanged(NetworkLibrary* cros) { 41 NetworkStateNotifier::~NetworkStateNotifier() {
42 // Let the NetworkManagerObserver leak to avoid a DCHECK
43 // failure in CommandLine::ForCurrentProcess.
44 // if (CrosLibrary::Get()->EnsureLoaded())
45 // CrosLibrary::Get()->GetNetworkLibrary()->
46 // RemoveNetworkManagerObserver(this);
47 }
48
49 void NetworkStateNotifier::OnNetworkManagerChanged(NetworkLibrary* cros) {
40 DCHECK(CrosLibrary::Get()->EnsureLoaded()); 50 DCHECK(CrosLibrary::Get()->EnsureLoaded());
41 BrowserThread::PostTask( 51 BrowserThread::PostTask(
42 BrowserThread::UI, FROM_HERE, 52 BrowserThread::UI, FROM_HERE,
43 task_factory_.NewRunnableMethod( 53 task_factory_.NewRunnableMethod(
44 &NetworkStateNotifier::UpdateNetworkState, 54 &NetworkStateNotifier::UpdateNetworkState,
45 RetrieveState())); 55 RetrieveState()));
46 } 56 }
47 57
48 void NetworkStateNotifier::UpdateNetworkState( 58 void NetworkStateNotifier::UpdateNetworkState(
49 NetworkStateDetails::State new_state) { 59 NetworkStateDetails::State new_state) {
(...skipping 21 matching lines...) Expand all
71 return NetworkStateDetails::CONNECTED; 81 return NetworkStateDetails::CONNECTED;
72 } else if (cros->Connecting()) { 82 } else if (cros->Connecting()) {
73 return NetworkStateDetails::CONNECTING; 83 return NetworkStateDetails::CONNECTING;
74 } else { 84 } else {
75 return NetworkStateDetails::DISCONNECTED; 85 return NetworkStateDetails::DISCONNECTED;
76 } 86 }
77 } 87 }
78 88
79 89
80 } // namespace chromeos 90 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/network_state_notifier.h ('k') | chrome/browser/chromeos/network_state_notifier_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698