Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: content/browser/geolocation/wifi_data_provider_linux.cc

Issue 6648002: Make DBUS an optional dependency so Chromium can be built without it.... Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/chrome_browser.gypi ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 // defined(USE_DBUS)
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 }
OLDNEW
« no previous file with comments | « chrome/chrome_browser.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698