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.
5 #ifndef CHROME_BROWSER_LOCAL_DISCOVERY_WIFI_WIFI_MANAGER_NONCHROMEOS_H_
6 #define CHROME_BROWSER_LOCAL_DISCOVERY_WIFI_WIFI_MANAGER_NONCHROMEOS_H_
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"
18 namespace local_discovery
{
22 class WifiManagerNonChromeos
: public WifiManager
{
24 WifiManagerNonChromeos();
25 virtual ~WifiManagerNonChromeos();
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
& ssid
,
39 const CredentialsCallback
& callback
) OVERRIDE
;
40 virtual void AddNetworkListObserver(NetworkListObserver
* observer
) OVERRIDE
;
41 virtual void RemoveNetworkListObserver(
42 NetworkListObserver
* observer
) OVERRIDE
;
45 class WifiServiceWrapper
;
47 // Called when the network list changes. Used by WifiServiceWrapper.
48 void OnNetworkListChanged(scoped_ptr
<NetworkPropertiesList
> ssid_list
);
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
);
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
);
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_
;
64 base::WeakPtrFactory
<WifiManagerNonChromeos
> weak_factory_
;
66 DISALLOW_COPY_AND_ASSIGN(WifiManagerNonChromeos
);
71 } // namespace local_discovery
73 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_WIFI_WIFI_MANAGER_NONCHROMEOS_H_