| 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/stringprintf.h" |
| 10 #include "base/thread.h" | 10 #include "base/thread.h" |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 int MultiThreadedProxyResolver::GetProxyForURL(const GURL& url, | 403 int MultiThreadedProxyResolver::GetProxyForURL(const GURL& url, |
| 404 ProxyInfo* results, | 404 ProxyInfo* results, |
| 405 CompletionCallback* callback, | 405 CompletionCallback* callback, |
| 406 RequestHandle* request, | 406 RequestHandle* request, |
| 407 const BoundNetLog& net_log) { | 407 const BoundNetLog& net_log) { |
| 408 DCHECK(CalledOnValidThread()); | 408 DCHECK(CalledOnValidThread()); |
| 409 DCHECK(callback); | 409 DCHECK(callback); |
| 410 DCHECK(current_script_data_.get()) | 410 DCHECK(current_script_data_.get()) |
| 411 << "Resolver is un-initialized. Must call SetPacScript() first!"; | 411 << "Resolver is un-initialized. Must call SetPacScript() first!"; |
| 412 | 412 |
| 413 scoped_refptr<GetProxyForURLJob> job = | 413 scoped_refptr<GetProxyForURLJob> job( |
| 414 new GetProxyForURLJob(url, results, callback, net_log); | 414 new GetProxyForURLJob(url, results, callback, net_log)); |
| 415 | 415 |
| 416 // Completion will be notified through |callback|, unless the caller cancels | 416 // Completion will be notified through |callback|, unless the caller cancels |
| 417 // the request using |request|. | 417 // the request using |request|. |
| 418 if (request) | 418 if (request) |
| 419 *request = reinterpret_cast<RequestHandle>(job.get()); | 419 *request = reinterpret_cast<RequestHandle>(job.get()); |
| 420 | 420 |
| 421 // If there is an executor that is ready to run this request, submit it! | 421 // If there is an executor that is ready to run this request, submit it! |
| 422 Executor* executor = FindIdleExecutor(); | 422 Executor* executor = FindIdleExecutor(); |
| 423 if (executor) { | 423 if (executor) { |
| 424 DCHECK_EQ(0u, pending_jobs_.size()); | 424 DCHECK_EQ(0u, pending_jobs_.size()); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 return; | 567 return; |
| 568 | 568 |
| 569 // 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 |
| 570 // to the executor. | 570 // to the executor. |
| 571 scoped_refptr<Job> job = pending_jobs_.front(); | 571 scoped_refptr<Job> job = pending_jobs_.front(); |
| 572 pending_jobs_.pop_front(); | 572 pending_jobs_.pop_front(); |
| 573 executor->StartJob(job); | 573 executor->StartJob(job); |
| 574 } | 574 } |
| 575 | 575 |
| 576 } // namespace net | 576 } // namespace net |
| OLD | NEW |