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

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

Issue 1439053002: Change ProxyResolver::GetProxyForURL() to take a scoped_ptr<Request>* rather than a RequestHandle* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/proxy_resolver_v8_tracing.h" 5 #include "net/proxy/proxy_resolver_v8_tracing.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 ProxyResolverV8TracingImpl(scoped_ptr<base::Thread> thread, 302 ProxyResolverV8TracingImpl(scoped_ptr<base::Thread> thread,
303 scoped_ptr<ProxyResolverV8> resolver, 303 scoped_ptr<ProxyResolverV8> resolver,
304 scoped_ptr<Job::Params> job_params); 304 scoped_ptr<Job::Params> job_params);
305 305
306 ~ProxyResolverV8TracingImpl() override; 306 ~ProxyResolverV8TracingImpl() override;
307 307
308 // ProxyResolverV8Tracing overrides. 308 // ProxyResolverV8Tracing overrides.
309 void GetProxyForURL(const GURL& url, 309 void GetProxyForURL(const GURL& url,
310 ProxyInfo* results, 310 ProxyInfo* results,
311 const CompletionCallback& callback, 311 const CompletionCallback& callback,
312 ProxyResolver::RequestHandle* request, 312 scoped_ptr<ProxyResolver::Request>* request,
313 scoped_ptr<Bindings> bindings) override; 313 scoped_ptr<Bindings> bindings) override;
314 void CancelRequest(ProxyResolver::RequestHandle request) override; 314
315 LoadState GetLoadState(ProxyResolver::RequestHandle request) const override; 315 class RequestImpl : public ProxyResolverV8Tracing::Request {
316 public:
317 RequestImpl(Job* job);
318 ~RequestImpl() override;
319 LoadState GetLoadState() override;
320
321 private:
322 Job* job_;
323 };
316 324
317 private: 325 private:
318 // The worker thread on which the ProxyResolverV8 will be run. 326 // The worker thread on which the ProxyResolverV8 will be run.
319 scoped_ptr<base::Thread> thread_; 327 scoped_ptr<base::Thread> thread_;
320 scoped_ptr<ProxyResolverV8> v8_resolver_; 328 scoped_ptr<ProxyResolverV8> v8_resolver_;
321 329
322 scoped_ptr<Job::Params> job_params_; 330 scoped_ptr<Job::Params> job_params_;
323 331
324 // The number of outstanding (non-cancelled) jobs. 332 // The number of outstanding (non-cancelled) jobs.
325 int num_outstanding_callbacks_; 333 int num_outstanding_callbacks_;
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 933
926 ProxyResolverV8TracingImpl::~ProxyResolverV8TracingImpl() { 934 ProxyResolverV8TracingImpl::~ProxyResolverV8TracingImpl() {
927 // Note, all requests should have been cancelled. 935 // Note, all requests should have been cancelled.
928 CHECK_EQ(0, num_outstanding_callbacks_); 936 CHECK_EQ(0, num_outstanding_callbacks_);
929 937
930 // Join the worker thread. See http://crbug.com/69710. 938 // Join the worker thread. See http://crbug.com/69710.
931 base::ThreadRestrictions::ScopedAllowIO allow_io; 939 base::ThreadRestrictions::ScopedAllowIO allow_io;
932 thread_.reset(); 940 thread_.reset();
933 } 941 }
934 942
943 ProxyResolverV8TracingImpl::RequestImpl::RequestImpl(Job* job) : job_(job) {}
944
945 ProxyResolverV8TracingImpl::RequestImpl::~RequestImpl() {
946 job_->Cancel();
947 }
948
949 LoadState ProxyResolverV8TracingImpl::RequestImpl::GetLoadState() {
950 return job_->GetLoadState();
951 }
952
935 void ProxyResolverV8TracingImpl::GetProxyForURL( 953 void ProxyResolverV8TracingImpl::GetProxyForURL(
936 const GURL& url, 954 const GURL& url,
937 ProxyInfo* results, 955 ProxyInfo* results,
938 const CompletionCallback& callback, 956 const CompletionCallback& callback,
939 ProxyResolver::RequestHandle* request, 957 scoped_ptr<ProxyResolver::Request>* request,
940 scoped_ptr<Bindings> bindings) { 958 scoped_ptr<Bindings> bindings) {
941 DCHECK(CalledOnValidThread()); 959 DCHECK(CalledOnValidThread());
942 DCHECK(!callback.is_null()); 960 DCHECK(!callback.is_null());
943 961
944 scoped_refptr<Job> job = new Job(job_params_.get(), bindings.Pass()); 962 scoped_refptr<Job> job = new Job(job_params_.get(), bindings.Pass());
945 963
946 if (request) 964 if (request)
947 *request = job.get(); 965 request->reset(new RequestImpl(job.get()));
948 966
949 job->StartGetProxyForURL(url, results, callback); 967 job->StartGetProxyForURL(url, results, callback);
950 } 968 }
951 969
952 void ProxyResolverV8TracingImpl::CancelRequest(
953 ProxyResolver::RequestHandle request) {
954 Job* job = reinterpret_cast<Job*>(request);
955 job->Cancel();
956 }
957
958 LoadState ProxyResolverV8TracingImpl::GetLoadState(
959 ProxyResolver::RequestHandle request) const {
960 Job* job = reinterpret_cast<Job*>(request);
961 return job->GetLoadState();
962 }
963 970
964 class ProxyResolverV8TracingFactoryImpl : public ProxyResolverV8TracingFactory { 971 class ProxyResolverV8TracingFactoryImpl : public ProxyResolverV8TracingFactory {
965 public: 972 public:
966 ProxyResolverV8TracingFactoryImpl(); 973 ProxyResolverV8TracingFactoryImpl();
967 ~ProxyResolverV8TracingFactoryImpl() override; 974 ~ProxyResolverV8TracingFactoryImpl() override;
968 975
969 void CreateProxyResolverV8Tracing( 976 void CreateProxyResolverV8Tracing(
970 const scoped_refptr<ProxyResolverScriptData>& pac_script, 977 const scoped_refptr<ProxyResolverScriptData>& pac_script,
971 scoped_ptr<ProxyResolverV8Tracing::Bindings> bindings, 978 scoped_ptr<ProxyResolverV8Tracing::Bindings> bindings,
972 scoped_ptr<ProxyResolverV8Tracing>* resolver, 979 scoped_ptr<ProxyResolverV8Tracing>* resolver,
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 1098
1092 } // namespace 1099 } // namespace
1093 1100
1094 // static 1101 // static
1095 scoped_ptr<ProxyResolverV8TracingFactory> 1102 scoped_ptr<ProxyResolverV8TracingFactory>
1096 ProxyResolverV8TracingFactory::Create() { 1103 ProxyResolverV8TracingFactory::Create() {
1097 return make_scoped_ptr(new ProxyResolverV8TracingFactoryImpl()); 1104 return make_scoped_ptr(new ProxyResolverV8TracingFactoryImpl());
1098 } 1105 }
1099 1106
1100 } // namespace net 1107 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698