| OLD | NEW |
| 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 #include "content/browser/geolocation/geolocation_provider_impl.h" | 5 #include "content/browser/geolocation/geolocation_provider_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "content/browser/geolocation/location_arbitrator_impl.h" | 14 #include "content/browser/geolocation/location_arbitrator_impl.h" |
| 15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 16 | 16 |
| 17 namespace content { | 17 namespace content { |
| 18 | 18 |
| 19 GeolocationProvider* GeolocationProvider::GetInstance() { | 19 GeolocationProvider* GeolocationProvider::GetInstance() { |
| 20 return GeolocationProviderImpl::GetInstance(); | 20 return GeolocationProviderImpl::GetInstance(); |
| 21 } | 21 } |
| 22 | 22 |
| 23 scoped_ptr<GeolocationProvider::Subscription> | 23 scoped_ptr<GeolocationProvider::Subscription> |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 } | 114 } |
| 115 // Determine a set of options that satisfies all clients. | 115 // Determine a set of options that satisfies all clients. |
| 116 bool use_high_accuracy = !high_accuracy_callbacks_.empty(); | 116 bool use_high_accuracy = !high_accuracy_callbacks_.empty(); |
| 117 | 117 |
| 118 // Send the current options to the providers as they may have changed. | 118 // Send the current options to the providers as they may have changed. |
| 119 task = base::Bind(&GeolocationProviderImpl::StartProviders, | 119 task = base::Bind(&GeolocationProviderImpl::StartProviders, |
| 120 base::Unretained(this), | 120 base::Unretained(this), |
| 121 use_high_accuracy); | 121 use_high_accuracy); |
| 122 } | 122 } |
| 123 | 123 |
| 124 message_loop()->PostTask(FROM_HERE, task); | 124 task_runner()->PostTask(FROM_HERE, task); |
| 125 } | 125 } |
| 126 | 126 |
| 127 void GeolocationProviderImpl::StopProviders() { | 127 void GeolocationProviderImpl::StopProviders() { |
| 128 DCHECK(OnGeolocationThread()); | 128 DCHECK(OnGeolocationThread()); |
| 129 DCHECK(arbitrator_); | 129 DCHECK(arbitrator_); |
| 130 arbitrator_->StopProviders(); | 130 arbitrator_->StopProviders(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void GeolocationProviderImpl::StartProviders(bool use_high_accuracy) { | 133 void GeolocationProviderImpl::StartProviders(bool use_high_accuracy) { |
| 134 DCHECK(OnGeolocationThread()); | 134 DCHECK(OnGeolocationThread()); |
| 135 DCHECK(arbitrator_); | 135 DCHECK(arbitrator_); |
| 136 arbitrator_->StartProviders(use_high_accuracy); | 136 arbitrator_->StartProviders(use_high_accuracy); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void GeolocationProviderImpl::InformProvidersPermissionGranted() { | 139 void GeolocationProviderImpl::InformProvidersPermissionGranted() { |
| 140 DCHECK(IsRunning()); | 140 DCHECK(IsRunning()); |
| 141 if (!OnGeolocationThread()) { | 141 if (!OnGeolocationThread()) { |
| 142 message_loop()->PostTask( | 142 task_runner()->PostTask( |
| 143 FROM_HERE, | 143 FROM_HERE, |
| 144 base::Bind(&GeolocationProviderImpl::InformProvidersPermissionGranted, | 144 base::Bind(&GeolocationProviderImpl::InformProvidersPermissionGranted, |
| 145 base::Unretained(this))); | 145 base::Unretained(this))); |
| 146 return; | 146 return; |
| 147 } | 147 } |
| 148 DCHECK(OnGeolocationThread()); | 148 DCHECK(OnGeolocationThread()); |
| 149 DCHECK(arbitrator_); | 149 DCHECK(arbitrator_); |
| 150 arbitrator_->OnPermissionGranted(); | 150 arbitrator_->OnPermissionGranted(); |
| 151 } | 151 } |
| 152 | 152 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 171 arbitrator_ = NULL; | 171 arbitrator_ = NULL; |
| 172 } | 172 } |
| 173 | 173 |
| 174 LocationArbitrator* GeolocationProviderImpl::CreateArbitrator() { | 174 LocationArbitrator* GeolocationProviderImpl::CreateArbitrator() { |
| 175 LocationArbitratorImpl::LocationUpdateCallback callback = base::Bind( | 175 LocationArbitratorImpl::LocationUpdateCallback callback = base::Bind( |
| 176 &GeolocationProviderImpl::OnLocationUpdate, base::Unretained(this)); | 176 &GeolocationProviderImpl::OnLocationUpdate, base::Unretained(this)); |
| 177 return new LocationArbitratorImpl(callback); | 177 return new LocationArbitratorImpl(callback); |
| 178 } | 178 } |
| 179 | 179 |
| 180 } // namespace content | 180 } // namespace content |
| OLD | NEW |