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 ~WifiManagerNonChromeos() override
;
27 // WifiManager implementation.
28 void Start() override
;
29 void GetSSIDList(const SSIDListCallback
& callback
) override
;
30 void RequestScan() override
;
31 void ConfigureAndConnectNetwork(const std::string
& ssid
,
32 const WifiCredentials
& credentials
,
33 const SuccessCallback
& callback
) override
;
34 void ConnectToNetworkByID(const std::string
& internal_id
,
35 const SuccessCallback
& callback
) override
;
36 void RequestNetworkCredentials(const std::string
& ssid
,
37 const CredentialsCallback
& callback
) override
;
38 void AddNetworkListObserver(NetworkListObserver
* observer
) override
;
39 void RemoveNetworkListObserver(NetworkListObserver
* observer
) override
;
42 class WifiServiceWrapper
;
44 // Called when the network list changes. Used by WifiServiceWrapper.
45 void OnNetworkListChanged(scoped_ptr
<NetworkPropertiesList
> ssid_list
);
47 // Used to post callbacks that take a const& network list without copying the
48 // vector between threads.
49 void PostSSIDListCallback(const SSIDListCallback
& callback
,
50 scoped_ptr
<NetworkPropertiesList
> ssid_list
);
52 // Used to ensure closures posted from the wifi threads aren't called after
53 // the service client is deleted.
54 void PostClosure(const base::Closure
& callback
);
56 std::string original_guid_
;
57 scoped_refptr
<base::SequencedTaskRunner
> task_runner_
;
58 WifiServiceWrapper
* wifi_wrapper_
; // Owned. Deleted on file thread.
59 base::ObserverList
<NetworkListObserver
> network_list_observers_
;
61 base::WeakPtrFactory
<WifiManagerNonChromeos
> weak_factory_
;
63 DISALLOW_COPY_AND_ASSIGN(WifiManagerNonChromeos
);
68 } // namespace local_discovery
70 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_WIFI_WIFI_MANAGER_NONCHROMEOS_H_