| OLD | NEW |
| 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/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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 virtual void Run(scoped_refptr<base::MessageLoopProxy> origin_loop) OVERRIDE { | 193 virtual void Run(scoped_refptr<base::MessageLoopProxy> origin_loop) OVERRIDE { |
| 194 ProxyResolver* resolver = executor()->resolver(); | 194 ProxyResolver* resolver = executor()->resolver(); |
| 195 int rv = resolver->SetPacScript(script_data_, CompletionCallback()); | 195 int rv = resolver->SetPacScript(script_data_, CompletionCallback()); |
| 196 | 196 |
| 197 DCHECK_NE(rv, ERR_IO_PENDING); | 197 DCHECK_NE(rv, ERR_IO_PENDING); |
| 198 origin_loop->PostTask( | 198 origin_loop->PostTask( |
| 199 FROM_HERE, | 199 FROM_HERE, |
| 200 base::Bind(&SetPacScriptJob::RequestComplete, this, rv)); | 200 base::Bind(&SetPacScriptJob::RequestComplete, this, rv)); |
| 201 } | 201 } |
| 202 | 202 |
| 203 protected: |
| 204 virtual ~SetPacScriptJob() {} |
| 205 |
| 203 private: | 206 private: |
| 204 // Runs the completion callback on the origin thread. | 207 // Runs the completion callback on the origin thread. |
| 205 void RequestComplete(int result_code) { | 208 void RequestComplete(int result_code) { |
| 206 // The task may have been cancelled after it was started. | 209 // The task may have been cancelled after it was started. |
| 207 if (!was_cancelled() && has_user_callback()) { | 210 if (!was_cancelled() && has_user_callback()) { |
| 208 RunUserCallback(result_code); | 211 RunUserCallback(result_code); |
| 209 } | 212 } |
| 210 OnJobCompleted(); | 213 OnJobCompleted(); |
| 211 } | 214 } |
| 212 | 215 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 ProxyResolver* resolver = executor()->resolver(); | 262 ProxyResolver* resolver = executor()->resolver(); |
| 260 int rv = resolver->GetProxyForURL( | 263 int rv = resolver->GetProxyForURL( |
| 261 url_, &results_buf_, CompletionCallback(), NULL, net_log_); | 264 url_, &results_buf_, CompletionCallback(), NULL, net_log_); |
| 262 DCHECK_NE(rv, ERR_IO_PENDING); | 265 DCHECK_NE(rv, ERR_IO_PENDING); |
| 263 | 266 |
| 264 origin_loop->PostTask( | 267 origin_loop->PostTask( |
| 265 FROM_HERE, | 268 FROM_HERE, |
| 266 base::Bind(&GetProxyForURLJob::QueryComplete, this, rv)); | 269 base::Bind(&GetProxyForURLJob::QueryComplete, this, rv)); |
| 267 } | 270 } |
| 268 | 271 |
| 272 protected: |
| 273 virtual ~GetProxyForURLJob() {} |
| 274 |
| 269 private: | 275 private: |
| 270 // Runs the completion callback on the origin thread. | 276 // Runs the completion callback on the origin thread. |
| 271 void QueryComplete(int result_code) { | 277 void QueryComplete(int result_code) { |
| 272 // The Job may have been cancelled after it was started. | 278 // The Job may have been cancelled after it was started. |
| 273 if (!was_cancelled()) { | 279 if (!was_cancelled()) { |
| 274 if (result_code >= OK) { // Note: unit-tests use values > 0. | 280 if (result_code >= OK) { // Note: unit-tests use values > 0. |
| 275 results_->Use(results_buf_); | 281 results_->Use(results_buf_); |
| 276 } | 282 } |
| 277 RunUserCallback(result_code); | 283 RunUserCallback(result_code); |
| 278 } | 284 } |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 return; | 583 return; |
| 578 | 584 |
| 579 // Get the next job to process (FIFO). Transfer it from the pending queue | 585 // Get the next job to process (FIFO). Transfer it from the pending queue |
| 580 // to the executor. | 586 // to the executor. |
| 581 scoped_refptr<Job> job = pending_jobs_.front(); | 587 scoped_refptr<Job> job = pending_jobs_.front(); |
| 582 pending_jobs_.pop_front(); | 588 pending_jobs_.pop_front(); |
| 583 executor->StartJob(job); | 589 executor->StartJob(job); |
| 584 } | 590 } |
| 585 | 591 |
| 586 } // namespace net | 592 } // namespace net |
| OLD | NEW |