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

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

Issue 1604023: Work-around for DBus crash due to timers firing on the wrong thread.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 8 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 | « no previous file | 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 "chrome/browser/geolocation/wifi_data_provider_linux.h" 9 #include "chrome/browser/geolocation/wifi_data_provider_linux.h"
10 10
11 #include <dbus/dbus-glib.h> 11 #include <dbus/dbus-glib.h>
12 #include <dbus/dbus-glib-lowlevel.h>
13 #include <dbus/dbus.h>
12 #include <glib.h> 14 #include <glib.h>
13 15
14 #include "base/scoped_ptr.h" 16 #include "base/scoped_ptr.h"
15 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
16 18
17 namespace { 19 namespace {
18 // The time periods between successive polls of the wifi data. 20 // The time periods between successive polls of the wifi data.
19 const int kDefaultPollingIntervalMilliseconds = 10 * 1000; // 10s 21 const int kDefaultPollingIntervalMilliseconds = 10 * 1000; // 10s
20 const int kNoChangePollingIntervalMilliseconds = 2 * 60 * 1000; // 2 mins 22 const int kNoChangePollingIntervalMilliseconds = 2 * 60 * 1000; // 2 mins
21 const int kTwoNoChangePollingIntervalMilliseconds = 10 * 60 * 1000; // 10 mins 23 const int kTwoNoChangePollingIntervalMilliseconds = 10 * 60 * 1000; // 10 mins
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // We should likely do this higher up too, the docs say it must only be done 152 // We should likely do this higher up too, the docs say it must only be done
151 // once but there's no way to know if it already was or not. 153 // once but there's no way to know if it already was or not.
152 dbus_g_thread_init(); 154 dbus_g_thread_init();
153 155
154 // Get a connection to the session bus. 156 // Get a connection to the session bus.
155 connection_ = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error_); 157 connection_ = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error_);
156 if (CheckError()) 158 if (CheckError())
157 return false; 159 return false;
158 DCHECK(connection_); 160 DCHECK(connection_);
159 161
162 // dbus-glib queues timers that get fired on the default loop, unfortunately
163 // it isn't thread safe in it's handling of these timers. We can't easily
164 // tell it which loop to queue them on instead, but as we only make
165 // blocking sync calls we don't need timers anyway, so disable them.
166 // See http://crbug.com/40803 TODO(joth): This is not an ideal solution, as
167 // we're reconfiguring the process global system bus connection, so could
168 // impact other users of DBus.
169 dbus_bool_t ok = dbus_connection_set_timeout_functions(
170 dbus_g_connection_get_connection(connection_),
171 NULL, NULL, NULL, NULL, NULL);
172 DCHECK(ok);
173
160 proxy_.reset(dbus_g_proxy_new_for_name(connection_, 174 proxy_.reset(dbus_g_proxy_new_for_name(connection_,
161 kNetworkManagerServiceName, 175 kNetworkManagerServiceName,
162 kNetworkManagerPath, 176 kNetworkManagerPath,
163 kNetworkManagerInterface)); 177 kNetworkManagerInterface));
164 DCHECK(proxy_.get()); 178 DCHECK(proxy_.get());
165 179
166 // Validate the proxy object by checking we can enumerate devices. 180 // Validate the proxy object by checking we can enumerate devices.
167 ScopedGPtrArrayPtr device_list(GetAdapterDeviceList()); 181 ScopedGPtrArrayPtr device_list(GetAdapterDeviceList());
168 return !!device_list.get(); 182 return !!device_list.get();
169 } 183 }
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 return wlan_api.release(); 371 return wlan_api.release();
358 return NULL; 372 return NULL;
359 } 373 }
360 374
361 PollingPolicyInterface* WifiDataProviderLinux::NewPollingPolicy() { 375 PollingPolicyInterface* WifiDataProviderLinux::NewPollingPolicy() {
362 return new GenericPollingPolicy<kDefaultPollingIntervalMilliseconds, 376 return new GenericPollingPolicy<kDefaultPollingIntervalMilliseconds,
363 kNoChangePollingIntervalMilliseconds, 377 kNoChangePollingIntervalMilliseconds,
364 kTwoNoChangePollingIntervalMilliseconds>; 378 kTwoNoChangePollingIntervalMilliseconds>;
365 } 379 }
366 380
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698