| OLD | NEW |
| 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 "net/proxy/multi_threaded_proxy_resolver.h" | 5 #include "net/proxy/multi_threaded_proxy_resolver.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/stringprintf.h" |
| 9 #include "base/thread.h" | 10 #include "base/thread.h" |
| 10 #include "net/base/capturing_net_log.h" | 11 #include "net/base/capturing_net_log.h" |
| 11 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
| 12 #include "net/proxy/proxy_info.h" | 13 #include "net/proxy/proxy_info.h" |
| 13 | 14 |
| 14 // TODO(eroman): Have the MultiThreadedProxyResolver clear its PAC script | 15 // TODO(eroman): Have the MultiThreadedProxyResolver clear its PAC script |
| 15 // data when SetPacScript fails. That will reclaim memory when | 16 // data when SetPacScript fails. That will reclaim memory when |
| 16 // testing bogus scripts. | 17 // testing bogus scripts. |
| 17 | 18 |
| 18 namespace net { | 19 namespace net { |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 int thread_number) | 309 int thread_number) |
| 309 : coordinator_(coordinator), | 310 : coordinator_(coordinator), |
| 310 thread_number_(thread_number), | 311 thread_number_(thread_number), |
| 311 resolver_(resolver) { | 312 resolver_(resolver) { |
| 312 DCHECK(coordinator); | 313 DCHECK(coordinator); |
| 313 DCHECK(resolver); | 314 DCHECK(resolver); |
| 314 // Start up the thread. | 315 // Start up the thread. |
| 315 // Note that it is safe to pass a temporary C-String to Thread(), as it will | 316 // Note that it is safe to pass a temporary C-String to Thread(), as it will |
| 316 // make a copy. | 317 // make a copy. |
| 317 std::string thread_name = | 318 std::string thread_name = |
| 318 StringPrintf("PAC thread #%d", thread_number); | 319 base::StringPrintf("PAC thread #%d", thread_number); |
| 319 thread_.reset(new base::Thread(thread_name.c_str())); | 320 thread_.reset(new base::Thread(thread_name.c_str())); |
| 320 thread_->Start(); | 321 thread_->Start(); |
| 321 } | 322 } |
| 322 | 323 |
| 323 void MultiThreadedProxyResolver::Executor::StartJob(Job* job) { | 324 void MultiThreadedProxyResolver::Executor::StartJob(Job* job) { |
| 324 DCHECK(!outstanding_job_); | 325 DCHECK(!outstanding_job_); |
| 325 outstanding_job_ = job; | 326 outstanding_job_ = job; |
| 326 | 327 |
| 327 // Run the job. Once it has completed (regardless of whether it was | 328 // Run the job. Once it has completed (regardless of whether it was |
| 328 // cancelled), it will invoke OnJobCompleted() on this thread. | 329 // cancelled), it will invoke OnJobCompleted() on this thread. |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 return; | 567 return; |
| 567 | 568 |
| 568 // Get the next job to process (FIFO). Transfer it from the pending queue | 569 // Get the next job to process (FIFO). Transfer it from the pending queue |
| 569 // to the executor. | 570 // to the executor. |
| 570 scoped_refptr<Job> job = pending_jobs_.front(); | 571 scoped_refptr<Job> job = pending_jobs_.front(); |
| 571 pending_jobs_.pop_front(); | 572 pending_jobs_.pop_front(); |
| 572 executor->StartJob(job); | 573 executor->StartJob(job); |
| 573 } | 574 } |
| 574 | 575 |
| 575 } // namespace net | 576 } // namespace net |
| OLD | NEW |