Update V8 to version 3.29.50 (based on bleeding_edge revision r23756).
[chromium-blink-merge.git] / content / browser / geolocation / wifi_data_provider.cc
blobcd739e7fb7cb7037df167d1291d9d172bcab0696
1 // Copyright 2013 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.
5 #include "content/browser/geolocation/wifi_data_provider.h"
7 namespace content {
9 WifiDataProvider::WifiDataProvider()
10 : client_loop_(base::MessageLoop::current()) {
11 DCHECK(client_loop_);
14 WifiDataProvider::~WifiDataProvider() {
17 void WifiDataProvider::AddCallback(WifiDataUpdateCallback* callback) {
18 callbacks_.insert(callback);
21 bool WifiDataProvider::RemoveCallback(WifiDataUpdateCallback* callback) {
22 return callbacks_.erase(callback) == 1;
25 bool WifiDataProvider::has_callbacks() const {
26 return !callbacks_.empty();
29 void WifiDataProvider::RunCallbacks() {
30 client_loop_->PostTask(FROM_HERE,
31 base::Bind(&WifiDataProvider::DoRunCallbacks, this));
34 bool WifiDataProvider::CalledOnClientThread() const {
35 return base::MessageLoop::current() == this->client_loop_;
38 base::MessageLoop* WifiDataProvider::client_loop() const {
39 return client_loop_;
42 void WifiDataProvider::DoRunCallbacks() {
43 // It's possible that all the callbacks went away whilst this task was
44 // pending. This is fine; the loop will be a no-op.
45 CallbackSet::const_iterator iter = callbacks_.begin();
46 while (iter != callbacks_.end()) {
47 WifiDataUpdateCallback* callback = *iter;
48 ++iter; // Advance iter before running, in case callback unregisters.
49 callback->Run();
53 } // namespace content