OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_TEST_CHROMEDRIVER_CHROME_PERFORMANCE_LOGGER_H_ | 5 #ifndef CHROME_TEST_CHROMEDRIVER_PERFORMANCE_LOGGER_H_ |
6 #define CHROME_TEST_CHROMEDRIVER_CHROME_PERFORMANCE_LOGGER_H_ | 6 #define CHROME_TEST_CHROMEDRIVER_PERFORMANCE_LOGGER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "chrome/test/chromedriver/chrome/devtools_event_listener.h" | 10 #include "chrome/test/chromedriver/chrome/devtools_event_listener.h" |
| 11 #include "chrome/test/chromedriver/command_listener.h" |
11 | 12 |
12 class Log; | 13 class Log; |
13 | 14 |
14 // Translates DevTools profiler events into Log messages with info level. | 15 // Translates DevTools profiler events into Log messages with info level. |
15 // | 16 // |
16 // The message is a JSON string of the following structure: | 17 // The message is a JSON string of the following structure: |
17 // { | 18 // { |
18 // "webview": <originating WebView ID>, | 19 // "webview": <originating WebView ID>, |
19 // "message": { "method": "...", "params": { ... }} // DevTools message. | 20 // "message": { "method": "...", "params": { ... }} // DevTools message. |
20 // } | 21 // } |
21 class PerformanceLogger : public DevToolsEventListener { | 22 class PerformanceLogger : public DevToolsEventListener, public CommandListener { |
22 public: | 23 public: |
23 // Creates a PerformanceLogger that creates entries in the given Log object. | 24 // Creates a PerformanceLogger that creates entries in the given Log object. |
24 // The log is owned elsewhere and must not be null. | 25 // The log is owned elsewhere and must not be null. |
25 explicit PerformanceLogger(Log* log); | 26 explicit PerformanceLogger(Log* log); |
26 | 27 |
27 // Enables Page,Network,Timeline events for client, which must not be null. | 28 // Enables Page,Network,Timeline events for client, which must not be null. |
28 virtual Status OnConnected(DevToolsClient* client) OVERRIDE; | 29 virtual Status OnConnected(DevToolsClient* client) OVERRIDE; |
29 // Translates an event into a log entry. | 30 // Translates an event into a log entry. |
30 virtual Status OnEvent(DevToolsClient* client, | 31 virtual Status OnEvent(DevToolsClient* client, |
31 const std::string& method, | 32 const std::string& method, |
32 const base::DictionaryValue& params) OVERRIDE; | 33 const base::DictionaryValue& params) OVERRIDE; |
33 | 34 |
| 35 virtual Status BeforeCommand(const std::string& command_name) OVERRIDE; |
| 36 |
34 private: | 37 private: |
35 Log* log_; // The log where to create entries. | 38 Log* log_; // The log where to create entries. |
36 | 39 |
37 DISALLOW_COPY_AND_ASSIGN(PerformanceLogger); | 40 DISALLOW_COPY_AND_ASSIGN(PerformanceLogger); |
38 }; | 41 }; |
39 | 42 |
40 #endif // CHROME_TEST_CHROMEDRIVER_CHROME_PERFORMANCE_LOGGER_H_ | 43 #endif // CHROME_TEST_CHROMEDRIVER_PERFORMANCE_LOGGER_H_ |
OLD | NEW |