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

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

Issue 6142009: Upating the app, ceee, chrome, ipc, media, and net directories to use the correct lock.h file. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Unified patch updating all references to the new base/synchronization/lock.h Created 9 years, 11 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
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 #include "chrome/browser/geolocation/gateway_data_provider_common.h" 5 #include "chrome/browser/geolocation/gateway_data_provider_common.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 8
9 GatewayDataProviderCommon::GatewayDataProviderCommon() 9 GatewayDataProviderCommon::GatewayDataProviderCommon()
10 : Thread("Geolocation_gateway_provider"), 10 : Thread("Geolocation_gateway_provider"),
(...skipping 14 matching lines...) Expand all
25 } 25 }
26 26
27 void GatewayDataProviderCommon::StopDataProvider() { 27 void GatewayDataProviderCommon::StopDataProvider() {
28 DCHECK(CalledOnClientThread()); 28 DCHECK(CalledOnClientThread());
29 Stop(); 29 Stop();
30 } 30 }
31 31
32 bool GatewayDataProviderCommon::GetData(GatewayData *data) { 32 bool GatewayDataProviderCommon::GetData(GatewayData *data) {
33 DCHECK(CalledOnClientThread()); 33 DCHECK(CalledOnClientThread());
34 DCHECK(data); 34 DCHECK(data);
35 AutoLock lock(data_mutex_); 35 base::AutoLock lock(data_mutex_);
36 *data = gateway_data_; 36 *data = gateway_data_;
37 // If we've successfully completed a scan, indicate that we have all of the 37 // If we've successfully completed a scan, indicate that we have all of the
38 // data we can get. 38 // data we can get.
39 return is_first_scan_complete_; 39 return is_first_scan_complete_;
40 } 40 }
41 41
42 // Thread implementation. 42 // Thread implementation.
43 void GatewayDataProviderCommon::Init() { 43 void GatewayDataProviderCommon::Init() {
44 DCHECK(gateway_api_ == NULL); 44 DCHECK(gateway_api_ == NULL);
45 gateway_api_.reset(NewGatewayApi()); 45 gateway_api_.reset(NewGatewayApi());
(...skipping 14 matching lines...) Expand all
60 polling_policy_.reset(); 60 polling_policy_.reset();
61 } 61 }
62 62
63 void GatewayDataProviderCommon::DoRouterScanTask() { 63 void GatewayDataProviderCommon::DoRouterScanTask() {
64 bool update_available = false; 64 bool update_available = false;
65 GatewayData new_data; 65 GatewayData new_data;
66 if (!gateway_api_->GetRouterData(&new_data.router_data)) { 66 if (!gateway_api_->GetRouterData(&new_data.router_data)) {
67 ScheduleNextScan(polling_policy_->NoRouterInterval()); 67 ScheduleNextScan(polling_policy_->NoRouterInterval());
68 } else { 68 } else {
69 { 69 {
70 AutoLock lock(data_mutex_); 70 base::AutoLock lock(data_mutex_);
71 update_available = gateway_data_.DiffersSignificantly(new_data); 71 update_available = gateway_data_.DiffersSignificantly(new_data);
72 gateway_data_ = new_data; 72 gateway_data_ = new_data;
73 } 73 }
74 ScheduleNextScan(polling_policy_->PollingInterval()); 74 ScheduleNextScan(polling_policy_->PollingInterval());
75 } 75 }
76 if (update_available || !is_first_scan_complete_) { 76 if (update_available || !is_first_scan_complete_) {
77 is_first_scan_complete_ = true; 77 is_first_scan_complete_ = true;
78 NotifyListeners(); 78 NotifyListeners();
79 } 79 }
80 } 80 }
81 81
82 void GatewayDataProviderCommon::ScheduleNextScan(int interval) { 82 void GatewayDataProviderCommon::ScheduleNextScan(int interval) {
83 message_loop()->PostDelayedTask( 83 message_loop()->PostDelayedTask(
84 FROM_HERE, task_factory_.NewRunnableMethod( 84 FROM_HERE, task_factory_.NewRunnableMethod(
85 &GatewayDataProviderCommon::DoRouterScanTask), interval); 85 &GatewayDataProviderCommon::DoRouterScanTask), interval);
86 } 86 }
87 87
88 GatewayPollingPolicyInterface* GatewayDataProviderCommon::NewPollingPolicy() { 88 GatewayPollingPolicyInterface* GatewayDataProviderCommon::NewPollingPolicy() {
89 return new GenericGatewayPollingPolicy; 89 return new GenericGatewayPollingPolicy;
90 } 90 }
OLDNEW
« no previous file with comments | « chrome/browser/geolocation/gateway_data_provider_common.h ('k') | chrome/browser/geolocation/wifi_data_provider_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698