OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/test/chromedriver/window_commands.h" | 5 #include "chrome/test/chromedriver/window_commands.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
923 "either 'network_conditions' or 'network_name' must be " | 923 "either 'network_conditions' or 'network_name' must be " |
924 "supplied"); | 924 "supplied"); |
925 } | 925 } |
926 | 926 |
927 session->overridden_network_conditions.reset( | 927 session->overridden_network_conditions.reset( |
928 network_conditions.release()); | 928 network_conditions.release()); |
929 return web_view->OverrideNetworkConditions( | 929 return web_view->OverrideNetworkConditions( |
930 *session->overridden_network_conditions); | 930 *session->overridden_network_conditions); |
931 } | 931 } |
932 | 932 |
| 933 Status ExecuteDeleteNetworkConditions( |
| 934 Session* session, |
| 935 WebView* web_view, |
| 936 const base::DictionaryValue& params, |
| 937 scoped_ptr<base::Value>* value) { |
| 938 // Chrome does not have any command to stop overriding network conditions, so |
| 939 // we just override the network conditions with the "No throttling" preset. |
| 940 NetworkConditions network_conditions; |
| 941 // Get conditions from preset list. |
| 942 Status status = FindPresetNetwork("No throttling", &network_conditions); |
| 943 if (status.IsError()) |
| 944 return status; |
| 945 |
| 946 status = web_view->OverrideNetworkConditions(network_conditions); |
| 947 if (status.IsError()) |
| 948 return status; |
| 949 |
| 950 // After we've successfully overridden the network conditions with |
| 951 // "No throttling", we can delete them from |session|. |
| 952 session->overridden_network_conditions.reset(); |
| 953 return status; |
| 954 } |
| 955 |
933 Status ExecuteTakeHeapSnapshot( | 956 Status ExecuteTakeHeapSnapshot( |
934 Session* session, | 957 Session* session, |
935 WebView* web_view, | 958 WebView* web_view, |
936 const base::DictionaryValue& params, | 959 const base::DictionaryValue& params, |
937 scoped_ptr<base::Value>* value) { | 960 scoped_ptr<base::Value>* value) { |
938 return web_view->TakeHeapSnapshot(value); | 961 return web_view->TakeHeapSnapshot(value); |
939 } | 962 } |
OLD | NEW |