Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/geolocation/geolocation_provider.h" | 5 #include "chrome/browser/geolocation/geolocation_provider.h" |
| 6 | 6 |
| 7 #include "base/singleton.h" | 7 #include "base/singleton.h" |
| 8 #include "base/thread_restrictions.h" | |
| 8 #include "chrome/browser/geolocation/location_arbitrator.h" | 9 #include "chrome/browser/geolocation/location_arbitrator.h" |
| 9 | 10 |
| 10 // This class is guaranteed to outlive its internal thread, so ref counting | 11 // This class is guaranteed to outlive its internal thread, so ref counting |
| 11 // is not required. | 12 // is not required. |
| 12 DISABLE_RUNNABLE_METHOD_REFCOUNT(GeolocationProvider); | 13 DISABLE_RUNNABLE_METHOD_REFCOUNT(GeolocationProvider); |
| 13 | 14 |
| 14 GeolocationProvider* GeolocationProvider::GetInstance() { | 15 GeolocationProvider* GeolocationProvider::GetInstance() { |
| 15 return Singleton<GeolocationProvider>::get(); | 16 return Singleton<GeolocationProvider>::get(); |
| 16 } | 17 } |
| 17 | 18 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 40 bool GeolocationProvider::RemoveObserver(GeolocationObserver* observer) { | 41 bool GeolocationProvider::RemoveObserver(GeolocationObserver* observer) { |
| 41 DCHECK(OnClientThread()); | 42 DCHECK(OnClientThread()); |
| 42 size_t remove = observers_.erase(observer); | 43 size_t remove = observers_.erase(observer); |
| 43 OnObserversChanged(); | 44 OnObserversChanged(); |
| 44 return remove > 0; | 45 return remove > 0; |
| 45 } | 46 } |
| 46 | 47 |
| 47 void GeolocationProvider::OnObserversChanged() { | 48 void GeolocationProvider::OnObserversChanged() { |
| 48 DCHECK(OnClientThread()); | 49 DCHECK(OnClientThread()); |
| 49 if (observers_.empty()) { | 50 if (observers_.empty()) { |
| 51 // http://crbug.com/66077 | |
|
Evan Martin
2010/12/10 21:43:04
Can you include a short summary here? (So people
| |
| 52 base::ThreadRestrictions::ScopedAllowIO allow_io; | |
| 50 Stop(); | 53 Stop(); |
| 51 } else { | 54 } else { |
| 52 if (!IsRunning()) { | 55 if (!IsRunning()) { |
| 53 Start(); | 56 Start(); |
| 54 if (HasPermissionBeenGranted()) | 57 if (HasPermissionBeenGranted()) |
| 55 InformProvidersPermissionGranted(most_recent_authorized_frame_); | 58 InformProvidersPermissionGranted(most_recent_authorized_frame_); |
| 56 } | 59 } |
| 57 // The high accuracy requirement may have changed. | 60 // The high accuracy requirement may have changed. |
| 58 Task* task = NewRunnableMethod(this, | 61 Task* task = NewRunnableMethod(this, |
| 59 &GeolocationProvider::SetObserverOptions, | 62 &GeolocationProvider::SetObserverOptions, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 return most_recent_authorized_frame_.is_valid(); | 134 return most_recent_authorized_frame_.is_valid(); |
| 132 } | 135 } |
| 133 | 136 |
| 134 bool GeolocationProvider::OnClientThread() const { | 137 bool GeolocationProvider::OnClientThread() const { |
| 135 return client_loop_->BelongsToCurrentThread(); | 138 return client_loop_->BelongsToCurrentThread(); |
| 136 } | 139 } |
| 137 | 140 |
| 138 bool GeolocationProvider::OnGeolocationThread() const { | 141 bool GeolocationProvider::OnGeolocationThread() const { |
| 139 return MessageLoop::current() == message_loop(); | 142 return MessageLoop::current() == message_loop(); |
| 140 } | 143 } |
| OLD | NEW |