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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 months 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/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/chromeos/cros/cros_library.h" 9 #include "chrome/browser/chromeos/cros/cros_library.h"
10 #include "chrome/common/chrome_notification_types.h"
10 #include "content/browser/browser_thread.h" 11 #include "content/browser/browser_thread.h"
12 #include "content/common/content_notification_types.h"
11 #include "content/common/notification_service.h" 13 #include "content/common/notification_service.h"
12 #include "content/common/notification_type.h"
13 14
14 namespace chromeos { 15 namespace chromeos {
15 16
16 using base::Time; 17 using base::Time;
17 using base::TimeDelta; 18 using base::TimeDelta;
18 19
19 // static 20 // static
20 NetworkStateNotifier* NetworkStateNotifier::GetInstance() { 21 NetworkStateNotifier* NetworkStateNotifier::GetInstance() {
21 return Singleton<NetworkStateNotifier>::get(); 22 return Singleton<NetworkStateNotifier>::get();
22 } 23 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 NetworkStateDetails::State new_state) { 63 NetworkStateDetails::State new_state) {
63 DVLOG(1) << "UpdateNetworkState: new=" << new_state << ", old=" << state_; 64 DVLOG(1) << "UpdateNetworkState: new=" << new_state << ", old=" << state_;
64 if (state_ == NetworkStateDetails::CONNECTED && 65 if (state_ == NetworkStateDetails::CONNECTED &&
65 new_state != NetworkStateDetails::CONNECTED) { 66 new_state != NetworkStateDetails::CONNECTED) {
66 offline_start_time_ = Time::Now(); 67 offline_start_time_ = Time::Now();
67 } 68 }
68 69
69 state_ = new_state; 70 state_ = new_state;
70 NetworkStateDetails details(state_); 71 NetworkStateDetails details(state_);
71 NotificationService::current()->Notify( 72 NotificationService::current()->Notify(
72 NotificationType::NETWORK_STATE_CHANGED, 73 chrome::NOTIFICATION_NETWORK_STATE_CHANGED,
73 NotificationService::AllSources(), 74 NotificationService::AllSources(),
74 Details<NetworkStateDetails>(&details)); 75 Details<NetworkStateDetails>(&details));
75 }; 76 };
76 77
77 // static 78 // static
78 NetworkStateDetails::State NetworkStateNotifier::RetrieveState() { 79 NetworkStateDetails::State NetworkStateNotifier::RetrieveState() {
79 // Running on desktop means always connected, for now. 80 // Running on desktop means always connected, for now.
80 if (!CrosLibrary::Get()->EnsureLoaded()) 81 if (!CrosLibrary::Get()->EnsureLoaded())
81 return NetworkStateDetails::CONNECTED; 82 return NetworkStateDetails::CONNECTED;
82 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); 83 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary();
83 if (cros->Connected()) { 84 if (cros->Connected()) {
84 return NetworkStateDetails::CONNECTED; 85 return NetworkStateDetails::CONNECTED;
85 } else if (cros->Connecting()) { 86 } else if (cros->Connecting()) {
86 return NetworkStateDetails::CONNECTING; 87 return NetworkStateDetails::CONNECTING;
87 } else { 88 } else {
88 return NetworkStateDetails::DISCONNECTED; 89 return NetworkStateDetails::DISCONNECTED;
89 } 90 }
90 } 91 }
91 92
92 93
93 } // namespace chromeos 94 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/media/media_player.cc ('k') | chrome/browser/chromeos/network_state_notifier_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698