Index: chrome/browser/devtools/devtools_network_realm.h |
diff --git a/chrome/browser/devtools/devtools_network_realm.h b/chrome/browser/devtools/devtools_network_realm.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..760ff6e240d134f473b6272349525a727d1f1fa2 |
--- /dev/null |
+++ b/chrome/browser/devtools/devtools_network_realm.h |
@@ -0,0 +1,59 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_REALM_H_ |
+#define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_REALM_H_ |
+ |
+#include <string> |
+#include <vector> |
+ |
+#include "base/macros.h" |
+#include "base/memory/ref_counted.h" |
+#include "base/timer/timer.h" |
+ |
+class DevToolsNetworkConditions; |
+class DevToolsNetworkTransaction; |
+ |
+namespace base { |
+class TimeDelta; |
+class TimeTicks; |
+} |
+ |
+// DevToolsNetworkRealm emulates network conditions for transactions with |
+// specific client id. |
+class DevToolsNetworkRealm { |
+ |
+ public: |
+ DevToolsNetworkRealm(); |
+ virtual ~DevToolsNetworkRealm(); |
+ |
+ void RemoveTransaction(DevToolsNetworkTransaction* transaction); |
+ |
+ // Applies network emulation configuration. |
+ void UpdateConditions( |
+ const scoped_refptr<DevToolsNetworkConditions> conditions); |
+ |
+ void ThrottleTransaction(DevToolsNetworkTransaction* transaction); |
+ |
+ const DevToolsNetworkConditions* conditions() const { |
+ return conditions_.get(); |
+ } |
+ |
+ private: |
+ scoped_refptr<DevToolsNetworkConditions> conditions_; |
+ |
+ void UpdateThrottles(); |
+ void ArmTimer(); |
+ void OnTimer(); |
+ |
+ std::vector<DevToolsNetworkTransaction*> throttled_transactions_; |
+ base::OneShotTimer<DevToolsNetworkRealm> timer_; |
+ base::TimeTicks offset_; |
+ base::TimeDelta tick_length_; |
+ uint64_t last_tick_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(DevToolsNetworkRealm); |
+}; |
+ |
+#endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_REALM_H_ |