OLD | NEW |
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 #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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 bool connecting() const { return state_ == STATE_ASSOCIATION || | 42 bool connecting() const { return state_ == STATE_ASSOCIATION || |
43 state_ == STATE_CONFIGURATION || state_ == STATE_CARRIER; } | 43 state_ == STATE_CONFIGURATION || state_ == STATE_CARRIER; } |
44 bool configuring() const { return state_ == STATE_CONFIGURATION; } | 44 bool configuring() const { return state_ == STATE_CONFIGURATION; } |
45 bool connected() const { return state_ == STATE_READY; } | 45 bool connected() const { return state_ == STATE_READY; } |
46 bool connecting_or_connected() const { return connecting() || connected(); } | 46 bool connecting_or_connected() const { return connecting() || connected(); } |
47 bool failed() const { return state_ == STATE_FAILURE; } | 47 bool failed() const { return state_ == STATE_FAILURE; } |
48 bool failed_or_disconnected() const { return failed() || | 48 bool failed_or_disconnected() const { return failed() || |
49 state_ == STATE_IDLE; } | 49 state_ == STATE_IDLE; } |
50 ConnectionError error() const { return error_; } | 50 ConnectionError error() const { return error_; } |
51 ConnectionState state() const { return state_; } | 51 ConnectionState state() const { return state_; } |
| 52 // Is this network connectable. Some networks are not yet ready to be |
| 53 // connected. For example, an 8021X network without certificates. |
| 54 bool connectable() const { return connectable_; } |
52 // Is this the active network, i.e, the one through which | 55 // Is this the active network, i.e, the one through which |
53 // network traffic is being routed? A network can be connected, | 56 // network traffic is being routed? A network can be connected, |
54 // but not be carrying traffic. | 57 // but not be carrying traffic. |
55 bool is_active() const { return is_active_; } | 58 bool is_active() const { return is_active_; } |
56 | 59 |
57 // Clear the fields. | 60 // Clear the fields. |
58 virtual void Clear(); | 61 virtual void Clear(); |
59 | 62 |
60 // Return a string representation of the state code. | 63 // Return a string representation of the state code. |
61 std::string GetStateString() const; | 64 std::string GetStateString() const; |
62 | 65 |
63 // Return a string representation of the error code. | 66 // Return a string representation of the error code. |
64 std::string GetErrorString() const; | 67 std::string GetErrorString() const; |
65 | 68 |
66 protected: | 69 protected: |
67 Network() | 70 Network() |
68 : type_(TYPE_UNKNOWN), | 71 : type_(TYPE_UNKNOWN), |
69 state_(STATE_UNKNOWN), | 72 state_(STATE_UNKNOWN), |
70 error_(ERROR_UNKNOWN), | 73 error_(ERROR_UNKNOWN), |
| 74 connectable_(true), |
71 is_active_(false) {} | 75 is_active_(false) {} |
72 explicit Network(const Network& network); | 76 explicit Network(const Network& network); |
73 explicit Network(const ServiceInfo* service); | 77 explicit Network(const ServiceInfo* service); |
74 virtual ~Network() {} | 78 virtual ~Network() {} |
75 | 79 |
76 std::string service_path_; | 80 std::string service_path_; |
77 std::string device_path_; | 81 std::string device_path_; |
78 std::string ip_address_; | 82 std::string ip_address_; |
79 ConnectionType type_; | 83 ConnectionType type_; |
80 ConnectionState state_; | 84 ConnectionState state_; |
81 ConnectionError error_; | 85 ConnectionError error_; |
| 86 bool connectable_; |
82 bool is_active_; | 87 bool is_active_; |
83 | 88 |
84 private: | 89 private: |
85 void set_service_path(const std::string& service_path) { | 90 void set_service_path(const std::string& service_path) { |
86 service_path_ = service_path; } | 91 service_path_ = service_path; } |
87 void set_connecting(bool connecting) { state_ = (connecting ? | 92 void set_connecting(bool connecting) { state_ = (connecting ? |
88 STATE_ASSOCIATION : STATE_IDLE); } | 93 STATE_ASSOCIATION : STATE_IDLE); } |
89 void set_connected(bool connected) { state_ = (connected ? | 94 void set_connected(bool connected) { state_ = (connected ? |
90 STATE_READY : STATE_IDLE); } | 95 STATE_READY : STATE_IDLE); } |
91 void set_state(ConnectionState state) { state_ = state; } | 96 void set_state(ConnectionState state) { state_ = state; } |
| 97 void set_connectable(bool connectable) { connectable_ = connectable; } |
92 void set_active(bool is_active) { is_active_ = is_active; } | 98 void set_active(bool is_active) { is_active_ = is_active; } |
93 | 99 |
94 friend class NetworkLibraryImpl; | 100 friend class NetworkLibraryImpl; |
95 }; | 101 }; |
96 | 102 |
97 class EthernetNetwork : public Network { | 103 class EthernetNetwork : public Network { |
98 public: | 104 public: |
99 EthernetNetwork() : Network() { | 105 EthernetNetwork() : Network() { |
100 type_ = TYPE_ETHERNET; | 106 type_ = TYPE_ETHERNET; |
101 } | 107 } |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 virtual std::string GetHtmlInfo(int refresh) = 0; | 590 virtual std::string GetHtmlInfo(int refresh) = 0; |
585 | 591 |
586 // Factory function, creates a new instance and returns ownership. | 592 // Factory function, creates a new instance and returns ownership. |
587 // For normal usage, access the singleton via CrosLibrary::Get(). | 593 // For normal usage, access the singleton via CrosLibrary::Get(). |
588 static NetworkLibrary* GetImpl(bool stub); | 594 static NetworkLibrary* GetImpl(bool stub); |
589 }; | 595 }; |
590 | 596 |
591 } // namespace chromeos | 597 } // namespace chromeos |
592 | 598 |
593 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ | 599 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ |
OLD | NEW |