Home | History | Annotate | Download | only in wifi
      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_MANAGER_NONCHROMEOS_H_
      6 #define CHROME_BROWSER_LOCAL_DISCOVERY_WIFI_WIFI_MANAGER_NONCHROMEOS_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 "base/observer_list.h"
     15 #include "chrome/browser/local_discovery/wifi/wifi_manager.h"
     16 #include "content/public/browser/browser_thread.h"
     17 
     18 namespace local_discovery {
     19 
     20 namespace wifi {
     21 
     22 class WifiManagerNonChromeos : public WifiManager {
     23  public:
     24   WifiManagerNonChromeos();
     25   virtual ~WifiManagerNonChromeos();
     26 
     27   // WifiManager implementation.
     28   virtual void Start() OVERRIDE;
     29   virtual void GetSSIDList(const SSIDListCallback& callback) OVERRIDE;
     30   virtual void RequestScan() OVERRIDE;
     31   virtual void ConfigureAndConnectNetwork(
     32       const std::string& ssid,
     33       const WifiCredentials& credentials,
     34       const SuccessCallback& callback) OVERRIDE;
     35   virtual void ConnectToNetworkByID(const std::string& internal_id,
     36                                     const SuccessCallback& callback) OVERRIDE;
     37   virtual void RequestNetworkCredentials(
     38       const std::string& internal_id,
     39       const CredentialsCallback& callback) OVERRIDE;
     40   virtual void AddNetworkListObserver(NetworkListObserver* observer) OVERRIDE;
     41   virtual void RemoveNetworkListObserver(
     42       NetworkListObserver* observer) OVERRIDE;
     43 
     44  private:
     45   class WifiServiceWrapper;
     46 
     47   // Called when the network list changes. Used by WifiServiceWrapper.
     48   void OnNetworkListChanged(scoped_ptr<NetworkPropertiesList> ssid_list);
     49 
     50   // Used to post callbacks that take a const& network list without copying the
     51   // vector between threads.
     52   void PostSSIDListCallback(const SSIDListCallback& callback,
     53                             scoped_ptr<NetworkPropertiesList> ssid_list);
     54 
     55   // Used to ensure closures posted from the wifi threads aren't called after
     56   // the service client is deleted.
     57   void PostClosure(const base::Closure& callback);
     58 
     59   std::string original_guid_;
     60   scoped_refptr<base::SequencedTaskRunner> task_runner_;
     61   WifiServiceWrapper* wifi_wrapper_;  // Owned. Deleted on file thread.
     62   ObserverList<NetworkListObserver> network_list_observers_;
     63 
     64   base::WeakPtrFactory<WifiManagerNonChromeos> weak_factory_;
     65 
     66   DISALLOW_COPY_AND_ASSIGN(WifiManagerNonChromeos);
     67 };
     68 
     69 }  // namespace wifi
     70 
     71 }  // namespace local_discovery
     72 
     73 #endif  // CHROME_BROWSER_LOCAL_DISCOVERY_WIFI_WIFI_MANAGER_NONCHROMEOS_H_
     74