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

Unified Diff: chrome/test/chromedriver/chrome/network_conditions_override_manager.h

Issue 883083002: [chromedriver] Add Network Conditions Override Manager and tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix warning Created 5 years, 9 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/test/chromedriver/chrome/network_conditions_override_manager.h
diff --git a/chrome/test/chromedriver/chrome/network_conditions_override_manager.h b/chrome/test/chromedriver/chrome/network_conditions_override_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..2f55a3ba3db211d8636bb92071fa37b281a74d41
--- /dev/null
+++ b/chrome/test/chromedriver/chrome/network_conditions_override_manager.h
@@ -0,0 +1,48 @@
+// Copyright (c) 2015 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_TEST_CHROMEDRIVER_CHROME_NETWORK_CONDITIONS_OVERRIDE_MANAGER_H_
+#define CHROME_TEST_CHROMEDRIVER_CHROME_NETWORK_CONDITIONS_OVERRIDE_MANAGER_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
+#include "chrome/test/chromedriver/chrome/devtools_event_listener.h"
+
+namespace base {
+class DictionaryValue;
+}
+
+class DevToolsClient;
+struct NetworkConditions;
+class Status;
+
+// Overrides the network conditions, if requested, for the duration of the
+// given |DevToolsClient|'s lifetime.
+class NetworkConditionsOverrideManager : public DevToolsEventListener {
+ public:
+ explicit NetworkConditionsOverrideManager(DevToolsClient* client);
+ ~NetworkConditionsOverrideManager() override;
+
+ Status OverrideNetworkConditions(const NetworkConditions& network_conditions);
+
+ // Overridden from DevToolsEventListener:
+ Status OnConnected(DevToolsClient* client) override;
+ Status OnEvent(DevToolsClient* client,
+ const std::string& method,
+ const base::DictionaryValue& params) override;
+
+ private:
+ Status ApplyOverrideIfNeeded();
+ Status ApplyOverride(const NetworkConditions* network_conditions);
+
+ DevToolsClient* client_;
+ const NetworkConditions* overridden_network_conditions_;
+
+ DISALLOW_COPY_AND_ASSIGN(NetworkConditionsOverrideManager);
+};
+
+#endif // CHROME_TEST_CHROMEDRIVER_CHROME_NETWORK_CONDITIONS_OVERRIDE_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698