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

Unified Diff: chrome/test/chromedriver/chrome/web_view_impl.cc

Issue 275193003: [ChromeDriver] Expose CPU Profiling DevTools API into chromeWebDriver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing web_view_stub method signatuer Created 6 years, 7 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/chrome/web_view_impl.h ('k') | chrome/test/chromedriver/window_commands.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/chromedriver/chrome/web_view_impl.cc
diff --git a/chrome/test/chromedriver/chrome/web_view_impl.cc b/chrome/test/chromedriver/chrome/web_view_impl.cc
index 052ceb45b8fe886bbe7d2d459ca5a78d468b63da..4403e89bbd10bdd04893480619fe52d247ccfea3 100644
--- a/chrome/test/chromedriver/chrome/web_view_impl.cc
+++ b/chrome/test/chromedriver/chrome/web_view_impl.cc
@@ -421,6 +421,67 @@ Status WebViewImpl::TakeHeapSnapshot(scoped_ptr<base::Value>* snapshot) {
return heap_snapshot_taker_->TakeSnapshot(snapshot);
}
+Status WebViewImpl::InitProfileInternal() {
+ base::DictionaryValue params;
+
+ // TODO: Remove Debugger.enable after Chrome 36 stable is released.
+ Status status_debug = client_->SendCommand("Debugger.enable", params);
+
+ if (status_debug.IsError())
+ return status_debug;
+
+ Status status_profiler = client_->SendCommand("Profiler.enable", params);
+
+ if (status_profiler.IsError()) {
+ Status status_debugger = client_->SendCommand("Debugger.disable", params);
+ if (status_debugger.IsError())
+ return status_debugger;
+
+ return status_profiler;
+ }
+
+ return Status(kOk);
+}
+
+Status WebViewImpl::StopProfileInternal() {
+ base::DictionaryValue params;
+ Status status_debug = client_->SendCommand("Debugger.disable", params);
+ Status status_profiler = client_->SendCommand("Profiler.disable", params);
+
+ if (status_debug.IsError())
+ return status_debug;
+ else if (status_profiler.IsError())
+ return status_profiler;
+
+ return Status(kOk);
+}
+
+Status WebViewImpl::StartProfile() {
+ Status status_init = InitProfileInternal();
+
+ if (status_init.IsError())
+ return status_init;
+
+ base::DictionaryValue params;
+ return client_->SendCommand("Profiler.start", params);
+}
+
+Status WebViewImpl::EndProfile(scoped_ptr<base::Value>* profile_data) {
+ base::DictionaryValue params;
+ scoped_ptr<base::DictionaryValue> profile_result;
+
+ Status status = client_->SendCommandAndGetResult(
+ "Profiler.stop", params, &profile_result);
+
+ if (status.IsError()) {
+ Status disable_profile_status = StopProfileInternal();
+ return disable_profile_status;
+ }
+
+ *profile_data = profile_result.PassAs<base::Value>();
+ return status;
+}
+
Status WebViewImpl::CallAsyncFunctionInternal(const std::string& frame,
const std::string& function,
const base::ListValue& args,
« no previous file with comments | « chrome/test/chromedriver/chrome/web_view_impl.h ('k') | chrome/test/chromedriver/window_commands.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698