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

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

Issue 2804042: Incomplete changes to make scoped_ptr_malloc use plain functions. (Closed)
Patch Set: chrome now builds & links Created 10 years, 5 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
« no previous file with comments | « base/scoped_ptr.h ('k') | chrome/browser/gtk/certificate_dialogs.cc » ('j') | 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 "chrome/browser/geolocation/wifi_data_provider_linux.h" 9 #include "chrome/browser/geolocation/wifi_data_provider_linux.h"
10 10
(...skipping 12 matching lines...) Expand all
23 const int kTwoNoChangePollingIntervalMilliseconds = 10 * 60 * 1000; // 10 mins 23 const int kTwoNoChangePollingIntervalMilliseconds = 10 * 60 * 1000; // 10 mins
24 24
25 const char kNetworkManagerServiceName[] = "org.freedesktop.NetworkManager"; 25 const char kNetworkManagerServiceName[] = "org.freedesktop.NetworkManager";
26 const char kNetworkManagerPath[] = "/org/freedesktop/NetworkManager"; 26 const char kNetworkManagerPath[] = "/org/freedesktop/NetworkManager";
27 const char kNetworkManagerInterface[] = "org.freedesktop.NetworkManager"; 27 const char kNetworkManagerInterface[] = "org.freedesktop.NetworkManager";
28 28
29 // From http://projects.gnome.org/NetworkManager/developers/spec.html 29 // From http://projects.gnome.org/NetworkManager/developers/spec.html
30 enum { NM_DEVICE_TYPE_WIFI = 2 }; 30 enum { NM_DEVICE_TYPE_WIFI = 2 };
31 31
32 // Utility wrappers to make various GLib & DBus structs into scoped objects. 32 // Utility wrappers to make various GLib & DBus structs into scoped objects.
33 class ScopedGPtrArrayFree { 33 void ScopedGPtrArrayFree(GPtrArray* x) {
34 public: 34 g_ptr_array_free(x, TRUE);
35 void operator()(GPtrArray* x) const { 35 }
36 if (x)
37 g_ptr_array_free(x, TRUE);
38 }
39 };
40 // Use ScopedGPtrArrayPtr as if it were scoped_ptr<GPtrArray> 36 // Use ScopedGPtrArrayPtr as if it were scoped_ptr<GPtrArray>
41 typedef scoped_ptr_malloc<GPtrArray, ScopedGPtrArrayFree> ScopedGPtrArrayPtr; 37 typedef scoped_ptr_malloc<GPtrArray, ScopedGPtrArrayFree> ScopedGPtrArrayPtr;
42 38
43 class ScopedGObjectFree {
44 public:
45 void operator()(void* x) const {
46 if (x)
47 g_object_unref(x);
48 }
49 };
50 // Use ScopedDBusGProxyPtr as if it were scoped_ptr<DBusGProxy> 39 // Use ScopedDBusGProxyPtr as if it were scoped_ptr<DBusGProxy>
51 typedef scoped_ptr_malloc<DBusGProxy, ScopedGObjectFree> ScopedDBusGProxyPtr; 40 typedef scoped_ptr_malloc<DBusGProxy, FreeFnAdapter<g_object_unref> >
41 ScopedDBusGProxyPtr;
52 42
53 // Use ScopedGValue::v as an instance of GValue with automatic cleanup. 43 // Use ScopedGValue::v as an instance of GValue with automatic cleanup.
54 class ScopedGValue { 44 class ScopedGValue {
55 public: 45 public:
56 ScopedGValue() 46 ScopedGValue()
57 : v(empty_gvalue()) { 47 : v(empty_gvalue()) {
58 } 48 }
59 ~ScopedGValue() { 49 ~ScopedGValue() {
60 g_value_unset(&v); 50 g_value_unset(&v);
61 } 51 }
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 return wlan_api.release(); 357 return wlan_api.release();
368 return NULL; 358 return NULL;
369 } 359 }
370 360
371 PollingPolicyInterface* WifiDataProviderLinux::NewPollingPolicy() { 361 PollingPolicyInterface* WifiDataProviderLinux::NewPollingPolicy() {
372 return new GenericPollingPolicy<kDefaultPollingIntervalMilliseconds, 362 return new GenericPollingPolicy<kDefaultPollingIntervalMilliseconds,
373 kNoChangePollingIntervalMilliseconds, 363 kNoChangePollingIntervalMilliseconds,
374 kTwoNoChangePollingIntervalMilliseconds>; 364 kTwoNoChangePollingIntervalMilliseconds>;
375 } 365 }
376 366
OLDNEW
« no previous file with comments | « base/scoped_ptr.h ('k') | chrome/browser/gtk/certificate_dialogs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698