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 "content/browser/geolocation/geolocation_provider_impl.h" | 5 #include "content/browser/geolocation/geolocation_provider_impl.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 bool started; | 150 bool started; |
151 provider_->task_runner()->PostTaskAndReply( | 151 provider_->task_runner()->PostTaskAndReply( |
152 FROM_HERE, base::Bind(&GeolocationProviderTest::GetProvidersStarted, | 152 FROM_HERE, base::Bind(&GeolocationProviderTest::GetProvidersStarted, |
153 base::Unretained(this), &started), | 153 base::Unretained(this), &started), |
154 base::MessageLoop::QuitWhenIdleClosure()); | 154 base::MessageLoop::QuitWhenIdleClosure()); |
155 base::RunLoop().Run(); | 155 base::RunLoop().Run(); |
156 return started; | 156 return started; |
157 } | 157 } |
158 | 158 |
159 void GeolocationProviderTest::GetProvidersStarted(bool* started) { | 159 void GeolocationProviderTest::GetProvidersStarted(bool* started) { |
160 DCHECK(base::MessageLoop::current() == provider_->message_loop()); | 160 DCHECK(provider_->task_runner()->BelongsToCurrentThread()); |
161 *started = provider_->mock_arbitrator()->providers_started(); | 161 *started = provider_->mock_arbitrator()->providers_started(); |
162 } | 162 } |
163 | 163 |
164 void GeolocationProviderTest::SendMockLocation(const Geoposition& position) { | 164 void GeolocationProviderTest::SendMockLocation(const Geoposition& position) { |
165 DCHECK(provider_->IsRunning()); | 165 DCHECK(provider_->IsRunning()); |
166 DCHECK(base::MessageLoop::current() == &message_loop_); | 166 DCHECK(base::MessageLoop::current() == &message_loop_); |
167 provider_->task_runner()->PostTask( | 167 provider_->task_runner()->PostTask( |
168 FROM_HERE, base::Bind(&GeolocationProviderImpl::OnLocationUpdate, | 168 FROM_HERE, base::Bind(&GeolocationProviderImpl::OnLocationUpdate, |
169 base::Unretained(provider_.get()), position)); | 169 base::Unretained(provider_.get()), position)); |
170 } | 170 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 &MockGeolocationObserver::OnLocationUpdate, | 253 &MockGeolocationObserver::OnLocationUpdate, |
254 base::Unretained(&mock_observer)); | 254 base::Unretained(&mock_observer)); |
255 std::unique_ptr<content::GeolocationProvider::Subscription> subscription = | 255 std::unique_ptr<content::GeolocationProvider::Subscription> subscription = |
256 provider()->AddLocationUpdateCallback(callback, false); | 256 provider()->AddLocationUpdateCallback(callback, false); |
257 subscription.reset(); | 257 subscription.reset(); |
258 // Wait for the providers to be stopped now that all clients are gone. | 258 // Wait for the providers to be stopped now that all clients are gone. |
259 EXPECT_FALSE(ProvidersStarted()); | 259 EXPECT_FALSE(ProvidersStarted()); |
260 } | 260 } |
261 | 261 |
262 } // namespace content | 262 } // namespace content |
OLD | NEW |