OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_REALM_H_ |
| 6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_REALM_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/timer/timer.h" |
| 14 |
| 15 class DevToolsNetworkConditions; |
| 16 class DevToolsNetworkTransaction; |
| 17 |
| 18 namespace base { |
| 19 class TimeDelta; |
| 20 class TimeTicks; |
| 21 } |
| 22 |
| 23 // DevToolsNetworkRealm emulates network conditions for transactions with |
| 24 // specific client id. |
| 25 class DevToolsNetworkRealm { |
| 26 |
| 27 public: |
| 28 DevToolsNetworkRealm(); |
| 29 virtual ~DevToolsNetworkRealm(); |
| 30 |
| 31 void RemoveTransaction(DevToolsNetworkTransaction* transaction); |
| 32 |
| 33 // Applies network emulation configuration. |
| 34 void UpdateConditions( |
| 35 const scoped_refptr<DevToolsNetworkConditions> conditions); |
| 36 |
| 37 void ThrottleTransaction(DevToolsNetworkTransaction* transaction); |
| 38 |
| 39 const DevToolsNetworkConditions* conditions() const { |
| 40 return conditions_.get(); |
| 41 } |
| 42 |
| 43 private: |
| 44 scoped_refptr<DevToolsNetworkConditions> conditions_; |
| 45 |
| 46 void UpdateThrottles(); |
| 47 void ArmTimer(); |
| 48 void OnTimer(); |
| 49 |
| 50 std::vector<DevToolsNetworkTransaction*> throttled_transactions_; |
| 51 base::OneShotTimer<DevToolsNetworkRealm> timer_; |
| 52 base::TimeTicks offset_; |
| 53 base::TimeDelta tick_length_; |
| 54 uint64_t last_tick_; |
| 55 |
| 56 DISALLOW_COPY_AND_ASSIGN(DevToolsNetworkRealm); |
| 57 }; |
| 58 |
| 59 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_REALM_H_ |
OLD | NEW |