| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 APPS_SHELL_BROWSER_SHELL_NETWORK_CONTROLLER_CHROMEOS_H_ | 5 #ifndef EXTENSIONS_SHELL_BROWSER_SHELL_NETWORK_CONTROLLER_CHROMEOS_H_ |
| 6 #define APPS_SHELL_BROWSER_SHELL_NETWORK_CONTROLLER_CHROMEOS_H_ | 6 #define EXTENSIONS_SHELL_BROWSER_SHELL_NETWORK_CONTROLLER_CHROMEOS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/timer/timer.h" | 14 #include "base/timer/timer.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chromeos/network/network_state_handler_observer.h" | 16 #include "chromeos/network/network_state_handler_observer.h" |
| 17 | 17 |
| 18 namespace apps { | 18 namespace extensions { |
| 19 | 19 |
| 20 // Handles network-related tasks for app_shell on Chrome OS. | 20 // Handles network-related tasks for app_shell on Chrome OS. |
| 21 class ShellNetworkController : public chromeos::NetworkStateHandlerObserver { | 21 class ShellNetworkController : public chromeos::NetworkStateHandlerObserver { |
| 22 public: | 22 public: |
| 23 // This class must be instantiated after chromeos::DBusThreadManager and | 23 // This class must be instantiated after chromeos::DBusThreadManager and |
| 24 // destroyed before it. | 24 // destroyed before it. |
| 25 explicit ShellNetworkController(const std::string& preferred_network_name); | 25 explicit ShellNetworkController(const std::string& preferred_network_name); |
| 26 virtual ~ShellNetworkController(); | 26 virtual ~ShellNetworkController(); |
| 27 | 27 |
| 28 // chromeos::NetworkStateHandlerObserver overrides: | 28 // chromeos::NetworkStateHandlerObserver overrides: |
| (...skipping 23 matching lines...) Expand all Loading... |
| 52 // Asks the connection manager to scan for networks. | 52 // Asks the connection manager to scan for networks. |
| 53 void RequestScan(); | 53 void RequestScan(); |
| 54 | 54 |
| 55 // If not currently connected or connecting, chooses a wireless network and | 55 // If not currently connected or connecting, chooses a wireless network and |
| 56 // asks the connection manager to connect to it. Also switches to | 56 // asks the connection manager to connect to it. Also switches to |
| 57 // |preferred_network_name_| if possible. | 57 // |preferred_network_name_| if possible. |
| 58 void ConnectIfUnconnected(); | 58 void ConnectIfUnconnected(); |
| 59 | 59 |
| 60 // Handles a successful or failed connection attempt. | 60 // Handles a successful or failed connection attempt. |
| 61 void HandleConnectionSuccess(); | 61 void HandleConnectionSuccess(); |
| 62 void HandleConnectionError( | 62 void HandleConnectionError(const std::string& error_name, |
| 63 const std::string& error_name, | 63 scoped_ptr<base::DictionaryValue> error_data); |
| 64 scoped_ptr<base::DictionaryValue> error_data); | |
| 65 | 64 |
| 66 // Current status of communication with the chromeos::NetworkStateHandler. | 65 // Current status of communication with the chromeos::NetworkStateHandler. |
| 67 // This is tracked to avoid sending duplicate requests before the handler has | 66 // This is tracked to avoid sending duplicate requests before the handler has |
| 68 // acknowledged the initial connection attempt. | 67 // acknowledged the initial connection attempt. |
| 69 State state_; | 68 State state_; |
| 70 | 69 |
| 71 // Invokes RequestScan() periodically. | 70 // Invokes RequestScan() periodically. |
| 72 base::RepeatingTimer<ShellNetworkController> scan_timer_; | 71 base::RepeatingTimer<ShellNetworkController> scan_timer_; |
| 73 | 72 |
| 74 // Optionally-supplied name of the preferred network. | 73 // Optionally-supplied name of the preferred network. |
| 75 std::string preferred_network_name_; | 74 std::string preferred_network_name_; |
| 76 | 75 |
| 77 // True if the preferred network is connected or connecting. | 76 // True if the preferred network is connected or connecting. |
| 78 bool preferred_network_is_active_; | 77 bool preferred_network_is_active_; |
| 79 | 78 |
| 80 base::WeakPtrFactory<ShellNetworkController> weak_ptr_factory_; | 79 base::WeakPtrFactory<ShellNetworkController> weak_ptr_factory_; |
| 81 | 80 |
| 82 DISALLOW_COPY_AND_ASSIGN(ShellNetworkController); | 81 DISALLOW_COPY_AND_ASSIGN(ShellNetworkController); |
| 83 }; | 82 }; |
| 84 | 83 |
| 85 } // namespace apps | 84 } // namespace extensions |
| 86 | 85 |
| 87 #endif // APPS_SHELL_BROWSER_SHELL_NETWORK_CONTROLLER_CHROMEOS_H_ | 86 #endif // EXTENSIONS_SHELL_BROWSER_SHELL_NETWORK_CONTROLLER_CHROMEOS_H_ |
| OLD | NEW |