Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 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 <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 292 | 292 |
| 293 // Contains data common to all network service types. | 293 // Contains data common to all network service types. |
| 294 class Network { | 294 class Network { |
| 295 public: | 295 public: |
| 296 virtual ~Network(); | 296 virtual ~Network(); |
| 297 | 297 |
| 298 // Test API for accessing setters in tests. | 298 // Test API for accessing setters in tests. |
| 299 class TestApi { | 299 class TestApi { |
| 300 public: | 300 public: |
| 301 explicit TestApi(Network* network) : network_(network) {} | 301 explicit TestApi(Network* network) : network_(network) {} |
| 302 void SetConnected(bool connected) { | 302 void SetConnected() { |
| 303 network_->set_connected(connected); | 303 network_->set_connected(); |
| 304 } | 304 } |
| 305 void SetConnecting(bool connecting) { | 305 void SetConnecting() { |
| 306 network_->set_connecting(connecting); | 306 network_->set_connecting(); |
| 307 } | |
| 308 void SetDisconnected() { | |
| 309 network_->set_idle(); | |
| 307 } | 310 } |
| 308 private: | 311 private: |
| 309 Network* network_; | 312 Network* network_; |
| 310 }; | 313 }; |
| 311 friend class TestApi; | 314 friend class TestApi; |
| 312 | 315 |
| 313 // Structure used only for parsing ONC's ProxySettings value. | 316 // Structure used only for parsing ONC's ProxySettings value. |
| 314 struct ProxyOncConfig { | 317 struct ProxyOncConfig { |
| 315 ProxyOncConfig() : type(PROXY_ONC_DIRECT) {} | 318 ProxyOncConfig() : type(PROXY_ONC_DIRECT) {} |
| 316 | 319 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 400 // Copy any credentials from a remembered network that are unset in |this|. | 403 // Copy any credentials from a remembered network that are unset in |this|. |
| 401 virtual void CopyCredentialsFromRemembered(Network* remembered); | 404 virtual void CopyCredentialsFromRemembered(Network* remembered); |
| 402 | 405 |
| 403 // Static helper functions. | 406 // Static helper functions. |
| 404 static bool IsConnectedState(ConnectionState state) { | 407 static bool IsConnectedState(ConnectionState state) { |
| 405 return (state == STATE_READY || | 408 return (state == STATE_READY || |
| 406 state == STATE_ONLINE || | 409 state == STATE_ONLINE || |
| 407 state == STATE_PORTAL); | 410 state == STATE_PORTAL); |
| 408 } | 411 } |
| 409 static bool IsConnectingState(ConnectionState state) { | 412 static bool IsConnectingState(ConnectionState state) { |
| 410 return (state == STATE_ASSOCIATION || | 413 return (state == STATE_CONNECT_REQUESTED || |
| 414 state == STATE_ASSOCIATION || | |
| 411 state == STATE_CONFIGURATION || | 415 state == STATE_CONFIGURATION || |
| 412 state == STATE_CARRIER); | 416 state == STATE_CARRIER); |
| 413 } | 417 } |
| 414 static bool IsDisconnectedState(ConnectionState state) { | 418 static bool IsDisconnectedState(ConnectionState state) { |
| 415 return (state == STATE_UNKNOWN || | 419 return (state == STATE_UNKNOWN || |
| 416 state == STATE_IDLE || | 420 state == STATE_IDLE || |
| 417 state == STATE_DISCONNECT || | 421 state == STATE_DISCONNECT || |
| 418 state == STATE_FAILURE || | 422 state == STATE_FAILURE || |
| 419 state == STATE_ACTIVATION_FAILURE); | 423 state == STATE_ACTIVATION_FAILURE); |
| 420 } | 424 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 513 | 517 |
| 514 // Use these functions at your peril. They are used by the various | 518 // Use these functions at your peril. They are used by the various |
| 515 // parsers to set state, and really shouldn't be used by anything else | 519 // parsers to set state, and really shouldn't be used by anything else |
| 516 // because they don't do the error checking and sending to the | 520 // because they don't do the error checking and sending to the |
| 517 // network layer that the other setters do. | 521 // network layer that the other setters do. |
| 518 void set_device_path(const std::string& device_path) { | 522 void set_device_path(const std::string& device_path) { |
| 519 device_path_ = device_path; | 523 device_path_ = device_path; |
| 520 } | 524 } |
| 521 void set_name(const std::string& name) { name_ = name; } | 525 void set_name(const std::string& name) { name_ = name; } |
| 522 void set_mode(ConnectionMode mode) { mode_ = mode; } | 526 void set_mode(ConnectionMode mode) { mode_ = mode; } |
| 523 void set_connecting(bool connecting) { | 527 void set_connecting() { |
| 524 state_ = (connecting ? STATE_ASSOCIATION : STATE_IDLE); | 528 state_ = STATE_CONNECT_REQUESTED; |
| 525 } | 529 } |
| 526 void set_connected(bool connected) { | 530 void set_connected() { |
| 527 state_ = (connected ? STATE_ONLINE : STATE_IDLE); | 531 state_ = STATE_ONLINE; |
| 532 } | |
| 533 void set_idle() { | |
|
Greg Spencer (Chromium)
2012/06/18 17:02:38
Any reason this shouldn't be called "set_disconnec
stevenjb (google-dont-use)
2012/06/18 17:35:31
Done.
The UI doesn't currently care about a "disco
| |
| 534 state_ = STATE_IDLE; | |
| 528 } | 535 } |
| 529 void set_connectable(bool connectable) { connectable_ = connectable; } | 536 void set_connectable(bool connectable) { connectable_ = connectable; } |
| 530 void set_connection_started(bool started) { connection_started_ = started; } | 537 void set_connection_started(bool started) { connection_started_ = started; } |
| 531 void set_is_active(bool is_active) { is_active_ = is_active; } | 538 void set_is_active(bool is_active) { is_active_ = is_active; } |
| 532 void set_error(ConnectionError error) { error_ = error; } | 539 void set_error(ConnectionError error) { error_ = error; } |
| 533 void set_added(bool added) { added_ = added; } | 540 void set_added(bool added) { added_ = added; } |
| 534 void set_auto_connect(bool auto_connect) { auto_connect_ = auto_connect; } | 541 void set_auto_connect(bool auto_connect) { auto_connect_ = auto_connect; } |
| 535 void set_save_credentials(bool save_credentials) { | 542 void set_save_credentials(bool save_credentials) { |
| 536 save_credentials_ = save_credentials; | 543 save_credentials_ = save_credentials; |
| 537 } | 544 } |
| (...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1674 const std::string& service_path) = 0; | 1681 const std::string& service_path) = 0; |
| 1675 | 1682 |
| 1676 // Factory function, creates a new instance and returns ownership. | 1683 // Factory function, creates a new instance and returns ownership. |
| 1677 // For normal usage, access the singleton via CrosLibrary::Get(). | 1684 // For normal usage, access the singleton via CrosLibrary::Get(). |
| 1678 static NetworkLibrary* GetImpl(bool stub); | 1685 static NetworkLibrary* GetImpl(bool stub); |
| 1679 }; | 1686 }; |
| 1680 | 1687 |
| 1681 } // namespace chromeos | 1688 } // namespace chromeos |
| 1682 | 1689 |
| 1683 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ | 1690 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ |
| OLD | NEW |