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

Side by Side Diff: device/geolocation/geolocation_service_impl.cc

Issue 2697473002: Remove last usage functions from HostContentSettingsMap and clean up prefs (Closed)
Patch Set: fix up unit test Created 3 years, 10 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 | « device/geolocation/geolocation_service_impl.h ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "device/geolocation/geolocation_service_impl.h" 5 #include "device/geolocation/geolocation_service_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 break; 53 break;
54 } 54 }
55 UMA_HISTOGRAM_ENUMERATION("Geolocation.LocationUpdate.ErrorCode", code, 55 UMA_HISTOGRAM_ENUMERATION("Geolocation.LocationUpdate.ErrorCode", code,
56 GEOPOSITION_ERROR_CODE_COUNT); 56 GEOPOSITION_ERROR_CODE_COUNT);
57 } 57 }
58 58
59 } // namespace 59 } // namespace
60 60
61 GeolocationServiceImpl::GeolocationServiceImpl( 61 GeolocationServiceImpl::GeolocationServiceImpl(
62 mojo::InterfaceRequest<GeolocationService> request, 62 mojo::InterfaceRequest<GeolocationService> request,
63 GeolocationServiceContext* context, 63 GeolocationServiceContext* context)
64 const base::Closure& update_callback)
65 : binding_(this, std::move(request)), 64 : binding_(this, std::move(request)),
66 context_(context), 65 context_(context),
67 update_callback_(update_callback),
68 high_accuracy_(false), 66 high_accuracy_(false),
69 has_position_to_report_(false) { 67 has_position_to_report_(false) {
70 DCHECK(context_); 68 DCHECK(context_);
71 binding_.set_connection_error_handler(base::Bind( 69 binding_.set_connection_error_handler(base::Bind(
72 &GeolocationServiceImpl::OnConnectionError, base::Unretained(this))); 70 &GeolocationServiceImpl::OnConnectionError, base::Unretained(this)));
73 } 71 }
74 72
75 GeolocationServiceImpl::~GeolocationServiceImpl() { 73 GeolocationServiceImpl::~GeolocationServiceImpl() {
76 // Make sure to respond to any pending callback even without a valid position. 74 // Make sure to respond to any pending callback even without a valid position.
77 if (!position_callback_.is_null()) { 75 if (!position_callback_.is_null()) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 context_->ServiceHadConnectionError(this); 151 context_->ServiceHadConnectionError(this);
154 152
155 // The above call deleted this instance, so the only safe thing to do is 153 // The above call deleted this instance, so the only safe thing to do is
156 // return. 154 // return.
157 } 155 }
158 156
159 void GeolocationServiceImpl::OnLocationUpdate(const Geoposition& position) { 157 void GeolocationServiceImpl::OnLocationUpdate(const Geoposition& position) {
160 RecordGeopositionErrorCode(position.error_code); 158 RecordGeopositionErrorCode(position.error_code);
161 DCHECK(context_); 159 DCHECK(context_);
162 160
163 update_callback_.Run();
164
165 current_position_.valid = position.Validate(); 161 current_position_.valid = position.Validate();
166 current_position_.latitude = position.latitude; 162 current_position_.latitude = position.latitude;
167 current_position_.longitude = position.longitude; 163 current_position_.longitude = position.longitude;
168 current_position_.altitude = position.altitude; 164 current_position_.altitude = position.altitude;
169 current_position_.accuracy = position.accuracy; 165 current_position_.accuracy = position.accuracy;
170 current_position_.altitude_accuracy = position.altitude_accuracy; 166 current_position_.altitude_accuracy = position.altitude_accuracy;
171 current_position_.heading = position.heading; 167 current_position_.heading = position.heading;
172 current_position_.speed = position.speed; 168 current_position_.speed = position.speed;
173 current_position_.timestamp = position.timestamp.ToDoubleT(); 169 current_position_.timestamp = position.timestamp.ToDoubleT();
174 current_position_.error_code = 170 current_position_.error_code =
175 mojom::Geoposition::ErrorCode(position.error_code); 171 mojom::Geoposition::ErrorCode(position.error_code);
176 current_position_.error_message = position.error_message; 172 current_position_.error_message = position.error_message;
177 173
178 has_position_to_report_ = true; 174 has_position_to_report_ = true;
179 175
180 if (!position_callback_.is_null()) 176 if (!position_callback_.is_null())
181 ReportCurrentPosition(); 177 ReportCurrentPosition();
182 } 178 }
183 179
184 void GeolocationServiceImpl::ReportCurrentPosition() { 180 void GeolocationServiceImpl::ReportCurrentPosition() {
185 position_callback_.Run(current_position_.Clone()); 181 position_callback_.Run(current_position_.Clone());
186 position_callback_.Reset(); 182 position_callback_.Reset();
187 has_position_to_report_ = false; 183 has_position_to_report_ = false;
188 } 184 }
189 185
190 } // namespace device 186 } // namespace device
OLDNEW
« no previous file with comments | « device/geolocation/geolocation_service_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698