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

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

Issue 6591034: Move core pieces of geolocation from chrome to content.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix Linux build Created 9 years, 9 months 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/geolocation/location_provider.h"
6
7 #include "base/logging.h"
8
9 LocationProviderBase::LocationProviderBase() {
10 }
11
12 LocationProviderBase::~LocationProviderBase() {
13 DCHECK(CalledOnValidThread());
14 }
15
16 void LocationProviderBase::RegisterListener(ListenerInterface* listener) {
17 DCHECK(CalledOnValidThread());
18 DCHECK(listener);
19 std::pair<ListenerMap::iterator, bool> result =
20 listeners_.insert(std::make_pair(listener, 0));
21 DCHECK(result.first != listeners_.end());
22
23 int& ref_count = result.first->second;
24 const bool& is_new = result.second;
25 ++ref_count;
26
27 // Check the post condition...
28 if (is_new) {
29 DCHECK(ref_count == 1);
30 } else {
31 DCHECK(ref_count > 1);
32 }
33 }
34
35 void LocationProviderBase::UnregisterListener(ListenerInterface *listener) {
36 DCHECK(CalledOnValidThread());
37 DCHECK(listener);
38 ListenerMap::iterator iter = listeners_.find(listener);
39 if (iter != listeners_.end()) {
40 if (--iter->second == 0) {
41 listeners_.erase(iter);
42 }
43 }
44 }
45
46 bool LocationProviderBase::has_listeners() const {
47 return !listeners_.empty();
48 }
49
50 void LocationProviderBase::UpdateListeners() {
51 DCHECK(CalledOnValidThread());
52 for (ListenerMap::const_iterator iter = listeners_.begin();
53 iter != listeners_.end();
54 ++iter) {
55 iter->first->LocationUpdateAvailable(this);
56 }
57 }
58
59 #if !defined(OS_LINUX) && !defined(OS_MACOSX) && !defined(OS_WIN)
60 LocationProviderBase* NewSystemLocationProvider() {
61 return NULL;
62 }
63 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698