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

Side by Side Diff: net/proxy/polling_proxy_config_service.cc

Issue 8985012: base::Bind: Convert net/proxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "net/proxy/polling_proxy_config_service.h" 5 #include "net/proxy/polling_proxy_config_service.h"
6 6
7 #include "base/bind.h"
7 #include "base/location.h" 8 #include "base/location.h"
8 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
10 #include "base/observer_list.h" 11 #include "base/observer_list.h"
11 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
12 #include "base/threading/worker_pool.h" 13 #include "base/threading/worker_pool.h"
13 #include "net/proxy/proxy_config.h" 14 #include "net/proxy/proxy_config.h"
14 15
15 namespace net { 16 namespace net {
16 17
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // completes. 85 // completes.
85 poll_task_queued_ = true; 86 poll_task_queued_ = true;
86 return; 87 return;
87 } 88 }
88 89
89 last_poll_time_ = base::TimeTicks::Now(); 90 last_poll_time_ = base::TimeTicks::Now();
90 poll_task_outstanding_ = true; 91 poll_task_outstanding_ = true;
91 poll_task_queued_ = false; 92 poll_task_queued_ = false;
92 base::WorkerPool::PostTask( 93 base::WorkerPool::PostTask(
93 FROM_HERE, 94 FROM_HERE,
94 NewRunnableMethod(this, &Core::PollOnWorkerThread, get_config_func_), 95 base::Bind(&Core::PollOnWorkerThread, this, get_config_func_),
95 true); 96 true);
96 } 97 }
97 98
98 private: 99 private:
99 void PollOnWorkerThread(GetConfigFunction func) { 100 void PollOnWorkerThread(GetConfigFunction func) {
100 ProxyConfig config; 101 ProxyConfig config;
101 func(&config); 102 func(&config);
102 103
103 base::AutoLock l(lock_); 104 base::AutoLock l(lock_);
104 if (origin_loop_proxy_) { 105 if (origin_loop_proxy_) {
105 origin_loop_proxy_->PostTask( 106 origin_loop_proxy_->PostTask(
106 FROM_HERE, 107 FROM_HERE,
107 NewRunnableMethod(this, &Core::GetConfigCompleted, config)); 108 base::Bind(&Core::GetConfigCompleted, this, config));
108 } 109 }
109 } 110 }
110 111
111 // Called after the worker thread has finished retrieving a configuration. 112 // Called after the worker thread has finished retrieving a configuration.
112 void GetConfigCompleted(const ProxyConfig& config) { 113 void GetConfigCompleted(const ProxyConfig& config) {
113 DCHECK(poll_task_outstanding_); 114 DCHECK(poll_task_outstanding_);
114 poll_task_outstanding_ = false; 115 poll_task_outstanding_ = false;
115 116
116 if (!origin_loop_proxy_) 117 if (!origin_loop_proxy_)
117 return; // Was orphaned (parent has already been destroyed). 118 return; // Was orphaned (parent has already been destroyed).
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 183
183 PollingProxyConfigService::~PollingProxyConfigService() { 184 PollingProxyConfigService::~PollingProxyConfigService() {
184 core_->Orphan(); 185 core_->Orphan();
185 } 186 }
186 187
187 void PollingProxyConfigService::CheckForChangesNow() { 188 void PollingProxyConfigService::CheckForChangesNow() {
188 core_->CheckForChangesNow(); 189 core_->CheckForChangesNow();
189 } 190 }
190 191
191 } // namespace net 192 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698