Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 suitable for typical linux distributions. | 5 // Provides wifi scan API binding for suitable for typical linux distributions. |
| 6 // Currently, only the NetworkManager API is used, accessed via D-Bus (in turn | 6 // Currently, only the NetworkManager API is used, accessed via D-Bus (in turn |
| 7 // accessed via the GLib wrapper). | 7 // accessed via the GLib wrapper). |
| 8 | 8 |
| 9 #include "content/browser/geolocation/wifi_data_provider_linux.h" | 9 #include "content/browser/geolocation/wifi_data_provider_linux.h" |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 const int kTwoNoChangePollingIntervalMilliseconds = 10 * 60 * 1000; // 10 mins | 25 const int kTwoNoChangePollingIntervalMilliseconds = 10 * 60 * 1000; // 10 mins |
| 26 const int kNoWifiPollingIntervalMilliseconds = 20 * 1000; // 20s | 26 const int kNoWifiPollingIntervalMilliseconds = 20 * 1000; // 20s |
| 27 | 27 |
| 28 const char kNetworkManagerServiceName[] = "org.freedesktop.NetworkManager"; | 28 const char kNetworkManagerServiceName[] = "org.freedesktop.NetworkManager"; |
| 29 const char kNetworkManagerPath[] = "/org/freedesktop/NetworkManager"; | 29 const char kNetworkManagerPath[] = "/org/freedesktop/NetworkManager"; |
| 30 const char kNetworkManagerInterface[] = "org.freedesktop.NetworkManager"; | 30 const char kNetworkManagerInterface[] = "org.freedesktop.NetworkManager"; |
| 31 | 31 |
| 32 // From http://projects.gnome.org/NetworkManager/developers/spec.html | 32 // From http://projects.gnome.org/NetworkManager/developers/spec.html |
| 33 enum { NM_DEVICE_TYPE_WIFI = 2 }; | 33 enum { NM_DEVICE_TYPE_WIFI = 2 }; |
| 34 | 34 |
| 35 #if defined(USE_DBUS) | |
| 35 // Function type matching dbus_g_bus_get_private so that we can | 36 // Function type matching dbus_g_bus_get_private so that we can |
| 36 // dynamically determine the presence of this symbol (see | 37 // dynamically determine the presence of this symbol (see |
| 37 // NetworkManagerWlanApi::Init) | 38 // NetworkManagerWlanApi::Init) |
| 38 typedef DBusGConnection* DBusGBusGetPrivateFunc( | 39 typedef DBusGConnection* DBusGBusGetPrivateFunc( |
| 39 DBusBusType type, GMainContext* context, GError** error); | 40 DBusBusType type, GMainContext* context, GError** error); |
| 40 | 41 |
| 41 // Utility wrappers to make various GLib & DBus structs into scoped objects. | 42 // Utility wrappers to make various GLib & DBus structs into scoped objects. |
| 42 class ScopedGPtrArrayFree { | 43 class ScopedGPtrArrayFree { |
| 43 public: | 44 public: |
| 44 void operator()(GPtrArray* x) const { | 45 void operator()(GPtrArray* x) const { |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 389 G_TYPE_INVALID); | 390 G_TYPE_INVALID); |
| 390 if (CheckError()) | 391 if (CheckError()) |
| 391 return false; | 392 return false; |
| 392 if (!G_VALUE_HOLDS(value_out, expected_gvalue_type)) { | 393 if (!G_VALUE_HOLDS(value_out, expected_gvalue_type)) { |
| 393 DLOG(WARNING) << "Property " << property_name << " unexptected type " | 394 DLOG(WARNING) << "Property " << property_name << " unexptected type " |
| 394 << G_VALUE_TYPE(value_out); | 395 << G_VALUE_TYPE(value_out); |
| 395 return false; | 396 return false; |
| 396 } | 397 } |
| 397 return true; | 398 return true; |
| 398 } | 399 } |
| 400 #endif | |
|
Paweł Hajdan Jr.
2011/03/08 21:13:13
nit: Add // defined(USE_DBUS)
There should be two
| |
| 399 | 401 |
| 400 } // namespace | 402 } // namespace |
| 401 | 403 |
| 402 // static | 404 // static |
| 403 template<> | 405 template<> |
| 404 WifiDataProviderImplBase* WifiDataProvider::DefaultFactoryFunction() { | 406 WifiDataProviderImplBase* WifiDataProvider::DefaultFactoryFunction() { |
| 405 return new WifiDataProviderLinux(); | 407 return new WifiDataProviderLinux(); |
| 406 } | 408 } |
| 407 | 409 |
| 408 WifiDataProviderLinux::WifiDataProviderLinux() { | 410 WifiDataProviderLinux::WifiDataProviderLinux() { |
| 409 } | 411 } |
| 410 | 412 |
| 411 WifiDataProviderLinux::~WifiDataProviderLinux() { | 413 WifiDataProviderLinux::~WifiDataProviderLinux() { |
| 412 } | 414 } |
| 413 | 415 |
| 414 WifiDataProviderCommon::WlanApiInterface* | 416 WifiDataProviderCommon::WlanApiInterface* |
| 415 WifiDataProviderLinux::NewWlanApi() { | 417 WifiDataProviderLinux::NewWlanApi() { |
| 418 #if defined(USE_DBUS) | |
| 416 scoped_ptr<NetworkManagerWlanApi> wlan_api(new NetworkManagerWlanApi); | 419 scoped_ptr<NetworkManagerWlanApi> wlan_api(new NetworkManagerWlanApi); |
| 417 if (wlan_api->Init()) | 420 if (wlan_api->Init()) |
| 418 return wlan_api.release(); | 421 return wlan_api.release(); |
| 422 #endif | |
| 419 return NULL; | 423 return NULL; |
| 420 } | 424 } |
| 421 | 425 |
| 422 PollingPolicyInterface* WifiDataProviderLinux::NewPollingPolicy() { | 426 PollingPolicyInterface* WifiDataProviderLinux::NewPollingPolicy() { |
| 423 return new GenericPollingPolicy<kDefaultPollingIntervalMilliseconds, | 427 return new GenericPollingPolicy<kDefaultPollingIntervalMilliseconds, |
| 424 kNoChangePollingIntervalMilliseconds, | 428 kNoChangePollingIntervalMilliseconds, |
| 425 kTwoNoChangePollingIntervalMilliseconds, | 429 kTwoNoChangePollingIntervalMilliseconds, |
| 426 kNoWifiPollingIntervalMilliseconds>; | 430 kNoWifiPollingIntervalMilliseconds>; |
| 427 } | 431 } |
| OLD | NEW |