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 EXTENSIONS_SHELL_BROWSER_SHELL_NETWORK_CONTROLLER_CHROMEOS_H_ | 5 #ifndef EXTENSIONS_SHELL_BROWSER_SHELL_NETWORK_CONTROLLER_CHROMEOS_H_ |
6 #define EXTENSIONS_SHELL_BROWSER_SHELL_NETWORK_CONTROLLER_CHROMEOS_H_ | 6 #define EXTENSIONS_SHELL_BROWSER_SHELL_NETWORK_CONTROLLER_CHROMEOS_H_ |
7 | 7 |
| 8 #include <memory> |
8 #include <string> | 9 #include <string> |
9 | 10 |
10 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
11 #include "base/macros.h" | 12 #include "base/macros.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 extensions { | 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: |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 void RequestScan(); | 56 void RequestScan(); |
57 | 57 |
58 // If not currently connected or connecting, chooses a wireless network and | 58 // If not currently connected or connecting, chooses a wireless network and |
59 // asks the connection manager to connect to it. Also switches to | 59 // asks the connection manager to connect to it. Also switches to |
60 // |preferred_network_name_| if possible. | 60 // |preferred_network_name_| if possible. |
61 void ConnectIfUnconnected(); | 61 void ConnectIfUnconnected(); |
62 | 62 |
63 // Handles a successful or failed connection attempt. | 63 // Handles a successful or failed connection attempt. |
64 void HandleConnectionSuccess(); | 64 void HandleConnectionSuccess(); |
65 void HandleConnectionError(const std::string& error_name, | 65 void HandleConnectionError(const std::string& error_name, |
66 scoped_ptr<base::DictionaryValue> error_data); | 66 std::unique_ptr<base::DictionaryValue> error_data); |
67 | 67 |
68 // Current status of communication with the chromeos::NetworkStateHandler. | 68 // Current status of communication with the chromeos::NetworkStateHandler. |
69 // This is tracked to avoid sending duplicate requests before the handler has | 69 // This is tracked to avoid sending duplicate requests before the handler has |
70 // acknowledged the initial connection attempt. | 70 // acknowledged the initial connection attempt. |
71 State state_; | 71 State state_; |
72 | 72 |
73 // Invokes RequestScan() periodically. | 73 // Invokes RequestScan() periodically. |
74 base::RepeatingTimer scan_timer_; | 74 base::RepeatingTimer scan_timer_; |
75 | 75 |
76 // Optionally-supplied name of the preferred network. | 76 // Optionally-supplied name of the preferred network. |
77 std::string preferred_network_name_; | 77 std::string preferred_network_name_; |
78 | 78 |
79 // True if the preferred network is connected or connecting. | 79 // True if the preferred network is connected or connecting. |
80 bool preferred_network_is_active_; | 80 bool preferred_network_is_active_; |
81 | 81 |
82 base::WeakPtrFactory<ShellNetworkController> weak_ptr_factory_; | 82 base::WeakPtrFactory<ShellNetworkController> weak_ptr_factory_; |
83 | 83 |
84 DISALLOW_COPY_AND_ASSIGN(ShellNetworkController); | 84 DISALLOW_COPY_AND_ASSIGN(ShellNetworkController); |
85 }; | 85 }; |
86 | 86 |
87 } // namespace extensions | 87 } // namespace extensions |
88 | 88 |
89 #endif // EXTENSIONS_SHELL_BROWSER_SHELL_NETWORK_CONTROLLER_CHROMEOS_H_ | 89 #endif // EXTENSIONS_SHELL_BROWSER_SHELL_NETWORK_CONTROLLER_CHROMEOS_H_ |
OLD | NEW |