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

Unified Diff: chrome/browser/devtools/devtools_network_realm.h

Issue 342473004: DevTools: make network conditions emulation scoped (browser) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed nits Created 6 years, 6 months 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 side-by-side diff with in-line comments
Download patch
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_

Powered by Google App Engine
This is Rietveld 408576698