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, |