| Index: apps/benchmark/event.cc
|
| diff --git a/apps/benchmark/event.cc b/apps/benchmark/event.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..6f9e6e0122c539d76ad8dc059ba624d34f10eba7
|
| --- /dev/null
|
| +++ b/apps/benchmark/event.cc
|
| @@ -0,0 +1,49 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "apps/benchmark/event.h"
|
| +
|
| +namespace benchmark {
|
| +
|
| +Event::Event() {}
|
| +
|
| +Event::~Event() {}
|
| +
|
| +bool GetEvents(scoped_ptr<base::Value> trace_data, std::vector<Event>* result) {
|
| + result->clear();
|
| +
|
| + base::ListValue* event_list;
|
| + if (!trace_data->GetAsList(&event_list))
|
| + return false;
|
| +
|
| + for (base::Value* val : *event_list) {
|
| + Event event;
|
| + base::DictionaryValue* dict;
|
| + if (!val->GetAsDictionary(&dict))
|
| + return false;
|
| +
|
| + if (!dict->GetString("name", &event.name))
|
| + return false;
|
| +
|
| + if (!dict->GetString("cat", &event.category))
|
| + return false;
|
| +
|
| + double timestamp;
|
| + if (!dict->GetDouble("ts", ×tamp))
|
| + return false;
|
| + event.timestamp = base::TimeTicks::FromInternalValue(timestamp);
|
| +
|
| + // It is valid for an event to not have duration.
|
| + double duration;
|
| + if (!dict->GetDouble("dur", &duration)) {
|
| + event.duration = base::TimeDelta();
|
| + } else {
|
| + event.duration = base::TimeDelta::FromInternalValue(duration);
|
| + }
|
| +
|
| + result->push_back(event);
|
| + }
|
| + return true;
|
| +}
|
| +} // namespace benchmark
|
|
|