OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chrome/network_conditions.h" | 5 #include "chrome/test/chromedriver/chrome/network_conditions.h" |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 json_reader.GetErrorMessage()); | 32 json_reader.GetErrorMessage()); |
33 | 33 |
34 base::ListValue* networks; | 34 base::ListValue* networks; |
35 if (!networks_value->GetAsList(&networks)) | 35 if (!networks_value->GetAsList(&networks)) |
36 return Status(kUnknownError, "malformed networks list"); | 36 return Status(kUnknownError, "malformed networks list"); |
37 | 37 |
38 for (base::ListValue::iterator it = networks->begin(); | 38 for (base::ListValue::iterator it = networks->begin(); |
39 it != networks->end(); | 39 it != networks->end(); |
40 ++it) { | 40 ++it) { |
41 base::DictionaryValue* network = NULL; | 41 base::DictionaryValue* network = NULL; |
42 if (!it->GetAsDictionary(&network)) { | 42 if (!(*it)->GetAsDictionary(&network)) { |
43 return Status(kUnknownError, | 43 return Status(kUnknownError, |
44 "malformed network in list: should be a dictionary"); | 44 "malformed network in list: should be a dictionary"); |
45 } | 45 } |
46 | 46 |
47 if (network == NULL) | 47 if (network == NULL) |
48 continue; | 48 continue; |
49 | 49 |
50 std::string title; | 50 std::string title; |
51 if (!network->GetString("title", &title)) { | 51 if (!network->GetString("title", &title)) { |
52 return Status(kUnknownError, | 52 return Status(kUnknownError, |
(...skipping 22 matching lines...) Expand all Loading... |
75 network_conditions->download_throughput *= 1024; | 75 network_conditions->download_throughput *= 1024; |
76 network_conditions->upload_throughput *= 1024; | 76 network_conditions->upload_throughput *= 1024; |
77 | 77 |
78 // |offline| is always false for now. | 78 // |offline| is always false for now. |
79 network_conditions->offline = false; | 79 network_conditions->offline = false; |
80 return Status(kOk); | 80 return Status(kOk); |
81 } | 81 } |
82 | 82 |
83 return Status(kUnknownError, "must be a valid network"); | 83 return Status(kUnknownError, "must be a valid network"); |
84 } | 84 } |
OLD | NEW |