| OLD | NEW |
| 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 "net/proxy/multi_threaded_proxy_resolver.h" | 5 #include "net/proxy/multi_threaded_proxy_resolver.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop_proxy.h" | 8 #include "base/message_loop_proxy.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 net_log_(net_log), | 232 net_log_(net_log), |
| 233 url_(url), | 233 url_(url), |
| 234 was_waiting_for_thread_(false) { | 234 was_waiting_for_thread_(false) { |
| 235 DCHECK(!callback.is_null()); | 235 DCHECK(!callback.is_null()); |
| 236 } | 236 } |
| 237 | 237 |
| 238 BoundNetLog* net_log() { return &net_log_; } | 238 BoundNetLog* net_log() { return &net_log_; } |
| 239 | 239 |
| 240 virtual void WaitingForThread() OVERRIDE { | 240 virtual void WaitingForThread() OVERRIDE { |
| 241 was_waiting_for_thread_ = true; | 241 was_waiting_for_thread_ = true; |
| 242 net_log_.BeginEvent( | 242 net_log_.BeginEvent(NetLog::TYPE_WAITING_FOR_PROXY_RESOLVER_THREAD); |
| 243 NetLog::TYPE_WAITING_FOR_PROXY_RESOLVER_THREAD, NULL); | |
| 244 } | 243 } |
| 245 | 244 |
| 246 virtual void FinishedWaitingForThread() OVERRIDE { | 245 virtual void FinishedWaitingForThread() OVERRIDE { |
| 247 DCHECK(executor()); | 246 DCHECK(executor()); |
| 248 | 247 |
| 249 if (was_waiting_for_thread_) { | 248 if (was_waiting_for_thread_) { |
| 250 net_log_.EndEvent( | 249 net_log_.EndEvent(NetLog::TYPE_WAITING_FOR_PROXY_RESOLVER_THREAD); |
| 251 NetLog::TYPE_WAITING_FOR_PROXY_RESOLVER_THREAD, NULL); | |
| 252 } | 250 } |
| 253 | 251 |
| 254 net_log_.AddEvent( | 252 net_log_.AddEvent( |
| 255 NetLog::TYPE_SUBMITTED_TO_RESOLVER_THREAD, | 253 NetLog::TYPE_SUBMITTED_TO_RESOLVER_THREAD, |
| 256 make_scoped_refptr(new NetLogIntegerParameter( | 254 NetLog::IntegerCallback("thread_number", executor()->thread_number())); |
| 257 "thread_number", executor()->thread_number()))); | |
| 258 } | 255 } |
| 259 | 256 |
| 260 // Runs on the worker thread. | 257 // Runs on the worker thread. |
| 261 virtual void Run(scoped_refptr<base::MessageLoopProxy> origin_loop) OVERRIDE { | 258 virtual void Run(scoped_refptr<base::MessageLoopProxy> origin_loop) OVERRIDE { |
| 262 ProxyResolver* resolver = executor()->resolver(); | 259 ProxyResolver* resolver = executor()->resolver(); |
| 263 int rv = resolver->GetProxyForURL( | 260 int rv = resolver->GetProxyForURL( |
| 264 url_, &results_buf_, CompletionCallback(), NULL, net_log_); | 261 url_, &results_buf_, CompletionCallback(), NULL, net_log_); |
| 265 DCHECK_NE(rv, ERR_IO_PENDING); | 262 DCHECK_NE(rv, ERR_IO_PENDING); |
| 266 | 263 |
| 267 origin_loop->PostTask( | 264 origin_loop->PostTask( |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 return; | 580 return; |
| 584 | 581 |
| 585 // Get the next job to process (FIFO). Transfer it from the pending queue | 582 // Get the next job to process (FIFO). Transfer it from the pending queue |
| 586 // to the executor. | 583 // to the executor. |
| 587 scoped_refptr<Job> job = pending_jobs_.front(); | 584 scoped_refptr<Job> job = pending_jobs_.front(); |
| 588 pending_jobs_.pop_front(); | 585 pending_jobs_.pop_front(); |
| 589 executor->StartJob(job); | 586 executor->StartJob(job); |
| 590 } | 587 } |
| 591 | 588 |
| 592 } // namespace net | 589 } // namespace net |
| OLD | NEW |