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

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

Issue 2379253002: Remove ContentViewCore::PauseOrResumeGeolocation() (Closed)
Patch Set: comment Created 4 years, 2 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_context.cc ('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.h" 10 #include "base/metrics/histogram.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 context_->ServiceHadConnectionError(this); 153 context_->ServiceHadConnectionError(this);
154 154
155 // The above call deleted this instance, so the only safe thing to do is 155 // The above call deleted this instance, so the only safe thing to do is
156 // return. 156 // return.
157 } 157 }
158 158
159 void GeolocationServiceImpl::OnLocationUpdate(const Geoposition& position) { 159 void GeolocationServiceImpl::OnLocationUpdate(const Geoposition& position) {
160 RecordGeopositionErrorCode(position.error_code); 160 RecordGeopositionErrorCode(position.error_code);
161 DCHECK(context_); 161 DCHECK(context_);
162 162
163 if (context_->paused())
164 return;
165
166 update_callback_.Run(); 163 update_callback_.Run();
167 164
168 current_position_.valid = position.Validate(); 165 current_position_.valid = position.Validate();
169 current_position_.latitude = position.latitude; 166 current_position_.latitude = position.latitude;
170 current_position_.longitude = position.longitude; 167 current_position_.longitude = position.longitude;
171 current_position_.altitude = position.altitude; 168 current_position_.altitude = position.altitude;
172 current_position_.accuracy = position.accuracy; 169 current_position_.accuracy = position.accuracy;
173 current_position_.altitude_accuracy = position.altitude_accuracy; 170 current_position_.altitude_accuracy = position.altitude_accuracy;
174 current_position_.heading = position.heading; 171 current_position_.heading = position.heading;
175 current_position_.speed = position.speed; 172 current_position_.speed = position.speed;
176 current_position_.timestamp = position.timestamp.ToDoubleT(); 173 current_position_.timestamp = position.timestamp.ToDoubleT();
177 current_position_.error_code = 174 current_position_.error_code =
178 mojom::Geoposition::ErrorCode(position.error_code); 175 mojom::Geoposition::ErrorCode(position.error_code);
179 current_position_.error_message = position.error_message; 176 current_position_.error_message = position.error_message;
180 177
181 has_position_to_report_ = true; 178 has_position_to_report_ = true;
182 179
183 if (!position_callback_.is_null()) 180 if (!position_callback_.is_null())
184 ReportCurrentPosition(); 181 ReportCurrentPosition();
185 } 182 }
186 183
187 void GeolocationServiceImpl::ReportCurrentPosition() { 184 void GeolocationServiceImpl::ReportCurrentPosition() {
188 position_callback_.Run(current_position_.Clone()); 185 position_callback_.Run(current_position_.Clone());
189 position_callback_.Reset(); 186 position_callback_.Reset();
190 has_position_to_report_ = false; 187 has_position_to_report_ = false;
191 } 188 }
192 189
193 } // namespace device 190 } // namespace device
OLDNEW
« no previous file with comments | « device/geolocation/geolocation_service_context.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698