| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 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 "chrome/browser/performance_monitor/event.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 | |
| 9 namespace performance_monitor { | |
| 10 | |
| 11 Event::Event(const EventType& type, | |
| 12 const base::Time& time, | |
| 13 scoped_ptr<base::DictionaryValue> data) | |
| 14 : type_(type), time_(time), data_(data.release()) { | |
| 15 } | |
| 16 | |
| 17 Event::~Event() { | |
| 18 } | |
| 19 | |
| 20 scoped_ptr<Event> Event::FromValue(scoped_ptr<base::DictionaryValue> data) { | |
| 21 int type = 0; | |
| 22 if (!data->GetInteger(std::string("eventType"), &type)) | |
| 23 return scoped_ptr<Event>(); | |
| 24 double time = 0.0; | |
| 25 if (!data->GetDouble(std::string("time"), &time)) | |
| 26 return scoped_ptr<Event>(); | |
| 27 return scoped_ptr<Event>(new Event(static_cast<EventType>(type), | |
| 28 base::Time::FromInternalValue((int64)time), | |
| 29 data.Pass())); | |
| 30 } | |
| 31 | |
| 32 } // namespace performance_monitor | |
| OLD | NEW |