Index: chrome/renderer/guest_view/chrome_guest_view_container_dispatcher.cc |
diff --git a/chrome/renderer/guest_view/chrome_guest_view_container_dispatcher.cc b/chrome/renderer/guest_view/chrome_guest_view_container_dispatcher.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9dd5200fb1fac0371443a3e0574b1f85c2612b8f |
--- /dev/null |
+++ b/chrome/renderer/guest_view/chrome_guest_view_container_dispatcher.cc |
@@ -0,0 +1,57 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/renderer/guest_view/chrome_guest_view_container_dispatcher.h" |
+ |
+#include "components/framelet/common/framelet_messages.h" |
+#include "content/public/renderer/render_frame.h" |
+#include "content/public/renderer/render_thread.h" |
+#include "content/public/renderer/render_view.h" |
+#include "ipc/ipc_message.h" |
+#include "ipc/ipc_message_macros.h" |
+#include "third_party/WebKit/public/web/WebKit.h" |
+#include "third_party/WebKit/public/web/WebLocalFrame.h" |
+#include "v8/include/v8.h" |
+ |
+namespace chrome { |
+ |
+ChromeGuestViewContainerDispatcher::ChromeGuestViewContainerDispatcher() {} |
+ |
+ChromeGuestViewContainerDispatcher::~ChromeGuestViewContainerDispatcher() {} |
+ |
+bool ChromeGuestViewContainerDispatcher::HandlesMessage( |
+ const IPC::Message& message) { |
+ return GuestViewContainerDispatcherBase::HandlesMessage(message) || |
+ (IPC_MESSAGE_CLASS(message) == ChromeGuestViewMsgStart); |
+} |
+ |
+bool ChromeGuestViewContainerDispatcher::OnControlMessageReceived( |
+ const IPC::Message& message) { |
+ bool handled = true; |
+ IPC_BEGIN_MESSAGE_MAP(ChromeGuestViewContainerDispatcher, message) |
+ IPC_MESSAGE_HANDLER(ChromeGuestViewMsg_RequestHeapSize, OnRequestHeapSize); |
+ IPC_MESSAGE_UNHANDLED( |
+ handled = GuestViewContainerDispatcherBase::OnControlMessageReceived( |
+ message)); |
+ IPC_END_MESSAGE_MAP(); |
+ return handled; |
+} |
+ |
+void ChromeGuestViewContainerDispatcher::OnRequestHeapSize(int routing_id) { |
+ size_t heap_size = 0; |
+ content::RenderView* render_view = |
+ content::RenderView::FromRoutingID(routing_id); |
+ if (render_view) { |
+ v8::Isolate* isolate = blink::mainThreadIsolate(); |
+ v8::HandleScope handle_scope(isolate); |
+ v8::Local<v8::Context> context = render_view->GetMainRenderFrame() |
+ ->GetWebFrame() |
+ ->mainWorldScriptContext(); |
+ heap_size = context->EstimatedSize(); |
+ } |
+ content::RenderThread::Get()->Send( |
+ new ChromeGuestViewHostMsg_HeapSize(routing_id, heap_size)); |
+} |
+ |
+} // namespace chrome |