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

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

Issue 15829004: Update net/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: license twerk Created 7 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 | Annotate | Revision Log
« no previous file with comments | « net/proxy/proxy_resolver_v8.cc ('k') | net/proxy/proxy_script_fetcher_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 DCHECK(host_resolver); 1070 DCHECK(host_resolver);
1071 // Start up the thread. 1071 // Start up the thread.
1072 thread_.reset(new base::Thread("Proxy resolver")); 1072 thread_.reset(new base::Thread("Proxy resolver"));
1073 CHECK(thread_->Start()); 1073 CHECK(thread_->Start());
1074 1074
1075 v8_resolver_.reset(new ProxyResolverV8); 1075 v8_resolver_.reset(new ProxyResolverV8);
1076 } 1076 }
1077 1077
1078 ProxyResolverV8Tracing::~ProxyResolverV8Tracing() { 1078 ProxyResolverV8Tracing::~ProxyResolverV8Tracing() {
1079 // Note, all requests should have been cancelled. 1079 // Note, all requests should have been cancelled.
1080 CHECK(!set_pac_script_job_); 1080 CHECK(!set_pac_script_job_.get());
1081 CHECK_EQ(0, num_outstanding_callbacks_); 1081 CHECK_EQ(0, num_outstanding_callbacks_);
1082 1082
1083 // Join the worker thread. See http://crbug.com/69710. Note that we call 1083 // Join the worker thread. See http://crbug.com/69710. Note that we call
1084 // Stop() here instead of simply clearing thread_ since there may be pending 1084 // Stop() here instead of simply clearing thread_ since there may be pending
1085 // callbacks on the worker thread which want to dereference thread_. 1085 // callbacks on the worker thread which want to dereference thread_.
1086 base::ThreadRestrictions::ScopedAllowIO allow_io; 1086 base::ThreadRestrictions::ScopedAllowIO allow_io;
1087 thread_->Stop(); 1087 thread_->Stop();
1088 } 1088 }
1089 1089
1090 int ProxyResolverV8Tracing::GetProxyForURL(const GURL& url, 1090 int ProxyResolverV8Tracing::GetProxyForURL(const GURL& url,
1091 ProxyInfo* results, 1091 ProxyInfo* results,
1092 const CompletionCallback& callback, 1092 const CompletionCallback& callback,
1093 RequestHandle* request, 1093 RequestHandle* request,
1094 const BoundNetLog& net_log) { 1094 const BoundNetLog& net_log) {
1095 DCHECK(CalledOnValidThread()); 1095 DCHECK(CalledOnValidThread());
1096 DCHECK(!callback.is_null()); 1096 DCHECK(!callback.is_null());
1097 DCHECK(!set_pac_script_job_); 1097 DCHECK(!set_pac_script_job_.get());
1098 1098
1099 scoped_refptr<Job> job = new Job(this); 1099 scoped_refptr<Job> job = new Job(this);
1100 1100
1101 if (request) 1101 if (request)
1102 *request = job.get(); 1102 *request = job.get();
1103 1103
1104 job->StartGetProxyForURL(url, results, net_log, callback); 1104 job->StartGetProxyForURL(url, results, net_log, callback);
1105 return ERR_IO_PENDING; 1105 return ERR_IO_PENDING;
1106 } 1106 }
1107 1107
1108 void ProxyResolverV8Tracing::CancelRequest(RequestHandle request) { 1108 void ProxyResolverV8Tracing::CancelRequest(RequestHandle request) {
1109 Job* job = reinterpret_cast<Job*>(request); 1109 Job* job = reinterpret_cast<Job*>(request);
1110 job->Cancel(); 1110 job->Cancel();
1111 } 1111 }
1112 1112
1113 LoadState ProxyResolverV8Tracing::GetLoadState(RequestHandle request) const { 1113 LoadState ProxyResolverV8Tracing::GetLoadState(RequestHandle request) const {
1114 Job* job = reinterpret_cast<Job*>(request); 1114 Job* job = reinterpret_cast<Job*>(request);
1115 return job->GetLoadState(); 1115 return job->GetLoadState();
1116 } 1116 }
1117 1117
1118 void ProxyResolverV8Tracing::CancelSetPacScript() { 1118 void ProxyResolverV8Tracing::CancelSetPacScript() {
1119 DCHECK(set_pac_script_job_); 1119 DCHECK(set_pac_script_job_.get());
1120 set_pac_script_job_->Cancel(); 1120 set_pac_script_job_->Cancel();
1121 set_pac_script_job_ = NULL; 1121 set_pac_script_job_ = NULL;
1122 } 1122 }
1123 1123
1124 void ProxyResolverV8Tracing::PurgeMemory() { 1124 void ProxyResolverV8Tracing::PurgeMemory() {
1125 thread_->message_loop()->PostTask( 1125 thread_->message_loop()->PostTask(
1126 FROM_HERE, 1126 FROM_HERE,
1127 base::Bind(&ProxyResolverV8::PurgeMemory, 1127 base::Bind(&ProxyResolverV8::PurgeMemory,
1128 // The use of unretained is safe, since the worker thread 1128 // The use of unretained is safe, since the worker thread
1129 // cannot outlive |this|. 1129 // cannot outlive |this|.
1130 base::Unretained(v8_resolver_.get()))); 1130 base::Unretained(v8_resolver_.get())));
1131 } 1131 }
1132 1132
1133 int ProxyResolverV8Tracing::SetPacScript( 1133 int ProxyResolverV8Tracing::SetPacScript(
1134 const scoped_refptr<ProxyResolverScriptData>& script_data, 1134 const scoped_refptr<ProxyResolverScriptData>& script_data,
1135 const CompletionCallback& callback) { 1135 const CompletionCallback& callback) {
1136 DCHECK(CalledOnValidThread()); 1136 DCHECK(CalledOnValidThread());
1137 DCHECK(!callback.is_null()); 1137 DCHECK(!callback.is_null());
1138 1138
1139 // Note that there should not be any outstanding (non-cancelled) Jobs when 1139 // Note that there should not be any outstanding (non-cancelled) Jobs when
1140 // setting the PAC script (ProxyService should guarantee this). If there are, 1140 // setting the PAC script (ProxyService should guarantee this). If there are,
1141 // then they might complete in strange ways after the new script is set. 1141 // then they might complete in strange ways after the new script is set.
1142 DCHECK(!set_pac_script_job_); 1142 DCHECK(!set_pac_script_job_.get());
1143 CHECK_EQ(0, num_outstanding_callbacks_); 1143 CHECK_EQ(0, num_outstanding_callbacks_);
1144 1144
1145 set_pac_script_job_ = new Job(this); 1145 set_pac_script_job_ = new Job(this);
1146 set_pac_script_job_->StartSetPacScript(script_data, callback); 1146 set_pac_script_job_->StartSetPacScript(script_data, callback);
1147 1147
1148 return ERR_IO_PENDING; 1148 return ERR_IO_PENDING;
1149 } 1149 }
1150 1150
1151 } // namespace net 1151 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_resolver_v8.cc ('k') | net/proxy/proxy_script_fetcher_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698