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

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

Issue 324953002: DevToolsNetworkController: support "limit throughput" network condition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: One more divide-by-zero check 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_controller.h
diff --git a/chrome/browser/devtools/devtools_network_controller.h b/chrome/browser/devtools/devtools_network_controller.h
index f057412e5a23be36d92438d7e3b9c46115cb5ec1..adcd145444f3d5bb1b1b77478382180c57431a59 100644
--- a/chrome/browser/devtools/devtools_network_controller.h
+++ b/chrome/browser/devtools/devtools_network_controller.h
@@ -13,12 +13,18 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/threading/thread_checker.h"
+#include "base/timer/timer.h"
class DevToolsNetworkConditions;
class DevToolsNetworkTransaction;
class GURL;
class Profile;
+namespace base {
+class TimeDelta;
+class TimeTicks;
+}
+
namespace content {
class ResourceContext;
}
@@ -31,6 +37,10 @@ namespace test {
class DevToolsNetworkControllerHelper;
}
+namespace {
+struct Throttle;
+}
+
// DevToolsNetworkController tracks DevToolsNetworkTransactions.
class DevToolsNetworkController {
@@ -43,12 +53,13 @@ class DevToolsNetworkController {
void RemoveTransaction(DevToolsNetworkTransaction* transaction);
// Applies network emulation configuration.
- // |client_id| should be DevToolsAgentHost GUID.
void SetNetworkState(
- const std::string& client_id,
const scoped_refptr<DevToolsNetworkConditions> conditions);
bool ShouldFail(const net::HttpRequestInfo* request);
+ bool ShouldThrottle(const net::HttpRequestInfo* request);
+ void ThrottleTransaction(DevToolsNetworkTransaction* transaction,
+ int64_t penalty);
protected:
friend class test::DevToolsNetworkControllerHelper;
@@ -59,19 +70,26 @@ class DevToolsNetworkController {
typedef scoped_refptr<DevToolsNetworkConditions> Conditions;
- void SetNetworkStateOnIO(
- const std::string& client_id,
- const Conditions conditions);
+ void SetNetworkStateOnIO(const Conditions conditions);
typedef std::set<DevToolsNetworkTransaction*> Transactions;
Transactions transactions_;
- // Active client id.
- std::string active_client_id_;
-
- // Active network conditions.
Conditions conditions_;
+ void UpdateThrottles();
+ void FireThrottledCallbacks();
+ void CancelThrottles();
+ void ArmTimer();
+ void OnTimer();
+
+ typedef std::vector<Throttle> Throttles;
+ Throttles throttles_;
+ base::OneShotTimer<DevToolsNetworkController> timer_;
+ base::TimeTicks offset_;
+ base::TimeDelta tick_length_;
+ uint64_t last_tick_;
+
base::WeakPtrFactory<DevToolsNetworkController> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(DevToolsNetworkController);

Powered by Google App Engine
This is Rietveld 408576698