Upstream version 10.38.222.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / performance_monitor / performance_monitor_util.h
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 #ifndef CHROME_BROWSER_PERFORMANCE_MONITOR_PERFORMANCE_MONITOR_UTIL_H_
6 #define CHROME_BROWSER_PERFORMANCE_MONITOR_PERFORMANCE_MONITOR_UTIL_H_
7
8 #include "base/callback.h"
9 #include "base/time/time.h"
10 #include "base/tracked_objects.h"
11 #include "chrome/browser/performance_monitor/database.h"
12 #include "chrome/browser/performance_monitor/event.h"
13 #include "chrome/browser/performance_monitor/metric.h"
14 #include "chrome/common/extensions/extension_constants.h"
15
16 namespace performance_monitor {
17 namespace util {
18
19 // Posts |request| to the performance monitor database's sequenced thread. On
20 // completion |reply| is posted to the thread that called
21 // PostTaskToDatabaseThreadAndReply.
22 bool PostTaskToDatabaseThreadAndReply(
23     const tracked_objects::Location& from_here,
24     const base::Closure& request,
25     const base::Closure& reply);
26
27 // These are a collection of methods designed to create an event to store the
28 // pertinent information, given all the fields. Please use these methods to
29 // create any PerformanceMonitor events, as this will ensure strong-typing
30 // guards that performance_monitor::Event() will not.
31 scoped_ptr<Event> CreateExtensionEvent(const EventType type,
32                                        const base::Time& time,
33                                        const std::string& id,
34                                        const std::string& name,
35                                        const std::string& url,
36                                        const int location,
37                                        const std::string& version,
38                                        const std::string& description);
39
40 scoped_ptr<Event> CreateRendererFailureEvent(const base::Time& time,
41                                              const EventType& type,
42                                              const std::string& url);
43
44 scoped_ptr<Event> CreateUncleanExitEvent(const base::Time& time,
45                                          const std::string& profile_name);
46
47 scoped_ptr<Event> CreateChromeUpdateEvent(const base::Time& time,
48                                           const std::string& previous_version,
49                                           const std::string& current_version);
50
51 }  // namespace util
52 }  // namespace performance_monitor
53
54 #endif  // CHROME_BROWSER_PERFORMANCE_MONITOR_PERFORMANCE_MONITOR_UTIL_H_