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

Side by Side Diff: ash/system/chromeos/network/network_state_notifier.h

Issue 22796014: Eliminate c/b/chromeos/options/network_connect.cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + fix clang Created 7 years, 4 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) 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 #ifndef ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_STATE_NOTIFIER_H_ 5 #ifndef ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_STATE_NOTIFIER_H_
6 #define ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_STATE_NOTIFIER_H_ 6 #define ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_STATE_NOTIFIER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "ash/ash_export.h" 10 #include "ash/ash_export.h"
11 #include "ash/system/chromeos/network/network_tray_delegate.h" 11 #include "ash/system/chromeos/network/network_tray_delegate.h"
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h"
14 #include "base/time/time.h" 16 #include "base/time/time.h"
15 #include "chromeos/network/network_state_handler_observer.h" 17 #include "chromeos/network/network_state_handler_observer.h"
16 18
19 namespace base {
20 class DictionaryValue;
21 }
22
17 namespace chromeos { 23 namespace chromeos {
18 class NetworkState; 24 class NetworkState;
19 } 25 }
20 26
21 namespace ash { 27 namespace ash {
22 28
23 // This class has two purposes: 29 // This class has two purposes:
24 // 1. ShowNetworkConnectError() gets called after any user initiated connect 30 // 1. ShowNetworkConnectError() gets called after any user initiated connect
25 // failure. This will handle displaying an error notification. 31 // failure. This will handle displaying an error notification.
26 // NOTE: Because Shill sets the Error property of a Service *after*
27 // the Connect call fails, this class will delay the notification if
28 // necessary until the Error property is set so that the correct
29 // message can be displayed.
30 // TODO(stevenjb): convert this class to use the new MessageCenter 32 // TODO(stevenjb): convert this class to use the new MessageCenter
31 // notification system, generate a notification immediately, and update 33 // notification system.
32 // it when the Error property is set to guarantee that a notification is
33 // displayed for every failure.
34 // 2. It observes NetworkState changes to generate notifications when a 34 // 2. It observes NetworkState changes to generate notifications when a
35 // Cellular network is out of credits. 35 // Cellular network is out of credits.
36 class ASH_EXPORT NetworkStateNotifier : 36 class ASH_EXPORT NetworkStateNotifier :
37 public chromeos::NetworkStateHandlerObserver, 37 public chromeos::NetworkStateHandlerObserver,
38 public NetworkTrayDelegate { 38 public NetworkTrayDelegate {
39 public: 39 public:
40 NetworkStateNotifier(); 40 NetworkStateNotifier();
41 virtual ~NetworkStateNotifier(); 41 virtual ~NetworkStateNotifier();
42 42
43 // NetworkStateHandlerObserver 43 // NetworkStateHandlerObserver
44 virtual void NetworkListChanged() OVERRIDE;
45 virtual void DefaultNetworkChanged( 44 virtual void DefaultNetworkChanged(
46 const chromeos::NetworkState* network) OVERRIDE; 45 const chromeos::NetworkState* network) OVERRIDE;
47 virtual void NetworkPropertiesUpdated( 46 virtual void NetworkPropertiesUpdated(
48 const chromeos::NetworkState* network) OVERRIDE; 47 const chromeos::NetworkState* network) OVERRIDE;
49 48
50 // NetworkTrayDelegate 49 // NetworkTrayDelegate
51 virtual void NotificationLinkClicked( 50 virtual void NotificationLinkClicked(
52 NetworkObserver::MessageType message_type, 51 NetworkObserver::MessageType message_type,
53 size_t link_index) OVERRIDE; 52 size_t link_index) OVERRIDE;
54 53
55 // Show a connection error notification. 54 // Show a connection error notification.
56 void ShowNetworkConnectError(const std::string& error_name, 55 void ShowNetworkConnectError(const std::string& error_name,
pneubeck (no reviews) 2013/08/20 08:32:26 what strings are allowed for |error_name| ?
stevenjb 2013/08/20 20:47:43 Documented.
57 const std::string& service_path); 56 const std::string& service_path);
57 void ConnectErrorPropertiesSucceeded(
pneubeck (no reviews) 2013/08/20 08:32:26 these three should be private?
stevenjb 2013/08/20 20:47:43 Done.
58 const std::string& error_name,
59 const std::string& service_path,
60 const base::DictionaryValue& shill_properties);
61 void ConnectErrorPropertiesFailed(
62 const std::string& error_name,
63 const std::string& service_path,
64 const std::string& shill_error_name,
65 scoped_ptr<base::DictionaryValue> shill_error_data);
66 void ShowConnectErrorNotification(
67 const std::string& error_name,
68 const std::string& service_path,
69 const base::DictionaryValue& shill_properties);
58 70
59 private: 71 private:
60 typedef std::map<std::string, std::string> CachedStateMap; 72 typedef std::map<std::string, std::string> CachedStateMap;
61 73
62 std::string last_active_network_; 74 std::string last_active_network_;
63 std::string cellular_network_; 75 std::string cellular_network_;
64 std::string connect_failed_network_;
65 bool cellular_out_of_credits_; 76 bool cellular_out_of_credits_;
66 base::Time out_of_credits_notify_time_; 77 base::Time out_of_credits_notify_time_;
78 base::WeakPtrFactory<NetworkStateNotifier> weak_ptr_factory_;
67 79
68 DISALLOW_COPY_AND_ASSIGN(NetworkStateNotifier); 80 DISALLOW_COPY_AND_ASSIGN(NetworkStateNotifier);
69 }; 81 };
70 82
71 } // namespace ash 83 } // namespace ash
72 84
73 #endif // ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_STATE_NOTIFIER_H_ 85 #endif // ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_STATE_NOTIFIER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698