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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "content/shell/renderer/shell_render_view_observer.h" 5 #include "content/shell/renderer/shell_render_view_observer.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "content/public/renderer/render_thread.h"
8 #include "content/public/renderer/render_view.h" 9 #include "content/public/renderer/render_view.h"
9 #include "content/public/renderer/render_view_observer.h" 10 #include "content/public/renderer/render_view_observer.h"
11 #include "content/shell/common/shell_messages.h"
10 #include "content/shell/common/shell_switches.h" 12 #include "content/shell/common/shell_switches.h"
13 #include "content/shell/renderer/ipc_echo.h"
11 #include "third_party/WebKit/public/web/WebTestingSupport.h" 14 #include "third_party/WebKit/public/web/WebTestingSupport.h"
12 #include "third_party/WebKit/public/web/WebView.h" 15 #include "third_party/WebKit/public/web/WebView.h"
13 16
14 namespace content { 17 namespace content {
15 18
16 ShellRenderViewObserver::ShellRenderViewObserver(RenderView* render_view) 19 ShellRenderViewObserver::ShellRenderViewObserver(RenderView* render_view)
17 : RenderViewObserver(render_view) { 20 : RenderViewObserver(render_view) {
18 } 21 }
19 22
23 ShellRenderViewObserver::~ShellRenderViewObserver() {
24 }
25
20 void ShellRenderViewObserver::DidClearWindowObject( 26 void ShellRenderViewObserver::DidClearWindowObject(
21 blink::WebLocalFrame* frame) { 27 blink::WebLocalFrame* frame) {
22 if (CommandLine::ForCurrentProcess()->HasSwitch( 28 if (CommandLine::ForCurrentProcess()->HasSwitch(
23 switches::kExposeInternalsForTesting)) { 29 switches::kExposeInternalsForTesting)) {
24 blink::WebTestingSupport::injectInternalsObject(frame); 30 blink::WebTestingSupport::injectInternalsObject(frame);
25 } 31 }
32
33 if (CommandLine::ForCurrentProcess()->HasSwitch(
34 switches::kExposeIpcEcho)) {
35 RenderView* view = render_view();
36 if (!ipc_echo_)
37 ipc_echo_.reset(new IPCEcho(view->GetWebView()->mainFrame()->document(),
38 RenderThread::Get(), view->GetRoutingID()));
39 ipc_echo_->Install(view->GetWebView()->mainFrame());
40 }
41 }
42
43 bool ShellRenderViewObserver::OnMessageReceived(const IPC::Message& message) {
44 bool handled = true;
45 IPC_BEGIN_MESSAGE_MAP(ShellRenderViewObserver, message)
46 IPC_MESSAGE_HANDLER(ShellViewMsg_EchoPong, OnEchoPong)
47 IPC_MESSAGE_UNHANDLED(handled = false)
48 IPC_END_MESSAGE_MAP()
49
50 return handled;
51 }
52
53 void ShellRenderViewObserver::OnEchoPong(int id, const std::string& body) {
54 ipc_echo_->DidRespondEcho(id, body.size());
26 } 55 }
27 56
28 } // namespace content 57 } // namespace content
OLDNEW
« 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