| OLD | NEW |
| 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 "base/profiler/scoped_tracker.h" | |
| 8 #include "chrome/browser/devtools/devtools_network_controller.h" | 7 #include "chrome/browser/devtools/devtools_network_controller.h" |
| 9 #include "chrome/browser/devtools/devtools_network_interceptor.h" | 8 #include "chrome/browser/devtools/devtools_network_interceptor.h" |
| 10 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
| 11 #include "net/base/upload_progress.h" | 10 #include "net/base/upload_progress.h" |
| 12 #include "net/http/http_network_transaction.h" | 11 #include "net/http/http_network_transaction.h" |
| 13 #include "net/http/http_request_info.h" | 12 #include "net/http/http_request_info.h" |
| 14 | 13 |
| 15 // Keep in sync with kDevToolsRequestInitiator and | 14 // Keep in sync with kDevToolsRequestInitiator and |
| 16 // kDevToolsEmulateNetworkConditionsClientId defined in | 15 // kDevToolsEmulateNetworkConditionsClientId defined in |
| 17 // InspectorResourceAgent.cpp. | 16 // InspectorResourceAgent.cpp. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 46 if (callback_type_ == START) | 45 if (callback_type_ == START) |
| 47 throttled_byte_count_ += network_transaction_->GetTotalReceivedBytes(); | 46 throttled_byte_count_ += network_transaction_->GetTotalReceivedBytes(); |
| 48 if (result > 0) | 47 if (result > 0) |
| 49 throttled_byte_count_ += result; | 48 throttled_byte_count_ += result; |
| 50 | 49 |
| 51 if (interceptor_) | 50 if (interceptor_) |
| 52 interceptor_->ThrottleTransaction(this, callback_type_ == START); | 51 interceptor_->ThrottleTransaction(this, callback_type_ == START); |
| 53 } | 52 } |
| 54 | 53 |
| 55 void DevToolsNetworkTransaction::OnCallback(int rv) { | 54 void DevToolsNetworkTransaction::OnCallback(int rv) { |
| 56 // TODO(vadimt): Remove ScopedTracker below once crbug.com/424359 is fixed. | |
| 57 tracked_objects::ScopedTracker tracking_profile( | |
| 58 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 59 "424359 DevToolsNetworkTransaction::OnCallback")); | |
| 60 | |
| 61 if (failed_) | 55 if (failed_) |
| 62 return; | 56 return; |
| 63 DCHECK(!callback_.is_null()); | 57 DCHECK(!callback_.is_null()); |
| 64 if (callback_type_ == START || callback_type_ == READ) { | 58 if (callback_type_ == START || callback_type_ == READ) { |
| 65 if (interceptor_ && interceptor_->ShouldThrottle(this)) { | 59 if (interceptor_ && interceptor_->ShouldThrottle(this)) { |
| 66 Throttle(rv); | 60 Throttle(rv); |
| 67 return; | 61 return; |
| 68 } | 62 } |
| 69 } | 63 } |
| 70 net::CompletionCallback callback = callback_; | 64 net::CompletionCallback callback = callback_; |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 } | 267 } |
| 274 | 268 |
| 275 void DevToolsNetworkTransaction::FireThrottledCallback() { | 269 void DevToolsNetworkTransaction::FireThrottledCallback() { |
| 276 DCHECK(!callback_.is_null()); | 270 DCHECK(!callback_.is_null()); |
| 277 DCHECK(callback_type_ == READ || callback_type_ == START); | 271 DCHECK(callback_type_ == READ || callback_type_ == START); |
| 278 net::CompletionCallback callback = callback_; | 272 net::CompletionCallback callback = callback_; |
| 279 callback_.Reset(); | 273 callback_.Reset(); |
| 280 callback_type_ = NONE; | 274 callback_type_ = NONE; |
| 281 callback.Run(throttled_result_); | 275 callback.Run(throttled_result_); |
| 282 } | 276 } |
| OLD | NEW |