| 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 851 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 862     // default to 100 meters accuracy. | 862     // default to 100 meters accuracy. | 
| 863     geoposition.accuracy = 100; | 863     geoposition.accuracy = 100; | 
| 864   } | 864   } | 
| 865 | 865 | 
| 866   Status status = web_view->OverrideGeolocation(geoposition); | 866   Status status = web_view->OverrideGeolocation(geoposition); | 
| 867   if (status.IsOk()) | 867   if (status.IsOk()) | 
| 868     session->overridden_geoposition.reset(new Geoposition(geoposition)); | 868     session->overridden_geoposition.reset(new Geoposition(geoposition)); | 
| 869   return status; | 869   return status; | 
| 870 } | 870 } | 
| 871 | 871 | 
|  | 872 Status ExecuteSetNetworkConditions( | 
|  | 873     Session* session, | 
|  | 874     WebView* web_view, | 
|  | 875     const base::DictionaryValue& params, | 
|  | 876     scoped_ptr<base::Value>* value) { | 
|  | 877   const base::DictionaryValue* conditions = NULL; | 
|  | 878   NetworkConditions network_conditions; | 
|  | 879   // |latency| is required. | 
|  | 880   if (!params.GetDictionary("network_conditions", &conditions) || | 
|  | 881       !conditions->GetDouble("latency", &network_conditions.latency)) | 
|  | 882     return Status(kUnknownError, "missing or invalid 'network_conditions'"); | 
|  | 883 | 
|  | 884   // Either |throughput| or the pair |download_throughput| and | 
|  | 885   // |upload_throughput| is required. | 
|  | 886   if (conditions->HasKey("throughput")) { | 
|  | 887     if (!conditions->GetDouble("throughput", | 
|  | 888                                 &network_conditions.download_throughput)) | 
|  | 889       return Status(kUnknownError, "invalid 'throughput'"); | 
|  | 890     conditions->GetDouble("throughput", &network_conditions.upload_throughput); | 
|  | 891   } else if (conditions->HasKey("download_throughput") && | 
|  | 892              conditions->HasKey("upload_throughput")) { | 
|  | 893     if (!conditions->GetDouble("download_throughput", | 
|  | 894                                 &network_conditions.download_throughput) || | 
|  | 895         !conditions->GetDouble("upload_throughput", | 
|  | 896                                 &network_conditions.upload_throughput)) | 
|  | 897       return Status(kUnknownError, | 
|  | 898                     "invalid 'download_throughput' or 'upload_throughput'"); | 
|  | 899   } else { | 
|  | 900     return Status(kUnknownError, | 
|  | 901                   "invalid 'network_conditions' is missing 'throughput' or " | 
|  | 902                   "'download_throughput'/'upload_throughput' pair"); | 
|  | 903   } | 
|  | 904 | 
|  | 905   // |offline| is optional. | 
|  | 906   if (conditions->HasKey("offline")) { | 
|  | 907     if (!conditions->GetBoolean("offline", &network_conditions.offline)) | 
|  | 908       return Status(kUnknownError, "invalid 'offline'"); | 
|  | 909   } else { | 
|  | 910     network_conditions.offline = false; | 
|  | 911   } | 
|  | 912 | 
|  | 913   session->overridden_network_conditions.reset( | 
|  | 914       new NetworkConditions(network_conditions)); | 
|  | 915   return web_view->OverrideNetworkConditions( | 
|  | 916       *session->overridden_network_conditions); | 
|  | 917 } | 
|  | 918 | 
| 872 Status ExecuteTakeHeapSnapshot( | 919 Status ExecuteTakeHeapSnapshot( | 
| 873     Session* session, | 920     Session* session, | 
| 874     WebView* web_view, | 921     WebView* web_view, | 
| 875     const base::DictionaryValue& params, | 922     const base::DictionaryValue& params, | 
| 876     scoped_ptr<base::Value>* value) { | 923     scoped_ptr<base::Value>* value) { | 
| 877   return web_view->TakeHeapSnapshot(value); | 924   return web_view->TakeHeapSnapshot(value); | 
| 878 } | 925 } | 
| OLD | NEW | 
|---|