OLD | NEW |
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 = 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.clear(); |
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 } |
90 | 90 |
91 void GeolocationServiceImpl::ResumeUpdates() { | 91 void GeolocationServiceImpl::ResumeUpdates() { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 ReportCurrentPosition(); | 181 ReportCurrentPosition(); |
182 } | 182 } |
183 | 183 |
184 void GeolocationServiceImpl::ReportCurrentPosition() { | 184 void GeolocationServiceImpl::ReportCurrentPosition() { |
185 position_callback_.Run(current_position_.Clone()); | 185 position_callback_.Run(current_position_.Clone()); |
186 position_callback_.Reset(); | 186 position_callback_.Reset(); |
187 has_position_to_report_ = false; | 187 has_position_to_report_ = false; |
188 } | 188 } |
189 | 189 |
190 } // namespace device | 190 } // namespace device |
OLD | NEW |