OLD | NEW |
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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 ~ProxyResolverV8Tracing() override; | 345 ~ProxyResolverV8Tracing() override; |
346 | 346 |
347 // ProxyResolver implementation: | 347 // ProxyResolver implementation: |
348 int GetProxyForURL(const GURL& url, | 348 int GetProxyForURL(const GURL& url, |
349 ProxyInfo* results, | 349 ProxyInfo* results, |
350 const CompletionCallback& callback, | 350 const CompletionCallback& callback, |
351 RequestHandle* request, | 351 RequestHandle* request, |
352 const BoundNetLog& net_log) override; | 352 const BoundNetLog& net_log) override; |
353 void CancelRequest(RequestHandle request) override; | 353 void CancelRequest(RequestHandle request) override; |
354 LoadState GetLoadState(RequestHandle request) const override; | 354 LoadState GetLoadState(RequestHandle request) const override; |
355 void CancelSetPacScript() override; | |
356 int SetPacScript(const scoped_refptr<ProxyResolverScriptData>& script_data, | |
357 const CompletionCallback& callback) override; | |
358 | 355 |
359 private: | 356 private: |
360 // The worker thread on which the ProxyResolverV8 will be run. | 357 // The worker thread on which the ProxyResolverV8 will be run. |
361 scoped_ptr<base::Thread> thread_; | 358 scoped_ptr<base::Thread> thread_; |
362 scoped_ptr<ProxyResolverV8> v8_resolver_; | 359 scoped_ptr<ProxyResolverV8> v8_resolver_; |
363 | 360 |
364 scoped_ptr<ProxyResolverErrorObserver> error_observer_; | 361 scoped_ptr<ProxyResolverErrorObserver> error_observer_; |
365 | 362 |
366 scoped_ptr<Job::Params> job_params_; | 363 scoped_ptr<Job::Params> job_params_; |
367 | 364 |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
996 // Emit to the global NetLog event stream. | 993 // Emit to the global NetLog event stream. |
997 if (net_log()) | 994 if (net_log()) |
998 net_log()->AddGlobalEntry(type, parameters_callback); | 995 net_log()->AddGlobalEntry(type, parameters_callback); |
999 } | 996 } |
1000 | 997 |
1001 ProxyResolverV8Tracing::ProxyResolverV8Tracing( | 998 ProxyResolverV8Tracing::ProxyResolverV8Tracing( |
1002 scoped_ptr<ProxyResolverErrorObserver> error_observer, | 999 scoped_ptr<ProxyResolverErrorObserver> error_observer, |
1003 scoped_ptr<base::Thread> thread, | 1000 scoped_ptr<base::Thread> thread, |
1004 scoped_ptr<ProxyResolverV8> resolver, | 1001 scoped_ptr<ProxyResolverV8> resolver, |
1005 scoped_ptr<Job::Params> job_params) | 1002 scoped_ptr<Job::Params> job_params) |
1006 : ProxyResolver(true /*expects_pac_bytes*/), | 1003 : thread_(thread.Pass()), |
1007 thread_(thread.Pass()), | |
1008 v8_resolver_(resolver.Pass()), | 1004 v8_resolver_(resolver.Pass()), |
1009 error_observer_(error_observer.Pass()), | 1005 error_observer_(error_observer.Pass()), |
1010 job_params_(job_params.Pass()), | 1006 job_params_(job_params.Pass()), |
1011 num_outstanding_callbacks_(0) { | 1007 num_outstanding_callbacks_(0) { |
1012 job_params_->num_outstanding_callbacks = &num_outstanding_callbacks_; | 1008 job_params_->num_outstanding_callbacks = &num_outstanding_callbacks_; |
1013 } | 1009 } |
1014 | 1010 |
1015 ProxyResolverV8Tracing::~ProxyResolverV8Tracing() { | 1011 ProxyResolverV8Tracing::~ProxyResolverV8Tracing() { |
1016 // Note, all requests should have been cancelled. | 1012 // Note, all requests should have been cancelled. |
1017 CHECK_EQ(0, num_outstanding_callbacks_); | 1013 CHECK_EQ(0, num_outstanding_callbacks_); |
(...skipping 23 matching lines...) Expand all Loading... |
1041 void ProxyResolverV8Tracing::CancelRequest(RequestHandle request) { | 1037 void ProxyResolverV8Tracing::CancelRequest(RequestHandle request) { |
1042 Job* job = reinterpret_cast<Job*>(request); | 1038 Job* job = reinterpret_cast<Job*>(request); |
1043 job->Cancel(); | 1039 job->Cancel(); |
1044 } | 1040 } |
1045 | 1041 |
1046 LoadState ProxyResolverV8Tracing::GetLoadState(RequestHandle request) const { | 1042 LoadState ProxyResolverV8Tracing::GetLoadState(RequestHandle request) const { |
1047 Job* job = reinterpret_cast<Job*>(request); | 1043 Job* job = reinterpret_cast<Job*>(request); |
1048 return job->GetLoadState(); | 1044 return job->GetLoadState(); |
1049 } | 1045 } |
1050 | 1046 |
1051 void ProxyResolverV8Tracing::CancelSetPacScript() { | |
1052 NOTREACHED(); | |
1053 } | |
1054 | |
1055 int ProxyResolverV8Tracing::SetPacScript( | |
1056 const scoped_refptr<ProxyResolverScriptData>& script_data, | |
1057 const CompletionCallback& callback) { | |
1058 NOTREACHED(); | |
1059 return ERR_NOT_IMPLEMENTED; | |
1060 } | |
1061 | |
1062 } // namespace | 1047 } // namespace |
1063 | 1048 |
1064 class ProxyResolverFactoryV8Tracing::CreateJob | 1049 class ProxyResolverFactoryV8Tracing::CreateJob |
1065 : public ProxyResolverFactory::Request { | 1050 : public ProxyResolverFactory::Request { |
1066 public: | 1051 public: |
1067 CreateJob(ProxyResolverFactoryV8Tracing* factory, | 1052 CreateJob(ProxyResolverFactoryV8Tracing* factory, |
1068 HostResolver* host_resolver, | 1053 HostResolver* host_resolver, |
1069 scoped_ptr<ProxyResolverErrorObserver> error_observer, | 1054 scoped_ptr<ProxyResolverErrorObserver> error_observer, |
1070 NetLog* net_log, | 1055 NetLog* net_log, |
1071 const ProxyResolver::LoadStateChangedCallback& | 1056 const ProxyResolver::LoadStateChangedCallback& |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 return ERR_IO_PENDING; | 1168 return ERR_IO_PENDING; |
1184 } | 1169 } |
1185 | 1170 |
1186 void ProxyResolverFactoryV8Tracing::RemoveJob( | 1171 void ProxyResolverFactoryV8Tracing::RemoveJob( |
1187 ProxyResolverFactoryV8Tracing::CreateJob* job) { | 1172 ProxyResolverFactoryV8Tracing::CreateJob* job) { |
1188 size_t erased = jobs_.erase(job); | 1173 size_t erased = jobs_.erase(job); |
1189 DCHECK_EQ(1u, erased); | 1174 DCHECK_EQ(1u, erased); |
1190 } | 1175 } |
1191 | 1176 |
1192 } // namespace net | 1177 } // namespace net |
OLD | NEW |