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

Side by Side Diff: content/browser/geolocation/geolocation_provider.cc

Issue 11312210: Do not send stale position in GeolocationProvider::AddObserver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add a test. Created 8 years 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 | Annotate | Revision Log
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 #include "content/browser/geolocation/geolocation_provider.h" 5 #include "content/browser/geolocation/geolocation_provider.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"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 bool GeolocationProvider::OnGeolocationThread() const { 97 bool GeolocationProvider::OnGeolocationThread() const {
98 return MessageLoop::current() == message_loop(); 98 return MessageLoop::current() == message_loop();
99 } 99 }
100 100
101 void GeolocationProvider::OnClientsChanged() { 101 void GeolocationProvider::OnClientsChanged() {
102 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 102 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
103 base::Closure task; 103 base::Closure task;
104 if (observers_.empty() && callbacks_.empty()) { 104 if (observers_.empty() && callbacks_.empty()) {
105 DCHECK(IsRunning()); 105 DCHECK(IsRunning());
106 // We have no more observers, so we clear the cached geoposition so that
107 // when the next observer is added we will not provide a stale position.
108 position_ = Geoposition();
106 task = base::Bind(&GeolocationProvider::StopProviders, 109 task = base::Bind(&GeolocationProvider::StopProviders,
107 base::Unretained(this)); 110 base::Unretained(this));
108 } else { 111 } else {
109 if (!IsRunning()) { 112 if (!IsRunning()) {
110 Start(); 113 Start();
111 if (HasPermissionBeenGranted()) 114 if (HasPermissionBeenGranted())
112 InformProvidersPermissionGranted(); 115 InformProvidersPermissionGranted();
113 } 116 }
114 // Determine a set of options that satisfies all clients. 117 // Determine a set of options that satisfies all clients.
115 GeolocationObserverOptions options = 118 GeolocationObserverOptions options =
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 DCHECK(OnGeolocationThread()); 193 DCHECK(OnGeolocationThread());
191 delete arbitrator_; 194 delete arbitrator_;
192 arbitrator_ = NULL; 195 arbitrator_ = NULL;
193 } 196 }
194 197
195 GeolocationArbitrator* GeolocationProvider::CreateArbitrator() { 198 GeolocationArbitrator* GeolocationProvider::CreateArbitrator() {
196 return new GeolocationArbitratorImpl(this); 199 return new GeolocationArbitratorImpl(this);
197 } 200 }
198 201
199 } // namespace content 202 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698