OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "apps/benchmark/event.h" |
| 6 |
| 7 namespace benchmark { |
| 8 |
| 9 Event::Event() {} |
| 10 |
| 11 Event::~Event() {} |
| 12 |
| 13 bool GetEvents(scoped_ptr<base::Value> trace_data, std::vector<Event>* result) { |
| 14 result->clear(); |
| 15 |
| 16 base::ListValue* event_list; |
| 17 if (!trace_data->GetAsList(&event_list)) |
| 18 return false; |
| 19 |
| 20 for (base::Value* val : *event_list) { |
| 21 Event event; |
| 22 base::DictionaryValue* dict; |
| 23 if (!val->GetAsDictionary(&dict)) |
| 24 return false; |
| 25 |
| 26 if (!dict->GetString("name", &event.name)) |
| 27 return false; |
| 28 |
| 29 if (!dict->GetString("cat", &event.category)) |
| 30 return false; |
| 31 |
| 32 double timestamp; |
| 33 if (!dict->GetDouble("ts", ×tamp)) |
| 34 return false; |
| 35 event.timestamp = base::TimeTicks::FromInternalValue(timestamp); |
| 36 |
| 37 // It is valid for an event to not have duration. |
| 38 double duration; |
| 39 if (!dict->GetDouble("dur", &duration)) { |
| 40 event.duration = base::TimeDelta(); |
| 41 } else { |
| 42 event.duration = base::TimeDelta::FromInternalValue(duration); |
| 43 } |
| 44 |
| 45 result->push_back(event); |
| 46 } |
| 47 return true; |
| 48 } |
| 49 } // namespace benchmark |
OLD | NEW |