| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/shell/renderer/ipc_echo.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "content/shell/common/shell_messages.h" | |
| 9 #include "ipc/ipc_sender.h" | |
| 10 #include "third_party/WebKit/public/web/WebDOMCustomEvent.h" | |
| 11 #include "third_party/WebKit/public/web/WebDOMEvent.h" | |
| 12 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" | |
| 13 | |
| 14 namespace content { | |
| 15 | |
| 16 IPCEcho::IPCEcho(blink::WebDocument document, | |
| 17 IPC::Sender* sender, | |
| 18 int routing_id) | |
| 19 : document_(document), sender_(sender), routing_id_(routing_id), | |
| 20 last_echo_id_(0) { | |
| 21 } | |
| 22 | |
| 23 void IPCEcho::RequestEcho(int id, int size) { | |
| 24 sender_->Send(new ShellViewHostMsg_EchoPing( | |
| 25 routing_id_, id, std::string(size, '*'))); | |
| 26 } | |
| 27 | |
| 28 void IPCEcho::DidRespondEcho(int id, int size) { | |
| 29 last_echo_id_ = id; | |
| 30 last_echo_size_ = size; | |
| 31 blink::WebString eventName = blink::WebString::fromUTF8("CustomEvent"); | |
| 32 blink::WebString eventType = blink::WebString::fromUTF8("pong"); | |
| 33 blink::WebDOMEvent event = document_.createEvent(eventName); | |
| 34 event.to<blink::WebDOMCustomEvent>().initCustomEvent( | |
| 35 eventType, false, false, blink::WebSerializedScriptValue()); | |
| 36 document_.dispatchEvent(event); | |
| 37 } | |
| 38 | |
| 39 } // namespace content | |
| OLD | NEW |