Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: chrome/test/chromedriver/performance_logger.h

Issue 2743013002: Add webdriver endpoint to send custom debugger commands (Closed)
Patch Set: New DevToolsEventsLogger Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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_PERFORMANCE_LOGGER_H_ 5 #ifndef CHROME_TEST_CHROMEDRIVER_PERFORMANCE_LOGGER_H_
6 #define CHROME_TEST_CHROMEDRIVER_PERFORMANCE_LOGGER_H_ 6 #define CHROME_TEST_CHROMEDRIVER_PERFORMANCE_LOGGER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "chrome/test/chromedriver/base_logger.h"
12 #include "chrome/test/chromedriver/capabilities.h" 13 #include "chrome/test/chromedriver/capabilities.h"
13 #include "chrome/test/chromedriver/chrome/devtools_event_listener.h" 14 #include "chrome/test/chromedriver/chrome/devtools_event_listener.h"
14 #include "chrome/test/chromedriver/command_listener.h" 15 #include "chrome/test/chromedriver/command_listener.h"
15 16
16 class Log; 17 class Log;
17 struct Session; 18 struct Session;
18 19
19 // Translates DevTools profiler events into Log messages with info level. 20 // Translates DevTools profiler events into Log messages with info level.
20 // 21 //
21 // The message is a JSON string of the following structure: 22 // The message is a JSON string of the following structure:
22 // { 23 // {
23 // "webview": <originating WebView ID>, 24 // "webview": <originating WebView ID>,
24 // "message": { "method": "...", "params": { ... }} // DevTools message. 25 // "message": { "method": "...", "params": { ... }} // DevTools message.
25 // } 26 // }
26 // 27 //
27 // Also translates buffered trace events into Log messages of info level with 28 // Also translates buffered trace events into Log messages of info level with
28 // the same structure if tracing categories are specified. 29 // the same structure if tracing categories are specified.
29 30
30 class PerformanceLogger : public DevToolsEventListener, public CommandListener { 31 class PerformanceLogger : public BaseLogger,
32 public DevToolsEventListener,
33 public CommandListener {
31 public: 34 public:
32 // Creates a |PerformanceLogger| with default preferences that creates entries 35 // Creates a |PerformanceLogger| with default preferences that creates entries
33 // in the given Log object. The log is owned elsewhere and must not be null. 36 // in the given Log object. The log is owned elsewhere and must not be null.
34 PerformanceLogger(Log* log, const Session* session); 37 PerformanceLogger(Log* log, const Session* session);
35 38
36 // Creates a |PerformanceLogger| with specific preferences. 39 // Creates a |PerformanceLogger| with specific preferences.
37 PerformanceLogger(Log* log, 40 PerformanceLogger(Log* log,
38 const Session* session, 41 const Session* session,
39 const PerfLoggingPrefs& prefs); 42 const PerfLoggingPrefs& prefs);
40 43
41 // PerformanceLogger subscribes to browser-wide |DevToolsClient| for tracing. 44 // PerformanceLogger subscribes to browser-wide |DevToolsClient| for tracing.
42 bool subscribes_to_browser() override; 45 bool subscribes_to_browser() override;
43 46
44 // For browser-wide client: enables tracing if trace categories are specified, 47 // For browser-wide client: enables tracing if trace categories are specified,
45 // sets |browser_client_|. For other clients: calls EnableInspectorDomains. 48 // sets |browser_client_|. For other clients: calls EnableInspectorDomains.
46 Status OnConnected(DevToolsClient* client) override; 49 Status OnConnected(DevToolsClient* client) override;
47 50
48 // Calls HandleInspectorEvents or HandleTraceEvents depending on client type. 51 // Calls HandleInspectorEvents or HandleTraceEvents depending on client type.
49 Status OnEvent(DevToolsClient* client, 52 Status OnEvent(DevToolsClient* client,
50 const std::string& method, 53 const std::string& method,
51 const base::DictionaryValue& params) override; 54 const base::DictionaryValue& params) override;
52 55
53 // Before whitelisted commands, if tracing enabled, calls CollectTraceEvents. 56 // Before whitelisted commands, if tracing enabled, calls CollectTraceEvents.
54 Status BeforeCommand(const std::string& command_name) override; 57 Status BeforeCommand(const std::string& command_name) override;
55 58
56 private: 59 private:
57 void AddLogEntry(Log::Level level,
58 const std::string& webview,
59 const std::string& method,
60 const base::DictionaryValue& params);
61
62 void AddLogEntry(const std::string& webview,
63 const std::string& method,
64 const base::DictionaryValue& params);
65
66 // Enables Network, Page and Timeline domains according to |PerfLoggingPrefs|. 60 // Enables Network, Page and Timeline domains according to |PerfLoggingPrefs|.
67 Status EnableInspectorDomains(DevToolsClient* client); 61 Status EnableInspectorDomains(DevToolsClient* client);
68 62
69 // Logs Network, Page, and Timeline events. 63 // Logs Network, Page, and Timeline events.
70 Status HandleInspectorEvents(DevToolsClient* client, 64 Status HandleInspectorEvents(DevToolsClient* client,
71 const std::string& method, 65 const std::string& method,
72 const base::DictionaryValue& params); 66 const base::DictionaryValue& params);
73 67
74 // Logs trace events and monitors trace buffer usage. 68 // Logs trace events and monitors trace buffer usage.
75 Status HandleTraceEvents(DevToolsClient* client, 69 Status HandleTraceEvents(DevToolsClient* client,
76 const std::string& method, 70 const std::string& method,
77 const base::DictionaryValue& params); 71 const base::DictionaryValue& params);
78 72
79 bool ShouldReportTracingError(); 73 bool ShouldReportTracingError();
80 Status StartTrace(); // Must not call before browser-wide client connects. 74 Status StartTrace(); // Must not call before browser-wide client connects.
81 Status CollectTraceEvents(); // Ditto. 75 Status CollectTraceEvents(); // Ditto.
82 Status IsTraceDone(bool* trace_done) const; // True if trace is not buffering. 76 Status IsTraceDone(bool* trace_done) const; // True if trace is not buffering.
83 77
84 Log* log_; // The log where to create entries.
85 const Session* session_; 78 const Session* session_;
86 PerfLoggingPrefs prefs_; 79 PerfLoggingPrefs prefs_;
87 DevToolsClient* browser_client_; // Pointer to browser-wide |DevToolsClient|. 80 DevToolsClient* browser_client_; // Pointer to browser-wide |DevToolsClient|.
88 bool trace_buffering_; // True unless trace stopped and all events received. 81 bool trace_buffering_; // True unless trace stopped and all events received.
89 82
90 DISALLOW_COPY_AND_ASSIGN(PerformanceLogger); 83 DISALLOW_COPY_AND_ASSIGN(PerformanceLogger);
91 }; 84 };
92 85
93 #endif // CHROME_TEST_CHROMEDRIVER_PERFORMANCE_LOGGER_H_ 86 #endif // CHROME_TEST_CHROMEDRIVER_PERFORMANCE_LOGGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698