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

Side by Side Diff: chrome/browser/devtools/devtools_network_transaction.cc

Issue 1429113003: [DevTools] Narrow down DevToolsNetworkTransaction surface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment fix 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
« no previous file with comments | « chrome/browser/devtools/devtools_network_transaction.h ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/devtools/devtools_network_transaction.h" 5 #include "chrome/browser/devtools/devtools_network_transaction.h"
6 6
7 #include "chrome/browser/devtools/devtools_network_controller.h" 7 #include "chrome/browser/devtools/devtools_network_controller.h"
8 #include "chrome/browser/devtools/devtools_network_interceptor.h" 8 #include "chrome/browser/devtools/devtools_network_interceptor.h"
9 #include "net/base/load_timing_info.h" 9 #include "net/base/load_timing_info.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 callback_type_ = NONE; 134 callback_type_ = NONE;
135 callback.Run(net::ERR_INTERNET_DISCONNECTED); 135 callback.Run(net::ERR_INTERNET_DISCONNECTED);
136 } 136 }
137 137
138 int DevToolsNetworkTransaction::Start( 138 int DevToolsNetworkTransaction::Start(
139 const net::HttpRequestInfo* request, 139 const net::HttpRequestInfo* request,
140 const net::CompletionCallback& callback, 140 const net::CompletionCallback& callback,
141 const net::BoundNetLog& net_log) { 141 const net::BoundNetLog& net_log) {
142 DCHECK(request); 142 DCHECK(request);
143 request_ = request; 143 request_ = request;
144 interceptor_ = controller_->GetInterceptor(this);
145 interceptor_->AddThrottable(this);
146 144
147 if (interceptor_->ShouldFail()) { 145 std::string client_id;
146 ProcessRequest(&client_id);
147 interceptor_ = controller_->GetInterceptor(client_id);
148 if (interceptor_)
149 interceptor_->AddThrottable(this);
150
151 if (interceptor_ && interceptor_->ShouldFail()) {
148 failed_ = true; 152 failed_ = true;
149 network_transaction_->SetBeforeNetworkStartCallback( 153 network_transaction_->SetBeforeNetworkStartCallback(
150 BeforeNetworkStartCallback()); 154 BeforeNetworkStartCallback());
151 return net::ERR_INTERNET_DISCONNECTED; 155 return net::ERR_INTERNET_DISCONNECTED;
152 } 156 }
153 int rv = network_transaction_->Start(request_, proxy_callback_, net_log); 157 int rv = network_transaction_->Start(request_, proxy_callback_, net_log);
154 return SetupCallback(callback, rv, START); 158 return SetupCallback(callback, rv, START);
155 } 159 }
156 160
157 void DevToolsNetworkTransaction::ProcessRequest() { 161 void DevToolsNetworkTransaction::ProcessRequest(std::string* client_id) {
158 DCHECK(request_); 162 DCHECK(request_);
159 bool has_devtools_client_id = request_->extra_headers.HasHeader( 163 bool has_devtools_client_id = request_->extra_headers.HasHeader(
160 kDevToolsEmulateNetworkConditionsClientId); 164 kDevToolsEmulateNetworkConditionsClientId);
161 if (!has_devtools_client_id) 165 if (!has_devtools_client_id)
162 return; 166 return;
163 167
164 custom_request_.reset(new net::HttpRequestInfo(*request_)); 168 custom_request_.reset(new net::HttpRequestInfo(*request_));
165 custom_request_->extra_headers.GetHeader( 169 custom_request_->extra_headers.GetHeader(
166 kDevToolsEmulateNetworkConditionsClientId, &client_id_); 170 kDevToolsEmulateNetworkConditionsClientId, client_id);
167 custom_request_->extra_headers.RemoveHeader( 171 custom_request_->extra_headers.RemoveHeader(
168 kDevToolsEmulateNetworkConditionsClientId); 172 kDevToolsEmulateNetworkConditionsClientId);
169 request_ = custom_request_.get(); 173 request_ = custom_request_.get();
170 } 174 }
171 175
172 int DevToolsNetworkTransaction::RestartIgnoringLastError( 176 int DevToolsNetworkTransaction::RestartIgnoringLastError(
173 const net::CompletionCallback& callback) { 177 const net::CompletionCallback& callback) {
174 if (failed_) 178 if (failed_)
175 return net::ERR_INTERNET_DISCONNECTED; 179 return net::ERR_INTERNET_DISCONNECTED;
176 int rv = network_transaction_->RestartIgnoringLastError(proxy_callback_); 180 int rv = network_transaction_->RestartIgnoringLastError(proxy_callback_);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 } 295 }
292 296
293 void DevToolsNetworkTransaction::ThrottleFinished() { 297 void DevToolsNetworkTransaction::ThrottleFinished() {
294 DCHECK(!callback_.is_null()); 298 DCHECK(!callback_.is_null());
295 DCHECK(callback_type_ == READ || callback_type_ == START); 299 DCHECK(callback_type_ == READ || callback_type_ == START);
296 net::CompletionCallback callback = callback_; 300 net::CompletionCallback callback = callback_;
297 callback_.Reset(); 301 callback_.Reset();
298 callback_type_ = NONE; 302 callback_type_ = NONE;
299 callback.Run(throttled_result_); 303 callback.Run(throttled_result_);
300 } 304 }
OLDNEW
« no previous file with comments | « chrome/browser/devtools/devtools_network_transaction.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698