Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / test / chromedriver / performance_logger.h
1 // Copyright 2014 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_TEST_CHROMEDRIVER_PERFORMANCE_LOGGER_H_
6 #define CHROME_TEST_CHROMEDRIVER_PERFORMANCE_LOGGER_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "chrome/test/chromedriver/capabilities.h"
13 #include "chrome/test/chromedriver/chrome/devtools_event_listener.h"
14 #include "chrome/test/chromedriver/command_listener.h"
15
16 class Log;
17
18 // Translates DevTools profiler events into Log messages with info level.
19 //
20 // The message is a JSON string of the following structure:
21 // {
22 //    "webview": <originating WebView ID>,
23 //    "message": { "method": "...", "params": { ... }}  // DevTools message.
24 // }
25 class PerformanceLogger : public DevToolsEventListener, public CommandListener {
26  public:
27   // Creates a |PerformanceLogger| with default preferences that creates entries
28   // in the given Log object. The log is owned elsewhere and must not be null.
29   explicit PerformanceLogger(Log* log);
30
31   // Creates a |PerformanceLogger| with specific preferences.
32   PerformanceLogger(Log* log, const PerfLoggingPrefs& prefs);
33
34   // Enables Page,Network,Timeline events for client, which must not be null.
35   virtual Status OnConnected(DevToolsClient* client) OVERRIDE;
36   // Translates an event into a log entry.
37   virtual Status OnEvent(DevToolsClient* client,
38                          const std::string& method,
39                          const base::DictionaryValue& params) OVERRIDE;
40
41   virtual Status BeforeCommand(const std::string& command_name) OVERRIDE;
42
43   // PerformanceLogger subscribes to browser-wide |DevToolsClient| for tracing.
44   virtual bool subscribes_to_browser() OVERRIDE;
45
46  private:
47   Log* log_;  // The log where to create entries.
48   PerfLoggingPrefs prefs_;
49
50   DISALLOW_COPY_AND_ASSIGN(PerformanceLogger);
51 };
52
53 #endif  // CHROME_TEST_CHROMEDRIVER_PERFORMANCE_LOGGER_H_