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

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

Issue 2201883003: Geolocation: move mojom from WebKit to device/geolocation/public/interfaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ortuno@s and rockot@s comments, tiny rebase Created 4 years, 4 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
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 has_position_to_report_(false) { 69 has_position_to_report_(false) {
70 DCHECK(context_); 70 DCHECK(context_);
71 binding_.set_connection_error_handler(base::Bind( 71 binding_.set_connection_error_handler(base::Bind(
72 &GeolocationServiceImpl::OnConnectionError, base::Unretained(this))); 72 &GeolocationServiceImpl::OnConnectionError, base::Unretained(this)));
73 } 73 }
74 74
75 GeolocationServiceImpl::~GeolocationServiceImpl() { 75 GeolocationServiceImpl::~GeolocationServiceImpl() {
76 // Make sure to respond to any pending callback even without a valid position. 76 // Make sure to respond to any pending callback even without a valid position.
77 if (!position_callback_.is_null()) { 77 if (!position_callback_.is_null()) {
78 if (!current_position_.valid) { 78 if (!current_position_.valid) {
79 current_position_.error_code = blink::mojom::Geoposition::ErrorCode( 79 current_position_.error_code = mojom::Geoposition::ErrorCode(
80 GEOPOSITION_ERROR_CODE_POSITION_UNAVAILABLE); 80 GEOPOSITION_ERROR_CODE_POSITION_UNAVAILABLE);
81 current_position_.error_message = mojo::String(""); 81 current_position_.error_message = mojo::String("");
82 } 82 }
83 ReportCurrentPosition(); 83 ReportCurrentPosition();
84 } 84 }
85 } 85 }
86 86
87 void GeolocationServiceImpl::PauseUpdates() { 87 void GeolocationServiceImpl::PauseUpdates() {
88 geolocation_subscription_.reset(); 88 geolocation_subscription_.reset();
89 } 89 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 current_position_.valid = position.Validate(); 168 current_position_.valid = position.Validate();
169 current_position_.latitude = position.latitude; 169 current_position_.latitude = position.latitude;
170 current_position_.longitude = position.longitude; 170 current_position_.longitude = position.longitude;
171 current_position_.altitude = position.altitude; 171 current_position_.altitude = position.altitude;
172 current_position_.accuracy = position.accuracy; 172 current_position_.accuracy = position.accuracy;
173 current_position_.altitude_accuracy = position.altitude_accuracy; 173 current_position_.altitude_accuracy = position.altitude_accuracy;
174 current_position_.heading = position.heading; 174 current_position_.heading = position.heading;
175 current_position_.speed = position.speed; 175 current_position_.speed = position.speed;
176 current_position_.timestamp = position.timestamp.ToDoubleT(); 176 current_position_.timestamp = position.timestamp.ToDoubleT();
177 current_position_.error_code = 177 current_position_.error_code =
178 blink::mojom::Geoposition::ErrorCode(position.error_code); 178 mojom::Geoposition::ErrorCode(position.error_code);
179 current_position_.error_message = position.error_message; 179 current_position_.error_message = position.error_message;
180 180
181 has_position_to_report_ = true; 181 has_position_to_report_ = true;
182 182
183 if (!position_callback_.is_null()) 183 if (!position_callback_.is_null())
184 ReportCurrentPosition(); 184 ReportCurrentPosition();
185 } 185 }
186 186
187 void GeolocationServiceImpl::ReportCurrentPosition() { 187 void GeolocationServiceImpl::ReportCurrentPosition() {
188 position_callback_.Run(current_position_.Clone()); 188 position_callback_.Run(current_position_.Clone());
189 position_callback_.Reset(); 189 position_callback_.Reset();
190 has_position_to_report_ = false; 190 has_position_to_report_ = false;
191 } 191 }
192 192
193 } // namespace device 193 } // namespace device
OLDNEW
« no previous file with comments | « device/geolocation/geolocation_service_impl.h ('k') | device/geolocation/public/interfaces/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698