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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 | 330 |
331 void MultiThreadedProxyResolver::Executor::OnJobCompleted(Job* job) { | 331 void MultiThreadedProxyResolver::Executor::OnJobCompleted(Job* job) { |
332 DCHECK_EQ(job, outstanding_job_.get()); | 332 DCHECK_EQ(job, outstanding_job_.get()); |
333 outstanding_job_ = NULL; | 333 outstanding_job_ = NULL; |
334 coordinator_->OnExecutorReady(this); | 334 coordinator_->OnExecutorReady(this); |
335 } | 335 } |
336 | 336 |
337 void MultiThreadedProxyResolver::Executor::Destroy() { | 337 void MultiThreadedProxyResolver::Executor::Destroy() { |
338 DCHECK(coordinator_); | 338 DCHECK(coordinator_); |
339 | 339 |
340 // Give the resolver an opportunity to shutdown from THIS THREAD before | |
341 // joining on the resolver thread. This allows certain implementations | |
342 // to avoid deadlocks. | |
343 resolver_->Shutdown(); | |
344 | |
345 { | 340 { |
346 // See http://crbug.com/69710. | 341 // See http://crbug.com/69710. |
347 base::ThreadRestrictions::ScopedAllowIO allow_io; | 342 base::ThreadRestrictions::ScopedAllowIO allow_io; |
348 | 343 |
349 // Join the worker thread. | 344 // Join the worker thread. |
350 thread_.reset(); | 345 thread_.reset(); |
351 } | 346 } |
352 | 347 |
353 // Cancel any outstanding job. | 348 // Cancel any outstanding job. |
354 if (outstanding_job_) { | 349 if (outstanding_job_) { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 PendingJobsQueue::iterator it = | 450 PendingJobsQueue::iterator it = |
456 std::find(pending_jobs_.begin(), pending_jobs_.end(), job); | 451 std::find(pending_jobs_.begin(), pending_jobs_.end(), job); |
457 DCHECK(it != pending_jobs_.end()); | 452 DCHECK(it != pending_jobs_.end()); |
458 pending_jobs_.erase(it); | 453 pending_jobs_.erase(it); |
459 } | 454 } |
460 } | 455 } |
461 | 456 |
462 LoadState MultiThreadedProxyResolver::GetLoadState(RequestHandle req) const { | 457 LoadState MultiThreadedProxyResolver::GetLoadState(RequestHandle req) const { |
463 DCHECK(CalledOnValidThread()); | 458 DCHECK(CalledOnValidThread()); |
464 DCHECK(req); | 459 DCHECK(req); |
465 | |
466 Job* job = reinterpret_cast<Job*>(req); | |
467 if (job->executor()) | |
468 return job->executor()->resolver()->GetLoadStateThreadSafe(NULL); | |
469 return LOAD_STATE_RESOLVING_PROXY_FOR_URL; | 460 return LOAD_STATE_RESOLVING_PROXY_FOR_URL; |
470 } | 461 } |
471 | 462 |
472 LoadState MultiThreadedProxyResolver::GetLoadStateThreadSafe( | |
473 RequestHandle req) const { | |
474 NOTIMPLEMENTED(); | |
475 return LOAD_STATE_IDLE; | |
476 } | |
477 | |
478 void MultiThreadedProxyResolver::CancelSetPacScript() { | 463 void MultiThreadedProxyResolver::CancelSetPacScript() { |
479 DCHECK(CalledOnValidThread()); | 464 DCHECK(CalledOnValidThread()); |
480 DCHECK_EQ(0u, pending_jobs_.size()); | 465 DCHECK_EQ(0u, pending_jobs_.size()); |
481 DCHECK_EQ(1u, executors_.size()); | 466 DCHECK_EQ(1u, executors_.size()); |
482 DCHECK_EQ(Job::TYPE_SET_PAC_SCRIPT, | 467 DCHECK_EQ(Job::TYPE_SET_PAC_SCRIPT, |
483 executors_[0]->outstanding_job()->type()); | 468 executors_[0]->outstanding_job()->type()); |
484 | 469 |
485 // Defensively clear some data which shouldn't be getting used | 470 // Defensively clear some data which shouldn't be getting used |
486 // anymore. | 471 // anymore. |
487 current_script_data_ = NULL; | 472 current_script_data_ = NULL; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 return; | 565 return; |
581 | 566 |
582 // Get the next job to process (FIFO). Transfer it from the pending queue | 567 // Get the next job to process (FIFO). Transfer it from the pending queue |
583 // to the executor. | 568 // to the executor. |
584 scoped_refptr<Job> job = pending_jobs_.front(); | 569 scoped_refptr<Job> job = pending_jobs_.front(); |
585 pending_jobs_.pop_front(); | 570 pending_jobs_.pop_front(); |
586 executor->StartJob(job); | 571 executor->StartJob(job); |
587 } | 572 } |
588 | 573 |
589 } // namespace net | 574 } // namespace net |
OLD | NEW |