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.
5 #ifndef CHROME_BROWSER_PERFORMANCE_MONITOR_EVENT_H_
6 #define CHROME_BROWSER_PERFORMANCE_MONITOR_EVENT_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/time/time.h"
10 #include "base/values.h"
12 #include "chrome/browser/performance_monitor/event_type.h"
14 namespace performance_monitor
{
16 const char* EventTypeToString(EventType event_type
);
18 // The wrapper class for the JSON-generated event classes for the performance
19 // monitor. This class is used so we can pass around events in a single class,
20 // rather than having a variety of different types (since JSON does not
21 // currently support inheritance). Since the class will occasionally need to
22 // be compared against other events, we construct it with type and time. Other
23 // information should not be needed commonly, and is stored in a JSON-generated
27 Event(const EventType
& type
,
28 const base::Time
& time
,
29 scoped_ptr
<base::DictionaryValue
> data
);
32 // Construct an event from the given DictionaryValue; takes ownership of
34 static scoped_ptr
<Event
> FromValue(scoped_ptr
<base::DictionaryValue
> data
);
37 EventType
type() const { return type_
; }
38 base::Time
time() const { return time_
; }
39 base::DictionaryValue
* data() const { return data_
.get(); }
43 // The type of the event.
45 // The time at which the event was recorded.
47 // The full JSON-generated value representing the information of the event;
48 // these data are described in chrome/browser/performance_monitor/events.json.
49 scoped_ptr
<base::DictionaryValue
> data_
;
52 } // namespace performance_monitor
54 #endif // CHROME_BROWSER_PERFORMANCE_MONITOR_EVENT_H_