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

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

Issue 1105743002: More instrumentation to track down net/ jank. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « net/dns/host_resolver_impl.cc ('k') | no next file » | 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) 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/proxy_script_fetcher_impl.h" 5 #include "net/proxy/proxy_script_fetcher_impl.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/profiler/scoped_tracker.h"
10 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
11 #include "net/base/data_url.h" 12 #include "net/base/data_url.h"
12 #include "net/base/io_buffer.h" 13 #include "net/base/io_buffer.h"
13 #include "net/base/load_flags.h" 14 #include "net/base/load_flags.h"
14 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
15 #include "net/base/net_string_util.h" 16 #include "net/base/net_string_util.h"
16 #include "net/base/request_priority.h" 17 #include "net/base/request_priority.h"
17 #include "net/cert/cert_status_flags.h" 18 #include "net/cert/cert_status_flags.h"
18 #include "net/http/http_response_headers.h" 19 #include "net/http/http_response_headers.h"
19 #include "net/url_request/url_request_context.h" 20 #include "net/url_request/url_request_context.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // Use |result_code_| as the request's error if we have already set it to 108 // Use |result_code_| as the request's error if we have already set it to
108 // something specific. 109 // something specific.
109 if (result_code_ == OK && !request->status().is_success()) 110 if (result_code_ == OK && !request->status().is_success())
110 result_code_ = request->status().error(); 111 result_code_ = request->status().error();
111 112
112 FetchCompleted(); 113 FetchCompleted();
113 } 114 }
114 115
115 int ProxyScriptFetcherImpl::Fetch( 116 int ProxyScriptFetcherImpl::Fetch(
116 const GURL& url, base::string16* text, const CompletionCallback& callback) { 117 const GURL& url, base::string16* text, const CompletionCallback& callback) {
118 // TODO(eroman): Remove ScopedTracker below once crbug.com/455942 is fixed.
119 tracked_objects::ScopedTracker tracking_profile1(
120 FROM_HERE_WITH_EXPLICIT_FUNCTION(
121 "455942 ProxyScriptFetcherImpl::Fetch (Other)"));
122
117 // It is invalid to call Fetch() while a request is already in progress. 123 // It is invalid to call Fetch() while a request is already in progress.
118 DCHECK(!cur_request_.get()); 124 DCHECK(!cur_request_.get());
119 DCHECK(!callback.is_null()); 125 DCHECK(!callback.is_null());
120 DCHECK(text); 126 DCHECK(text);
121 127
122 // Handle base-64 encoded data-urls that contain custom PAC scripts. 128 // Handle base-64 encoded data-urls that contain custom PAC scripts.
123 if (url.SchemeIs("data")) { 129 if (url.SchemeIs("data")) {
130 // TODO(eroman): Remove ScopedTracker below once crbug.com/455942 is fixed.
131 tracked_objects::ScopedTracker tracking_profile2(
132 FROM_HERE_WITH_EXPLICIT_FUNCTION(
133 "455942 ProxyScriptFetcherImpl::Fetch (data url)"));
124 std::string mime_type; 134 std::string mime_type;
125 std::string charset; 135 std::string charset;
126 std::string data; 136 std::string data;
127 if (!DataURL::Parse(url, &mime_type, &charset, &data)) 137 if (!DataURL::Parse(url, &mime_type, &charset, &data))
128 return ERR_FAILED; 138 return ERR_FAILED;
129 139
130 ConvertResponseToUTF16(charset, data, text); 140 ConvertResponseToUTF16(charset, data, text);
131 return OK; 141 return OK;
132 } 142 }
133 143
(...skipping 14 matching lines...) Expand all
148 LOAD_DISABLE_CERT_REVOCATION_CHECKING); 158 LOAD_DISABLE_CERT_REVOCATION_CHECKING);
149 159
150 // Save the caller's info for notification on completion. 160 // Save the caller's info for notification on completion.
151 callback_ = callback; 161 callback_ = callback;
152 result_text_ = text; 162 result_text_ = text;
153 163
154 bytes_read_so_far_.clear(); 164 bytes_read_so_far_.clear();
155 165
156 // Post a task to timeout this request if it takes too long. 166 // Post a task to timeout this request if it takes too long.
157 cur_request_id_ = ++next_id_; 167 cur_request_id_ = ++next_id_;
168
169 // TODO(eroman): Remove ScopedTracker below once crbug.com/455942 is fixed.
170 tracked_objects::ScopedTracker tracking_profile3(
171 FROM_HERE_WITH_EXPLICIT_FUNCTION(
172 "455942 ProxyScriptFetcherImpl::Fetch (PostDelayedTask)"));
173
158 base::MessageLoop::current()->PostDelayedTask( 174 base::MessageLoop::current()->PostDelayedTask(
159 FROM_HERE, 175 FROM_HERE,
160 base::Bind(&ProxyScriptFetcherImpl::OnTimeout, 176 base::Bind(&ProxyScriptFetcherImpl::OnTimeout,
161 weak_factory_.GetWeakPtr(), 177 weak_factory_.GetWeakPtr(),
162 cur_request_id_), 178 cur_request_id_),
163 max_duration_); 179 max_duration_);
164 180
165 // Start the request. 181 // Start the request.
166 cur_request_->Start(); 182 cur_request_->Start();
mmenke 2015/04/23 21:32:51 Hrm...Some poor soul is also stuck looking into ja
eroman 2015/04/23 22:50:46 Heh, I wonder who that poor soul might be... I gue
167 return ERR_IO_PENDING; 183 return ERR_IO_PENDING;
168 } 184 }
169 185
170 void ProxyScriptFetcherImpl::Cancel() { 186 void ProxyScriptFetcherImpl::Cancel() {
171 // ResetCurRequestState will free the URLRequest, which will cause 187 // ResetCurRequestState will free the URLRequest, which will cause
172 // cancellation. 188 // cancellation.
173 ResetCurRequestState(); 189 ResetCurRequestState();
174 } 190 }
175 191
176 URLRequestContext* ProxyScriptFetcherImpl::GetRequestContext() const { 192 URLRequestContext* ProxyScriptFetcherImpl::GetRequestContext() const {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 // is still applicable. 327 // is still applicable.
312 if (cur_request_id_ != id) 328 if (cur_request_id_ != id)
313 return; 329 return;
314 330
315 DCHECK(cur_request_.get()); 331 DCHECK(cur_request_.get());
316 result_code_ = ERR_TIMED_OUT; 332 result_code_ = ERR_TIMED_OUT;
317 cur_request_->Cancel(); 333 cur_request_->Cancel();
318 } 334 }
319 335
320 } // namespace net 336 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/host_resolver_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698