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.
5 #ifndef CHROME_TEST_CHROMEDRIVER_PERFORMANCE_LOGGER_H_
6 #define CHROME_TEST_CHROMEDRIVER_PERFORMANCE_LOGGER_H_
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"
18 // Translates DevTools profiler events into Log messages with info level.
20 // The message is a JSON string of the following structure:
22 // "webview": <originating WebView ID>,
23 // "message": { "method": "...", "params": { ... }} // DevTools message.
25 class PerformanceLogger : public DevToolsEventListener, public CommandListener {
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);
31 // Creates a |PerformanceLogger| with specific preferences.
32 PerformanceLogger(Log* log, const PerfLoggingPrefs& prefs);
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;
41 virtual Status BeforeCommand(const std::string& command_name) OVERRIDE;
43 // PerformanceLogger subscribes to browser-wide |DevToolsClient| for tracing.
44 virtual bool subscribes_to_browser() OVERRIDE;
47 Log* log_; // The log where to create entries.
48 PerfLoggingPrefs prefs_;
50 DISALLOW_COPY_AND_ASSIGN(PerformanceLogger);
53 #endif // CHROME_TEST_CHROMEDRIVER_PERFORMANCE_LOGGER_H_