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

Unified Diff: content/shell/renderer/shell_render_view_observer.cc

Issue 478483005: Add IPC benchmarking API to Blink TestRunner (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Landing 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
Index: content/shell/renderer/shell_render_view_observer.cc
diff --git a/content/shell/renderer/shell_render_view_observer.cc b/content/shell/renderer/shell_render_view_observer.cc
index 3ef6cbf9ee39319188bae780658af1a4548f3e5d..17e61d419998705807f913d4ed94b6f373fcb43b 100644
--- a/content/shell/renderer/shell_render_view_observer.cc
+++ b/content/shell/renderer/shell_render_view_observer.cc
@@ -5,9 +5,12 @@
#include "content/shell/renderer/shell_render_view_observer.h"
#include "base/command_line.h"
+#include "content/public/renderer/render_thread.h"
#include "content/public/renderer/render_view.h"
#include "content/public/renderer/render_view_observer.h"
+#include "content/shell/common/shell_messages.h"
#include "content/shell/common/shell_switches.h"
+#include "content/shell/renderer/ipc_echo.h"
#include "third_party/WebKit/public/web/WebTestingSupport.h"
#include "third_party/WebKit/public/web/WebView.h"
@@ -17,12 +20,38 @@ ShellRenderViewObserver::ShellRenderViewObserver(RenderView* render_view)
: RenderViewObserver(render_view) {
}
+ShellRenderViewObserver::~ShellRenderViewObserver() {
+}
+
void ShellRenderViewObserver::DidClearWindowObject(
blink::WebLocalFrame* frame) {
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kExposeInternalsForTesting)) {
blink::WebTestingSupport::injectInternalsObject(frame);
}
+
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kExposeIpcEcho)) {
+ RenderView* view = render_view();
+ if (!ipc_echo_)
+ ipc_echo_.reset(new IPCEcho(view->GetWebView()->mainFrame()->document(),
+ RenderThread::Get(), view->GetRoutingID()));
+ ipc_echo_->Install(view->GetWebView()->mainFrame());
+ }
+}
+
+bool ShellRenderViewObserver::OnMessageReceived(const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(ShellRenderViewObserver, message)
+ IPC_MESSAGE_HANDLER(ShellViewMsg_EchoPong, OnEchoPong)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+
+ return handled;
+}
+
+void ShellRenderViewObserver::OnEchoPong(int id, const std::string& body) {
+ ipc_echo_->DidRespondEcho(id, body.size());
}
} // namespace content
« no previous file with comments | « content/shell/renderer/shell_render_view_observer.h ('k') | content/shell/renderer/test_runner/test_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698