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

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

Issue 5750003: Reland r68893 after fixing allowing blocking IO on shutdown. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disable for Windows. Created 10 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
« no previous file with comments | « chrome/browser/browser_process_impl.cc ('k') | chrome/browser/printing/printer_query.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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: This is a bug. The geolocation thread may
52 // transitively (via other threads it joins) block on long-running tasks /
53 // IO.
54 base::ThreadRestrictions::ScopedAllowIO allow_io;
50 Stop(); 55 Stop();
51 } else { 56 } else {
52 if (!IsRunning()) { 57 if (!IsRunning()) {
53 Start(); 58 Start();
54 if (HasPermissionBeenGranted()) 59 if (HasPermissionBeenGranted())
55 InformProvidersPermissionGranted(most_recent_authorized_frame_); 60 InformProvidersPermissionGranted(most_recent_authorized_frame_);
56 } 61 }
57 // The high accuracy requirement may have changed. 62 // The high accuracy requirement may have changed.
58 Task* task = NewRunnableMethod(this, 63 Task* task = NewRunnableMethod(this,
59 &GeolocationProvider::SetObserverOptions, 64 &GeolocationProvider::SetObserverOptions,
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 return most_recent_authorized_frame_.is_valid(); 136 return most_recent_authorized_frame_.is_valid();
132 } 137 }
133 138
134 bool GeolocationProvider::OnClientThread() const { 139 bool GeolocationProvider::OnClientThread() const {
135 return client_loop_->BelongsToCurrentThread(); 140 return client_loop_->BelongsToCurrentThread();
136 } 141 }
137 142
138 bool GeolocationProvider::OnGeolocationThread() const { 143 bool GeolocationProvider::OnGeolocationThread() const {
139 return MessageLoop::current() == message_loop(); 144 return MessageLoop::current() == message_loop();
140 } 145 }
OLDNEW
« no previous file with comments | « chrome/browser/browser_process_impl.cc ('k') | chrome/browser/printing/printer_query.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698