Index: chrome/browser/guest_view/chrome_guest_view_message_filter.cc |
diff --git a/chrome/browser/guest_view/chrome_guest_view_message_filter.cc b/chrome/browser/guest_view/chrome_guest_view_message_filter.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1bc5b9fecb2df391621034d8450d69dcaad25dd3 |
--- /dev/null |
+++ b/chrome/browser/guest_view/chrome_guest_view_message_filter.cc |
@@ -0,0 +1,85 @@ |
+// 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/browser/guest_view/chrome_guest_view_message_filter.h" |
+ |
+#include "chrome/browser/guest_view/chrome_guest_view_manager_delegate.h" |
+#include "components/framelet/browser/framelet_guest.h" |
+#include "components/framelet/browser/framelet_memory_tracker.h" |
+#include "components/framelet/common/framelet_constants.h" |
+#include "components/framelet/common/framelet_messages.h" |
+#include "components/guest_view/browser/guest_view_manager.h" |
+#include "components/guest_view/common/guest_view_constants.h" |
+#include "content/public/browser/render_frame_host.h" |
+#include "content/public/browser/render_process_host.h" |
+#include "content/public/browser/web_contents.h" |
+#include "ipc/ipc_message_macros.h" |
+#include "ipc/ipc_message_start.h" |
+#include "ui/gfx/geometry/size.h" |
+ |
+namespace chrome { |
+ |
+namespace { |
+ |
+const uint32_t kFilteredGuestViewMessageClasses[] = { |
+ GuestViewMsgStart, |
+#if defined(ENABLE_EXTENSIONS) |
+ ExtensionsGuestViewMsgStart, |
+#endif |
+ ChromeGuestViewMsgStart}; |
+ |
+} // namespace |
+ |
+ChromeGuestViewMessageFilter::ChromeGuestViewMessageFilter( |
+ int render_process_id, |
+ content::BrowserContext* context) |
+ : GuestViewMessageFilterBase(kFilteredGuestViewMessageClasses, |
+ arraysize(kFilteredGuestViewMessageClasses), |
+ render_process_id, |
+ context) {} |
+ |
+ChromeGuestViewMessageFilter::~ChromeGuestViewMessageFilter() {} |
+ |
+guest_view::GuestViewManager* |
+ChromeGuestViewMessageFilter::GetOrCreateGuestViewManager() { |
+ auto manager = |
+ guest_view::GuestViewManager::FromBrowserContext(browser_context_); |
+ if (!manager) { |
+ manager = guest_view::GuestViewManager::CreateWithDelegate( |
+ browser_context_, |
+ make_scoped_ptr( |
+ ChromeGuestViewManagerDelegate::Create(browser_context_))); |
+ } |
+ return manager; |
+} |
+ |
+bool ChromeGuestViewMessageFilter::OnMessageReceived( |
+ const IPC::Message& message) { |
+ bool handled = true; |
+ IPC_BEGIN_MESSAGE_MAP(ChromeGuestViewMessageFilter, message) |
+ IPC_MESSAGE_HANDLER(ChromeGuestViewHostMsg_HeapSize, OnHeapSize); |
+ IPC_MESSAGE_UNHANDLED( |
+ handled = GuestViewMessageFilterBase::OnMessageReceived(message)); |
+ IPC_END_MESSAGE_MAP(); |
+ return handled; |
+} |
+ |
+void ChromeGuestViewMessageFilter::OverrideThreadForMessage( |
+ const IPC::Message& message, |
+ content::BrowserThread::ID* thread) { |
+ if (IPC_MESSAGE_CLASS(message) == ChromeGuestViewMsgStart) { |
+ *thread = content::BrowserThread::UI; |
+ return; |
+ } |
+ GuestViewMessageFilterBase::OverrideThreadForMessage(message, thread); |
+} |
+ |
+void ChromeGuestViewMessageFilter::OnHeapSize(int routing_id, int heap_size) { |
+ framelet::FrameletMemoryTracker::ClientID client_id(render_process_id_, |
+ routing_id); |
+ framelet::FrameletMemoryTracker::FromBrowserContext(browser_context_) |
+ ->ReportHeapSize(client_id, heap_size); |
+} |
+ |
+} // namespace chrome |