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