| Index: chrome/browser/local_discovery/wifi/wifi_service_client.h
|
| diff --git a/chrome/browser/local_discovery/wifi/wifi_service_client.h b/chrome/browser/local_discovery/wifi/wifi_service_client.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..2e4ad0468309f8c4095befd05d1431b480b9fba1
|
| --- /dev/null
|
| +++ b/chrome/browser/local_discovery/wifi/wifi_service_client.h
|
| @@ -0,0 +1,83 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef CHROME_BROWSER_LOCAL_DISCOVERY_WIFI_WIFI_SERVICE_CLIENT_H_
|
| +#define CHROME_BROWSER_LOCAL_DISCOVERY_WIFI_WIFI_SERVICE_CLIENT_H_
|
| +
|
| +#include <string>
|
| +#include <vector>
|
| +
|
| +#include "base/callback.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "chrome/browser/local_discovery/wifi/wifi_client.h"
|
| +
|
| +namespace local_discovery {
|
| +
|
| +namespace wifi {
|
| +
|
| +template <class T>
|
| +class ThreadSpecificDeleter {
|
| + public:
|
| + explicit ThreadSpecificDeleter(base::SequencedTaskRunner* runner)
|
| + : runner_(runner) {}
|
| +
|
| + ThreadSpecificDeleter() {}
|
| +
|
| + ~ThreadSpecificDeleter() {}
|
| +
|
| + void operator()(T* element) {
|
| + DCHECK(runner_);
|
| + runner_->DeleteSoon(FROM_HERE, element);
|
| + }
|
| +
|
| + private:
|
| + scoped_refptr<base::SequencedTaskRunner> runner_;
|
| +};
|
| +
|
| +class WifiServiceContainer;
|
| +
|
| +class WifiServiceClient : public WifiClient {
|
| + public:
|
| + explicit WifiServiceClient();
|
| + virtual ~WifiServiceClient();
|
| +
|
| + virtual void Start() OVERRIDE;
|
| +
|
| + virtual void GetSSIDList(const SSIDListCallback& callback) OVERRIDE;
|
| + virtual void RequestScan(const SuccessCallback& callback) OVERRIDE;
|
| +
|
| + virtual void ConnectToNetwork(const std::string& ssid,
|
| + const std::string& internal_id,
|
| + const std::string& password,
|
| + const SuccessCallback& callback) OVERRIDE;
|
| +
|
| + virtual void ConnectToNetworkByID(const std::string& internal_id,
|
| + const SuccessCallback& callback) OVERRIDE;
|
| +
|
| + virtual void GetNetworkCredentials(
|
| + const std::string& internal_id,
|
| + const CredentialsCallback& callback) OVERRIDE;
|
| +
|
| + void OnNetworkListChanged();
|
| +
|
| + // Used to ensure closures posted from the wifi threads aren't called after
|
| + // the service client is deleted.
|
| + void PostClosure(const base::Closure& callback);
|
| +
|
| + private:
|
| + std::string original_guid_;
|
| + scoped_refptr<base::SequencedTaskRunner> task_runner_;
|
| + scoped_ptr<WifiServiceContainer, ThreadSpecificDeleter<WifiServiceContainer> >
|
| + wifi_container_;
|
| + std::vector<SuccessCallback> scan_callbacks_;
|
| +
|
| + base::WeakPtrFactory<WifiServiceClient> weak_factory_;
|
| +};
|
| +
|
| +} // namespace wifi
|
| +
|
| +} // namespace local_discovery
|
| +
|
| +#endif // CHROME_BROWSER_LOCAL_DISCOVERY_WIFI_WIFI_SERVICE_CLIENT_H_
|
|
|