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

Side by Side Diff: content/browser/browser_plugin/browser_plugin_message_filter.cc

Issue 1008613002: favor DCHECK_CURRENTLY_ON for better logs in content/browser/[a-d]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « content/browser/browser_main_loop.cc ('k') | content/browser/cocoa/system_hotkey_helper_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/browser_plugin/browser_plugin_message_filter.h" 5 #include "content/browser/browser_plugin/browser_plugin_message_filter.h"
6 6
7 #include "base/supports_user_data.h" 7 #include "base/supports_user_data.h"
8 #include "content/browser/browser_plugin/browser_plugin_guest.h" 8 #include "content/browser/browser_plugin/browser_plugin_guest.h"
9 #include "content/browser/gpu/gpu_process_host.h" 9 #include "content/browser/gpu/gpu_process_host.h"
10 #include "content/browser/web_contents/web_contents_impl.h" 10 #include "content/browser/web_contents/web_contents_impl.h"
11 #include "content/common/browser_plugin/browser_plugin_constants.h" 11 #include "content/common/browser_plugin/browser_plugin_constants.h"
12 #include "content/common/browser_plugin/browser_plugin_messages.h" 12 #include "content/common/browser_plugin/browser_plugin_messages.h"
13 #include "content/common/view_messages.h" 13 #include "content/common/view_messages.h"
14 #include "content/public/browser/browser_context.h" 14 #include "content/public/browser/browser_context.h"
15 #include "content/public/browser/browser_plugin_guest_manager.h" 15 #include "content/public/browser/browser_plugin_guest_manager.h"
16 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
17 #include "content/public/browser/render_view_host.h" 17 #include "content/public/browser/render_view_host.h"
18 18
19 namespace content { 19 namespace content {
20 20
21 BrowserPluginMessageFilter::BrowserPluginMessageFilter(int render_process_id) 21 BrowserPluginMessageFilter::BrowserPluginMessageFilter(int render_process_id)
22 : BrowserMessageFilter(BrowserPluginMsgStart), 22 : BrowserMessageFilter(BrowserPluginMsgStart),
23 render_process_id_(render_process_id) { 23 render_process_id_(render_process_id) {
24 } 24 }
25 25
26 BrowserPluginMessageFilter::~BrowserPluginMessageFilter() { 26 BrowserPluginMessageFilter::~BrowserPluginMessageFilter() {
27 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 27 DCHECK_CURRENTLY_ON(BrowserThread::IO);
28 } 28 }
29 29
30 bool BrowserPluginMessageFilter::OnMessageReceived( 30 bool BrowserPluginMessageFilter::OnMessageReceived(
31 const IPC::Message& message) { 31 const IPC::Message& message) {
32 // Any message requested by a BrowserPluginGuest should be routed through 32 // Any message requested by a BrowserPluginGuest should be routed through
33 // a BrowserPluginGuestManager. 33 // a BrowserPluginGuestManager.
34 if (BrowserPluginGuest::ShouldForwardToBrowserPluginGuest(message)) { 34 if (BrowserPluginGuest::ShouldForwardToBrowserPluginGuest(message)) {
35 ForwardMessageToGuest(message); 35 ForwardMessageToGuest(message);
36 // We always swallow messages destined for BrowserPluginGuest because we're 36 // We always swallow messages destined for BrowserPluginGuest because we're
37 // on the UI thread and fallback code is expected to be run on the IO 37 // on the UI thread and fallback code is expected to be run on the IO
38 // thread. 38 // thread.
39 return true; 39 return true;
40 } 40 }
41 return false; 41 return false;
42 } 42 }
43 43
44 void BrowserPluginMessageFilter::OnDestruct() const { 44 void BrowserPluginMessageFilter::OnDestruct() const {
45 BrowserThread::DeleteOnIOThread::Destruct(this); 45 BrowserThread::DeleteOnIOThread::Destruct(this);
46 } 46 }
47 47
48 void BrowserPluginMessageFilter::OverrideThreadForMessage( 48 void BrowserPluginMessageFilter::OverrideThreadForMessage(
49 const IPC::Message& message, BrowserThread::ID* thread) { 49 const IPC::Message& message, BrowserThread::ID* thread) {
50 if (BrowserPluginGuest::ShouldForwardToBrowserPluginGuest(message)) 50 if (BrowserPluginGuest::ShouldForwardToBrowserPluginGuest(message))
51 *thread = BrowserThread::UI; 51 *thread = BrowserThread::UI;
52 } 52 }
53 53
54 void BrowserPluginMessageFilter::ForwardMessageToGuest( 54 void BrowserPluginMessageFilter::ForwardMessageToGuest(
55 const IPC::Message& message) { 55 const IPC::Message& message) {
56 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 56 DCHECK_CURRENTLY_ON(BrowserThread::UI);
57 auto rph = RenderProcessHost::FromID(render_process_id_); 57 auto rph = RenderProcessHost::FromID(render_process_id_);
58 if (!rph) 58 if (!rph)
59 return; 59 return;
60 60
61 int browser_plugin_instance_id = browser_plugin::kInstanceIDNone; 61 int browser_plugin_instance_id = browser_plugin::kInstanceIDNone;
62 // All allowed messages must have instance_id as their first parameter. 62 // All allowed messages must have instance_id as their first parameter.
63 PickleIterator iter(message); 63 PickleIterator iter(message);
64 bool success = iter.ReadInt(&browser_plugin_instance_id); 64 bool success = iter.ReadInt(&browser_plugin_instance_id);
65 DCHECK(success); 65 DCHECK(success);
66 66
67 WebContents* guest_web_contents = 67 WebContents* guest_web_contents =
68 rph->GetBrowserContext()->GetGuestManager() 68 rph->GetBrowserContext()->GetGuestManager()
69 ->GetGuestByInstanceID(render_process_id_, 69 ->GetGuestByInstanceID(render_process_id_,
70 browser_plugin_instance_id); 70 browser_plugin_instance_id);
71 if (!guest_web_contents) 71 if (!guest_web_contents)
72 return; 72 return;
73 73
74 static_cast<WebContentsImpl*>(guest_web_contents) 74 static_cast<WebContentsImpl*>(guest_web_contents)
75 ->GetBrowserPluginGuest() 75 ->GetBrowserPluginGuest()
76 ->OnMessageReceivedFromEmbedder(message); 76 ->OnMessageReceivedFromEmbedder(message);
77 } 77 }
78 78
79 } // namespace content 79 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_main_loop.cc ('k') | content/browser/cocoa/system_hotkey_helper_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698