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

Unified Diff: chrome/test/chromedriver/performance_logger.h

Issue 454133003: [ChromeDriver] Implementing tracing support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing nits Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/chromedriver/logging_unittest.cc ('k') | chrome/test/chromedriver/performance_logger.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/chromedriver/performance_logger.h
diff --git a/chrome/test/chromedriver/performance_logger.h b/chrome/test/chromedriver/performance_logger.h
index f31687908453d686689f6e389099c45d76b89fed..4ce17ca1b681bfeee42affa23d106e955555e004 100644
--- a/chrome/test/chromedriver/performance_logger.h
+++ b/chrome/test/chromedriver/performance_logger.h
@@ -14,6 +14,7 @@
#include "chrome/test/chromedriver/command_listener.h"
class Log;
+struct Session;
// Translates DevTools profiler events into Log messages with info level.
//
@@ -22,30 +23,69 @@ class Log;
// "webview": <originating WebView ID>,
// "message": { "method": "...", "params": { ... }} // DevTools message.
// }
+//
+// Also translates buffered trace events into Log messages of info level with
+// the same structure if tracing categories are specified.
+
class PerformanceLogger : public DevToolsEventListener, public CommandListener {
public:
// Creates a |PerformanceLogger| with default preferences that creates entries
// in the given Log object. The log is owned elsewhere and must not be null.
- explicit PerformanceLogger(Log* log);
+ PerformanceLogger(Log* log, const Session* session);
// Creates a |PerformanceLogger| with specific preferences.
- PerformanceLogger(Log* log, const PerfLoggingPrefs& prefs);
+ PerformanceLogger(Log* log,
+ const Session* session,
+ const PerfLoggingPrefs& prefs);
+
+ // PerformanceLogger subscribes to browser-wide |DevToolsClient| for tracing.
+ virtual bool subscribes_to_browser() OVERRIDE;
- // Enables Page,Network,Timeline events for client, which must not be null.
+ // For browser-wide client: enables tracing if trace categories are specified,
+ // sets |browser_client_|. For other clients: calls EnableInspectorDomains.
virtual Status OnConnected(DevToolsClient* client) OVERRIDE;
- // Translates an event into a log entry.
+
+ // Calls HandleInspectorEvents or HandleTraceEvents depending on client type.
virtual Status OnEvent(DevToolsClient* client,
const std::string& method,
const base::DictionaryValue& params) OVERRIDE;
+ // Before whitelisted commands, if tracing enabled, calls CollectTraceEvents.
virtual Status BeforeCommand(const std::string& command_name) OVERRIDE;
- // PerformanceLogger subscribes to browser-wide |DevToolsClient| for tracing.
- virtual bool subscribes_to_browser() OVERRIDE;
-
private:
+ void AddLogEntry(Log::Level level,
+ const std::string& webview,
+ const std::string& method,
+ const base::DictionaryValue& params);
+
+ void AddLogEntry(const std::string& webview,
+ const std::string& method,
+ const base::DictionaryValue& params);
+
+ // Enables Network, Page and Timeline domains according to |PerfLoggingPrefs|.
+ Status EnableInspectorDomains(DevToolsClient* client);
+
+ // Logs Network, Page, and Timeline events.
+ Status HandleInspectorEvents(DevToolsClient* client,
+ const std::string& method,
+ const base::DictionaryValue& params);
+
+ // Logs trace events and monitors trace buffer usage.
+ Status HandleTraceEvents(DevToolsClient* client,
+ const std::string& method,
+ const base::DictionaryValue& params);
+
+ bool ShouldReportTracingError();
+ Status StartTrace(); // Must not call before browser-wide client connects.
+ Status CollectTraceEvents(); // Ditto.
+ Status IsTraceDone(bool* trace_done) const; // True if trace is not buffering.
+
Log* log_; // The log where to create entries.
+ const Session* session_;
PerfLoggingPrefs prefs_;
+ DevToolsClient* browser_client_; // Pointer to browser-wide |DevToolsClient|.
+ bool trace_buffering_; // True unless trace stopped and all events received.
DISALLOW_COPY_AND_ASSIGN(PerformanceLogger);
};
« no previous file with comments | « chrome/test/chromedriver/logging_unittest.cc ('k') | chrome/test/chromedriver/performance_logger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698