OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_LOCAL_DISCOVERY_WIFI_WIFI_SERVICE_CLIENT_H_ |
| 6 #define CHROME_BROWSER_LOCAL_DISCOVERY_WIFI_WIFI_SERVICE_CLIENT_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/callback.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" |
| 14 #include "chrome/browser/local_discovery/wifi/wifi_client.h" |
| 15 |
| 16 namespace local_discovery { |
| 17 |
| 18 namespace wifi { |
| 19 |
| 20 template <class T> |
| 21 class ThreadSpecificDeleter { |
| 22 public: |
| 23 explicit ThreadSpecificDeleter(base::SequencedTaskRunner* runner) |
| 24 : runner_(runner) {} |
| 25 |
| 26 ThreadSpecificDeleter() {} |
| 27 |
| 28 ~ThreadSpecificDeleter() {} |
| 29 |
| 30 void operator()(T* element) { |
| 31 DCHECK(runner_); |
| 32 runner_->DeleteSoon(FROM_HERE, element); |
| 33 } |
| 34 |
| 35 private: |
| 36 scoped_refptr<base::SequencedTaskRunner> runner_; |
| 37 }; |
| 38 |
| 39 class WifiServiceContainer; |
| 40 |
| 41 class WifiServiceClient : public WifiClient { |
| 42 public: |
| 43 explicit WifiServiceClient(); |
| 44 virtual ~WifiServiceClient(); |
| 45 |
| 46 virtual void Start() OVERRIDE; |
| 47 |
| 48 virtual void GetSSIDList(const SSIDListCallback& callback) OVERRIDE; |
| 49 virtual void RequestScan(const SuccessCallback& callback) OVERRIDE; |
| 50 |
| 51 virtual void ConnectToNetwork(const std::string& ssid, |
| 52 const std::string& internal_id, |
| 53 const std::string& password, |
| 54 const SuccessCallback& callback) OVERRIDE; |
| 55 |
| 56 virtual void ConnectToNetworkByID(const std::string& internal_id, |
| 57 const SuccessCallback& callback) OVERRIDE; |
| 58 |
| 59 virtual void GetNetworkCredentials( |
| 60 const std::string& internal_id, |
| 61 const CredentialsCallback& callback) OVERRIDE; |
| 62 |
| 63 void OnNetworkListChanged(); |
| 64 |
| 65 // Used to ensure closures posted from the wifi threads aren't called after |
| 66 // the service client is deleted. |
| 67 void PostClosure(const base::Closure& callback); |
| 68 |
| 69 private: |
| 70 std::string original_guid_; |
| 71 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 72 scoped_ptr<WifiServiceContainer, ThreadSpecificDeleter<WifiServiceContainer> > |
| 73 wifi_container_; |
| 74 std::vector<SuccessCallback> scan_callbacks_; |
| 75 |
| 76 base::WeakPtrFactory<WifiServiceClient> weak_factory_; |
| 77 }; |
| 78 |
| 79 } // namespace wifi |
| 80 |
| 81 } // namespace local_discovery |
| 82 |
| 83 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_WIFI_WIFI_SERVICE_CLIENT_H_ |
OLD | NEW |