| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Provides wifi scan API binding for chromeos, using proprietary APIs. | 5 // Provides wifi scan API binding for chromeos, using proprietary APIs. |
| 6 | 6 |
| 7 #include "chrome/browser/geolocation/wifi_data_provider_chromeos.h" | 7 #include "chrome/browser/geolocation/wifi_data_provider_chromeos.h" |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/chromeos/cros/cros_library.h" | 11 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 12 #include "chrome/browser/chromeos/cros/network_library.h" | 12 #include "chrome/browser/chromeos/cros/network_library.h" |
| 13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 14 | 14 |
| 15 using content::BrowserThread; | 15 using content::BrowserThread; |
| 16 | 16 |
| 17 namespace chromeos { |
| 17 namespace { | 18 namespace { |
| 18 // The time periods between successive polls of the wifi data. | 19 // The time periods between successive polls of the wifi data. |
| 19 const int kDefaultPollingIntervalMilliseconds = 10 * 1000; // 10s | 20 const int kDefaultPollingIntervalMilliseconds = 10 * 1000; // 10s |
| 20 const int kNoChangePollingIntervalMilliseconds = 2 * 60 * 1000; // 2 mins | 21 const int kNoChangePollingIntervalMilliseconds = 2 * 60 * 1000; // 2 mins |
| 21 const int kTwoNoChangePollingIntervalMilliseconds = 10 * 60 * 1000; // 10 mins | 22 const int kTwoNoChangePollingIntervalMilliseconds = 10 * 60 * 1000; // 10 mins |
| 22 const int kNoWifiPollingIntervalMilliseconds = 20 * 1000; // 20s | 23 const int kNoWifiPollingIntervalMilliseconds = 20 * 1000; // 20s |
| 23 | 24 |
| 24 WifiDataProviderImplBase* ChromeOSFactoryFunction() { | |
| 25 return new WifiDataProviderChromeOs(); | |
| 26 } | |
| 27 | |
| 28 // This global class forces code that links in this file to use that as a data | |
| 29 // provider instead of the default Linux provider. | |
| 30 class RegisterChromeOSWifiDataProvider { | |
| 31 public: | |
| 32 RegisterChromeOSWifiDataProvider() { | |
| 33 WifiDataProvider::SetFactory(ChromeOSFactoryFunction); | |
| 34 } | |
| 35 }; | |
| 36 | |
| 37 RegisterChromeOSWifiDataProvider g_force_chrome_os_provider; | |
| 38 | |
| 39 } // namespace | |
| 40 | |
| 41 namespace chromeos { | |
| 42 namespace { | |
| 43 // Wifi API binding to network_library.h, to allow reuse of the polling behavior | 25 // Wifi API binding to network_library.h, to allow reuse of the polling behavior |
| 44 // defined in WifiDataProviderCommon. | 26 // defined in WifiDataProviderCommon. |
| 45 class NetworkLibraryWlanApi : public WifiDataProviderCommon::WlanApiInterface { | 27 class NetworkLibraryWlanApi : public WifiDataProviderCommon::WlanApiInterface { |
| 46 public: | 28 public: |
| 47 // Does not transfer ownership, |lib| must remain valid for lifetime of | 29 // Does not transfer ownership, |lib| must remain valid for lifetime of |
| 48 // this object. | 30 // this object. |
| 49 explicit NetworkLibraryWlanApi(NetworkLibrary* lib); | 31 explicit NetworkLibraryWlanApi(NetworkLibrary* lib); |
| 50 ~NetworkLibraryWlanApi(); | 32 ~NetworkLibraryWlanApi(); |
| 51 | 33 |
| 52 // WifiDataProviderCommon::WlanApiInterface | 34 // WifiDataProviderCommon::WlanApiInterface |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 DCHECK(CalledOnClientThread()); | 214 DCHECK(CalledOnClientThread()); |
| 233 DCHECK(!started_); | 215 DCHECK(!started_); |
| 234 started_ = true; | 216 started_ = true; |
| 235 // Perform first scan ASAP regardless of the polling policy. If this scan | 217 // Perform first scan ASAP regardless of the polling policy. If this scan |
| 236 // fails we'll retry at a rate in line with the polling policy. | 218 // fails we'll retry at a rate in line with the polling policy. |
| 237 BrowserThread::PostTask( | 219 BrowserThread::PostTask( |
| 238 BrowserThread::UI, | 220 BrowserThread::UI, |
| 239 FROM_HERE, | 221 FROM_HERE, |
| 240 base::Bind(&WifiDataProviderChromeOs::DoStartTaskOnUIThread, this)); | 222 base::Bind(&WifiDataProviderChromeOs::DoStartTaskOnUIThread, this)); |
| 241 } | 223 } |
| 224 |
| 225 WifiDataProviderImplBase* WifiDataProvider::DefaultFactoryFunction() { |
| 226 return new WifiDataProviderChromeOs(); |
| 227 } |
| OLD | NEW |