OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "apps/benchmark/event.h" | 5 #include "apps/benchmark/event.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <stack> | 8 #include <stack> |
9 | 9 |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 const std::string& key, | 48 const std::string& key, |
49 std::string* output) { | 49 std::string* output) { |
50 const base::Value* value; | 50 const base::Value* value; |
51 if (!event_dict->Get(key, &value)) { | 51 if (!event_dict->Get(key, &value)) { |
52 LOG(ERROR) << "Incorrect trace event (missing " + key + "): " | 52 LOG(ERROR) << "Incorrect trace event (missing " + key + "): " |
53 << *event_dict; | 53 << *event_dict; |
54 return false; | 54 return false; |
55 } | 55 } |
56 | 56 |
57 if (value->IsType(base::Value::TYPE_INTEGER)) { | 57 if (value->IsType(base::Value::TYPE_INTEGER)) { |
58 int id_int; | 58 int id_int = 0; |
59 // We already verified the type, so it should be an integer. | 59 // We already verified the type, so it should be an integer. |
60 DCHECK(value->GetAsInteger(&id_int)); | 60 DCHECK(value->GetAsInteger(&id_int)); |
61 *output = base::IntToString(id_int); | 61 *output = base::IntToString(id_int); |
62 } else if (value->IsType(base::Value::TYPE_STRING)) { | 62 } else if (value->IsType(base::Value::TYPE_STRING)) { |
63 DCHECK(value->GetAsString(output)); | 63 DCHECK(value->GetAsString(output)); |
64 } else { | 64 } else { |
65 LOG(ERROR) << "Incorrect trace event (" + key + | 65 LOG(ERROR) << "Incorrect trace event (" + key + |
66 " not a string or integer): " | 66 " not a string or integer): " |
67 << *event_dict; | 67 << *event_dict; |
68 return false; | 68 return false; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 } | 264 } |
265 | 265 |
266 if (!JoinEvents(event_list)) | 266 if (!JoinEvents(event_list)) |
267 return false; | 267 return false; |
268 | 268 |
269 if (!ParseEvents(event_list, result)) | 269 if (!ParseEvents(event_list, result)) |
270 return false; | 270 return false; |
271 return true; | 271 return true; |
272 } | 272 } |
273 } // namespace benchmark | 273 } // namespace benchmark |
OLD | NEW |