| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_ARC_NET_ARC_NET_HOST_IMPL_H_ | 5 #ifndef COMPONENTS_ARC_NET_ARC_NET_HOST_IMPL_H_ |
| 6 #define COMPONENTS_ARC_NET_ARC_NET_HOST_IMPL_H_ | 6 #define COMPONENTS_ARC_NET_ARC_NET_HOST_IMPL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 73 |
| 74 // Overriden from chromeos::NetworkStateHandlerObserver. | 74 // Overriden from chromeos::NetworkStateHandlerObserver. |
| 75 void ScanCompleted(const chromeos::DeviceState* /*unused*/) override; | 75 void ScanCompleted(const chromeos::DeviceState* /*unused*/) override; |
| 76 void OnShuttingDown() override; | 76 void OnShuttingDown() override; |
| 77 void DefaultNetworkChanged(const chromeos::NetworkState* network) override; | 77 void DefaultNetworkChanged(const chromeos::NetworkState* network) override; |
| 78 void DeviceListChanged() override; | 78 void DeviceListChanged() override; |
| 79 void GetDefaultNetwork(const GetDefaultNetworkCallback& callback) override; | 79 void GetDefaultNetwork(const GetDefaultNetworkCallback& callback) override; |
| 80 | 80 |
| 81 // Overridden from ArcBridgeService::InterfaceObserver<mojom::NetInstance>: | 81 // Overridden from ArcBridgeService::InterfaceObserver<mojom::NetInstance>: |
| 82 void OnInstanceReady() override; | 82 void OnInstanceReady() override; |
| 83 void OnInstanceClosed() override; |
| 83 | 84 |
| 84 private: | 85 private: |
| 85 void DefaultNetworkSuccessCallback(const std::string& service_path, | 86 void DefaultNetworkSuccessCallback(const std::string& service_path, |
| 86 const base::DictionaryValue& dictionary); | 87 const base::DictionaryValue& dictionary); |
| 87 | 88 |
| 88 // Due to a race in Chrome, GetNetworkStateFromGuid() might not know about | 89 // Due to a race in Chrome, GetNetworkStateFromGuid() might not know about |
| 89 // newly created networks, as that function relies on the completion of a | 90 // newly created networks, as that function relies on the completion of a |
| 90 // separate GetProperties shill call that completes asynchronously. So this | 91 // separate GetProperties shill call that completes asynchronously. So this |
| 91 // class keeps a local cache of the path->guid mapping as a fallback. | 92 // class keeps a local cache of the path->guid mapping as a fallback. |
| 92 // This is sufficient to pass CTS but it might not handle multiple | 93 // This is sufficient to pass CTS but it might not handle multiple |
| 93 // successive Create operations (crbug.com/631646). | 94 // successive Create operations (crbug.com/631646). |
| 94 bool GetNetworkPathFromGuid(const std::string& guid, std::string* path); | 95 bool GetNetworkPathFromGuid(const std::string& guid, std::string* path); |
| 95 | 96 |
| 96 void CreateNetworkSuccessCallback( | 97 void CreateNetworkSuccessCallback( |
| 97 const mojom::NetHost::CreateNetworkCallback& mojo_callback, | 98 const mojom::NetHost::CreateNetworkCallback& mojo_callback, |
| 98 const std::string& service_path, | 99 const std::string& service_path, |
| 99 const std::string& guid); | 100 const std::string& guid); |
| 100 | 101 |
| 101 void CreateNetworkFailureCallback( | 102 void CreateNetworkFailureCallback( |
| 102 const mojom::NetHost::CreateNetworkCallback& mojo_callback, | 103 const mojom::NetHost::CreateNetworkCallback& mojo_callback, |
| 103 const std::string& error_name, | 104 const std::string& error_name, |
| 104 std::unique_ptr<base::DictionaryValue> error_data); | 105 std::unique_ptr<base::DictionaryValue> error_data); |
| 105 | 106 |
| 107 // True if the chrome::NetworkStateHandler is currently being observed for |
| 108 // state changes. |
| 109 bool observing_network_state_ = false; |
| 110 |
| 106 std::string cached_service_path_; | 111 std::string cached_service_path_; |
| 107 std::string cached_guid_; | 112 std::string cached_guid_; |
| 108 | 113 |
| 109 base::ThreadChecker thread_checker_; | 114 base::ThreadChecker thread_checker_; |
| 110 mojo::Binding<mojom::NetHost> binding_; | 115 mojo::Binding<mojom::NetHost> binding_; |
| 111 base::WeakPtrFactory<ArcNetHostImpl> weak_factory_; | 116 base::WeakPtrFactory<ArcNetHostImpl> weak_factory_; |
| 112 | 117 |
| 113 DISALLOW_COPY_AND_ASSIGN(ArcNetHostImpl); | 118 DISALLOW_COPY_AND_ASSIGN(ArcNetHostImpl); |
| 114 }; | 119 }; |
| 115 | 120 |
| 116 } // namespace arc | 121 } // namespace arc |
| 117 | 122 |
| 118 #endif // COMPONENTS_ARC_NET_ARC_NET_HOST_IMPL_H_ | 123 #endif // COMPONENTS_ARC_NET_ARC_NET_HOST_IMPL_H_ |
| OLD | NEW |