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

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

Issue 2298013002: Gets rid of LocationProviderBase. (Closed)
Patch Set: Created 4 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // This file implements a fake location provider and the factory functions for 5 // This file implements a fake location provider and the factory functions for
6 // various ways of creating it. 6 // various ways of creating it.
7 // TODO(lethalantidote): Convert location_arbitrator_impl to use actual mock 7 // TODO(lethalantidote): Convert location_arbitrator_impl to use actual mock
8 // instead of FakeLocationProvider. 8 // instead of FakeLocationProvider.
9 9
10 #include "device/geolocation/fake_location_provider.h" 10 #include "device/geolocation/fake_location_provider.h"
(...skipping 11 matching lines...) Expand all
22 FakeLocationProvider::FakeLocationProvider() 22 FakeLocationProvider::FakeLocationProvider()
23 : provider_task_runner_(base::ThreadTaskRunnerHandle::Get()) {} 23 : provider_task_runner_(base::ThreadTaskRunnerHandle::Get()) {}
24 24
25 FakeLocationProvider::~FakeLocationProvider() {} 25 FakeLocationProvider::~FakeLocationProvider() {}
26 26
27 void FakeLocationProvider::HandlePositionChanged(const Geoposition& position) { 27 void FakeLocationProvider::HandlePositionChanged(const Geoposition& position) {
28 if (provider_task_runner_->BelongsToCurrentThread()) { 28 if (provider_task_runner_->BelongsToCurrentThread()) {
29 // The location arbitrator unit tests rely on this method running 29 // The location arbitrator unit tests rely on this method running
30 // synchronously. 30 // synchronously.
31 position_ = position; 31 position_ = position;
32 NotifyCallback(position_); 32 if (!callback_.is_null()) {
Michael van Ouwerkerk 2016/08/31 09:44:37 nit: no need for curly braces for this one-line bo
CJ 2016/08/31 17:22:11 Done.
33 callback_.Run(this, position_);
34 }
33 } else { 35 } else {
34 provider_task_runner_->PostTask( 36 provider_task_runner_->PostTask(
35 FROM_HERE, base::Bind(&FakeLocationProvider::HandlePositionChanged, 37 FROM_HERE, base::Bind(&FakeLocationProvider::HandlePositionChanged,
36 base::Unretained(this), position)); 38 base::Unretained(this), position));
37 } 39 }
38 } 40 }
39 41
42 void FakeLocationProvider::SetUpdateCallback(
43 const LocationProviderUpdateCallback& callback) {
44 callback_ = callback;
45 }
46
40 bool FakeLocationProvider::StartProvider(bool high_accuracy) { 47 bool FakeLocationProvider::StartProvider(bool high_accuracy) {
41 state_ = high_accuracy ? HIGH_ACCURACY : LOW_ACCURACY; 48 state_ = high_accuracy ? HIGH_ACCURACY : LOW_ACCURACY;
42 return true; 49 return true;
43 } 50 }
44 51
45 void FakeLocationProvider::StopProvider() { 52 void FakeLocationProvider::StopProvider() {
46 state_ = STOPPED; 53 state_ = STOPPED;
47 } 54 }
48 55
49 const Geoposition& FakeLocationProvider::GetPosition() { 56 const Geoposition& FakeLocationProvider::GetPosition() {
50 return position_; 57 return position_;
51 } 58 }
52 59
53 void FakeLocationProvider::OnPermissionGranted() { 60 void FakeLocationProvider::OnPermissionGranted() {
54 is_permission_granted_ = true; 61 is_permission_granted_ = true;
55 } 62 }
56 63
57 } // namespace device 64 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698