| 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 "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/net_errors.h" | 9 #include "net/base/net_errors.h" |
| 10 #include "net/base/upload_progress.h" | 10 #include "net/base/upload_progress.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 void DevToolsNetworkTransaction::Throttle(int result) { | 41 void DevToolsNetworkTransaction::Throttle(int result) { |
| 42 throttled_result_ = result; | 42 throttled_result_ = result; |
| 43 | 43 |
| 44 if (callback_type_ == START) | 44 if (callback_type_ == START) |
| 45 throttled_byte_count_ += network_transaction_->GetTotalReceivedBytes(); | 45 throttled_byte_count_ += network_transaction_->GetTotalReceivedBytes(); |
| 46 if (result > 0) | 46 if (result > 0) |
| 47 throttled_byte_count_ += result; | 47 throttled_byte_count_ += result; |
| 48 | 48 |
| 49 if (interceptor_) | 49 if (interceptor_) |
| 50 interceptor_->ThrottleTransaction(this); | 50 interceptor_->ThrottleTransaction(this, callback_type_ == START); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void DevToolsNetworkTransaction::OnCallback(int rv) { | 53 void DevToolsNetworkTransaction::OnCallback(int rv) { |
| 54 if (failed_) | 54 if (failed_) |
| 55 return; | 55 return; |
| 56 DCHECK(!callback_.is_null()); | 56 DCHECK(!callback_.is_null()); |
| 57 if (callback_type_ == START || callback_type_ == READ) { | 57 if (callback_type_ == START || callback_type_ == READ) { |
| 58 if (interceptor_ && interceptor_->ShouldThrottle(this)) { | 58 if (interceptor_ && interceptor_->ShouldThrottle(this)) { |
| 59 Throttle(rv); | 59 Throttle(rv); |
| 60 return; | 60 return; |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 } | 261 } |
| 262 | 262 |
| 263 void DevToolsNetworkTransaction::FireThrottledCallback() { | 263 void DevToolsNetworkTransaction::FireThrottledCallback() { |
| 264 DCHECK(!callback_.is_null()); | 264 DCHECK(!callback_.is_null()); |
| 265 DCHECK(callback_type_ == READ || callback_type_ == START); | 265 DCHECK(callback_type_ == READ || callback_type_ == START); |
| 266 net::CompletionCallback callback = callback_; | 266 net::CompletionCallback callback = callback_; |
| 267 callback_.Reset(); | 267 callback_.Reset(); |
| 268 callback_type_ = NONE; | 268 callback_type_ = NONE; |
| 269 callback.Run(throttled_result_); | 269 callback.Run(throttled_result_); |
| 270 } | 270 } |
| OLD | NEW |