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

Side by Side Diff: chrome/browser/chromeos/cros_network_library.h

Issue 339013: cros: doing dbus stuff on the file thread==disaster. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/cros_network_library.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_
6 #define CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ 6 #define CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/observer_list.h" 11 #include "base/observer_list.h"
12 #include "base/platform_thread.h"
12 #include "base/singleton.h" 13 #include "base/singleton.h"
13 #include "base/string16.h" 14 #include "base/string16.h"
14 #include "third_party/cros/chromeos_network.h" 15 #include "third_party/cros/chromeos_network.h"
15 16
16 struct WifiNetwork { 17 struct WifiNetwork {
17 WifiNetwork() 18 WifiNetwork()
18 : encrypted(false), 19 : encrypted(false),
19 encryption(chromeos::NONE), 20 encryption(chromeos::NONE),
20 strength(0), 21 strength(0),
21 connecting(false), 22 connecting(false),
22 connected(false) {} 23 connected(false),
24 destroyed(false) {}
23 WifiNetwork(const std::string& ssid, bool encrypted, 25 WifiNetwork(const std::string& ssid, bool encrypted,
24 chromeos::EncryptionType encryption, int strength, 26 chromeos::EncryptionType encryption, int strength,
25 bool connecting, bool connected) 27 bool connecting, bool connected)
26 : ssid(ssid), 28 : ssid(ssid),
27 encrypted(encrypted), 29 encrypted(encrypted),
28 encryption(encryption), 30 encryption(encryption),
29 strength(strength), 31 strength(strength),
30 connecting(connecting), 32 connecting(connecting),
31 connected(connected) {} 33 connected(connected),
34 destroyed(false) {}
32 35
33 // WifiNetworks are sorted by ssids. 36 // WifiNetworks are sorted by ssids.
34 bool operator< (const WifiNetwork& other) const { 37 bool operator< (const WifiNetwork& other) const {
35 return ssid < other.ssid; 38 return ssid < other.ssid;
36 } 39 }
37 40
38 std::string ssid; 41 std::string ssid;
39 bool encrypted; 42 bool encrypted;
40 chromeos::EncryptionType encryption; 43 chromeos::EncryptionType encryption;
41 int strength; 44 int strength;
42 bool connecting; 45 bool connecting;
43 bool connected; 46 bool connected;
47 bool destroyed;
44 }; 48 };
45 typedef std::vector<WifiNetwork> WifiNetworkVector; 49 typedef std::vector<WifiNetwork> WifiNetworkVector;
46 50
47 // This class handles the interaction with the ChromeOS network library APIs. 51 // This class handles the interaction with the ChromeOS network library APIs.
48 // Classes can add themselves as observers. Users can get an instance of this 52 // Classes can add themselves as observers. Users can get an instance of this
49 // library class like this: CrosNetworkLibrary::Get() 53 // library class like this: CrosNetworkLibrary::Get()
50 class CrosNetworkLibrary { 54 class CrosNetworkLibrary {
51 public: 55 public:
52 class Observer { 56 class Observer {
53 public: 57 public:
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 const chromeos::ServiceStatus& service_status); 90 const chromeos::ServiceStatus& service_status);
87 91
88 // This parses ServiceStatus and creates a WifiNetworkVector of wifi networks. 92 // This parses ServiceStatus and creates a WifiNetworkVector of wifi networks.
89 // It also sets ethernet_connected depending on if we have ethernet or not. 93 // It also sets ethernet_connected depending on if we have ethernet or not.
90 static void ParseNetworks(const chromeos::ServiceStatus& service_status, 94 static void ParseNetworks(const chromeos::ServiceStatus& service_status,
91 WifiNetworkVector* networks, 95 WifiNetworkVector* networks,
92 bool* ethernet_connected); 96 bool* ethernet_connected);
93 97
94 // This methods loads the initial list of networks on startup and starts the 98 // This methods loads the initial list of networks on startup and starts the
95 // monitoring of network changes. 99 // monitoring of network changes.
96 // It should be called on a background thread. 100 void Init();
97 void InitOnBackgroundThread();
98 101
99 // Update the network with the a list of wifi networks and ethernet status. 102 // Update the network with the a list of wifi networks and ethernet status.
100 // This will notify all the Observers. 103 // This will notify all the Observers.
101 void UpdateNetworkStatus(const WifiNetworkVector& networks, 104 void UpdateNetworkStatus(const WifiNetworkVector& networks,
102 bool ethernet_connected); 105 bool ethernet_connected);
103 106
104 ObserverList<Observer> observers_; 107 ObserverList<Observer> observers_;
105 108
106 // The network status connection for monitoring network status changes. 109 // The network status connection for monitoring network status changes.
107 chromeos::NetworkStatusConnection network_status_connection_; 110 chromeos::NetworkStatusConnection network_status_connection_;
108 111
109 // Whether or not we are connected to the ethernet line. 112 // Whether or not we are connected to the ethernet line.
110 bool ethernet_connected_; 113 bool ethernet_connected_;
111 114
112 // The list of available wifi networks. 115 // The list of available wifi networks.
113 WifiNetworkVector wifi_networks_; 116 WifiNetworkVector wifi_networks_;
114 117
115 // The current connected (or connecting) wifi network. 118 // The current connected (or connecting) wifi network.
116 WifiNetwork wifi_; 119 WifiNetwork wifi_;
117 120
118 DISALLOW_COPY_AND_ASSIGN(CrosNetworkLibrary); 121 DISALLOW_COPY_AND_ASSIGN(CrosNetworkLibrary);
119 }; 122 };
120 123
121 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ 124 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/cros_network_library.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698