Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(291)

Side by Side Diff: net/proxy/multi_threaded_proxy_resolver.cc

Issue 1157163003: Remove ProxyResolver::(Cancel)SetPacScript and LegacyProxyResolverFactory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@v8-proxy-resolver-refactor
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <deque> 7 #include <deque>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 ~MultiThreadedProxyResolver() override; 112 ~MultiThreadedProxyResolver() override;
113 113
114 // ProxyResolver implementation: 114 // ProxyResolver implementation:
115 int GetProxyForURL(const GURL& url, 115 int GetProxyForURL(const GURL& url,
116 ProxyInfo* results, 116 ProxyInfo* results,
117 const CompletionCallback& callback, 117 const CompletionCallback& callback,
118 RequestHandle* request, 118 RequestHandle* request,
119 const BoundNetLog& net_log) override; 119 const BoundNetLog& net_log) override;
120 void CancelRequest(RequestHandle request) override; 120 void CancelRequest(RequestHandle request) override;
121 LoadState GetLoadState(RequestHandle request) const override; 121 LoadState GetLoadState(RequestHandle request) const override;
122 void CancelSetPacScript() override;
123 int SetPacScript(const scoped_refptr<ProxyResolverScriptData>& script_data,
124 const CompletionCallback& callback) override;
125 122
126 private: 123 private:
127 class GetProxyForURLJob; 124 class GetProxyForURLJob;
128 // FIFO queue of pending jobs waiting to be started. 125 // FIFO queue of pending jobs waiting to be started.
129 // TODO(eroman): Make this priority queue. 126 // TODO(eroman): Make this priority queue.
130 typedef std::deque<scoped_refptr<Job>> PendingJobsQueue; 127 typedef std::deque<scoped_refptr<Job>> PendingJobsQueue;
131 typedef std::vector<scoped_refptr<Executor>> ExecutorList; 128 typedef std::vector<scoped_refptr<Executor>> ExecutorList;
132 129
133 // Returns an idle worker thread which is ready to receive GetProxyForURL() 130 // Returns an idle worker thread which is ready to receive GetProxyForURL()
134 // requests. If all threads are occupied, returns NULL. 131 // requests. If all threads are occupied, returns NULL.
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 DCHECK(!outstanding_job_.get()); 414 DCHECK(!outstanding_job_.get());
418 } 415 }
419 416
420 // MultiThreadedProxyResolver -------------------------------------------------- 417 // MultiThreadedProxyResolver --------------------------------------------------
421 418
422 MultiThreadedProxyResolver::MultiThreadedProxyResolver( 419 MultiThreadedProxyResolver::MultiThreadedProxyResolver(
423 scoped_ptr<ProxyResolverFactory> resolver_factory, 420 scoped_ptr<ProxyResolverFactory> resolver_factory,
424 size_t max_num_threads, 421 size_t max_num_threads,
425 const scoped_refptr<ProxyResolverScriptData>& script_data, 422 const scoped_refptr<ProxyResolverScriptData>& script_data,
426 scoped_refptr<Executor> executor) 423 scoped_refptr<Executor> executor)
427 : ProxyResolver(resolver_factory->expects_pac_bytes()), 424 : resolver_factory_(resolver_factory.Pass()),
428 resolver_factory_(resolver_factory.Pass()),
429 max_num_threads_(max_num_threads), 425 max_num_threads_(max_num_threads),
430 script_data_(script_data) { 426 script_data_(script_data) {
431 DCHECK(script_data_); 427 DCHECK(script_data_);
432 executor->set_coordinator(this); 428 executor->set_coordinator(this);
433 executors_.push_back(executor); 429 executors_.push_back(executor);
434 } 430 }
435 431
436 MultiThreadedProxyResolver::~MultiThreadedProxyResolver() { 432 MultiThreadedProxyResolver::~MultiThreadedProxyResolver() {
437 DCHECK(CalledOnValidThread()); 433 DCHECK(CalledOnValidThread());
438 // We will cancel all outstanding requests. 434 // We will cancel all outstanding requests.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 pending_jobs_.erase(it); 493 pending_jobs_.erase(it);
498 } 494 }
499 } 495 }
500 496
501 LoadState MultiThreadedProxyResolver::GetLoadState(RequestHandle req) const { 497 LoadState MultiThreadedProxyResolver::GetLoadState(RequestHandle req) const {
502 DCHECK(CalledOnValidThread()); 498 DCHECK(CalledOnValidThread());
503 DCHECK(req); 499 DCHECK(req);
504 return LOAD_STATE_RESOLVING_PROXY_FOR_URL; 500 return LOAD_STATE_RESOLVING_PROXY_FOR_URL;
505 } 501 }
506 502
507 void MultiThreadedProxyResolver::CancelSetPacScript() {
508 NOTREACHED();
509 }
510
511 int MultiThreadedProxyResolver::SetPacScript(
512 const scoped_refptr<ProxyResolverScriptData>& script_data,
513 const CompletionCallback&callback) {
514 NOTREACHED();
515 return ERR_NOT_IMPLEMENTED;
516 }
517
518 Executor* MultiThreadedProxyResolver::FindIdleExecutor() { 503 Executor* MultiThreadedProxyResolver::FindIdleExecutor() {
519 DCHECK(CalledOnValidThread()); 504 DCHECK(CalledOnValidThread());
520 for (ExecutorList::iterator it = executors_.begin(); 505 for (ExecutorList::iterator it = executors_.begin();
521 it != executors_.end(); ++it) { 506 it != executors_.end(); ++it) {
522 Executor* executor = it->get(); 507 Executor* executor = it->get();
523 if (!executor->outstanding_job()) 508 if (!executor->outstanding_job())
524 return executor; 509 return executor;
525 } 510 }
526 return NULL; 511 return NULL;
527 } 512 }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 return ERR_IO_PENDING; 622 return ERR_IO_PENDING;
638 } 623 }
639 624
640 void MultiThreadedProxyResolverFactory::RemoveJob( 625 void MultiThreadedProxyResolverFactory::RemoveJob(
641 MultiThreadedProxyResolverFactory::Job* job) { 626 MultiThreadedProxyResolverFactory::Job* job) {
642 size_t erased = jobs_.erase(job); 627 size_t erased = jobs_.erase(job);
643 DCHECK_EQ(1u, erased); 628 DCHECK_EQ(1u, erased);
644 } 629 }
645 630
646 } // namespace net 631 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/mojo_proxy_resolver_impl_unittest.cc ('k') | net/proxy/multi_threaded_proxy_resolver_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698