OLD | NEW |
---|---|
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/renderer/pepper/pepper_in_process_router.h" | 5 #include "content/renderer/pepper/pepper_in_process_router.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "content/public/renderer/render_thread.h" | 9 #include "content/public/renderer/render_thread.h" |
10 #include "content/public/renderer/render_view.h" | 10 #include "content/public/renderer/render_view.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 // the message. | 103 // the message. |
104 if (resource) | 104 if (resource) |
105 resource->OnReplyReceived(reply_params, nested_msg); | 105 resource->OnReplyReceived(reply_params, nested_msg); |
106 return true; | 106 return true; |
107 } | 107 } |
108 | 108 |
109 bool PepperInProcessRouter::SendToHost(IPC::Message* msg) { | 109 bool PepperInProcessRouter::SendToHost(IPC::Message* msg) { |
110 scoped_ptr<IPC::Message> message(msg); | 110 scoped_ptr<IPC::Message> message(msg); |
111 | 111 |
112 if (!message->is_sync()) { | 112 if (!message->is_sync()) { |
113 bool result = host_impl_->GetPpapiHost()->OnMessageReceived(*message); | 113 // Dispatch host messages from the message loop. |
114 DCHECK(result) << "The message was not handled by the host."; | 114 base::MessageLoop::current()->PostTask( |
dmichael (off chromium)
2013/09/10 18:34:35
Wow, we should have been doing this from the very
| |
115 FROM_HERE, | |
116 base::Bind(&PepperInProcessRouter::DispatchHostMsg, | |
117 weak_factory_.GetWeakPtr(), | |
118 base::Owned(message.release()))); | |
115 return true; | 119 return true; |
116 } | 120 } |
117 | 121 |
118 pending_message_id_ = IPC::SyncMessage::GetMessageId(*message); | 122 pending_message_id_ = IPC::SyncMessage::GetMessageId(*message); |
119 reply_deserializer_.reset( | 123 reply_deserializer_.reset( |
120 static_cast<IPC::SyncMessage*>(message.get())->GetReplyDeserializer()); | 124 static_cast<IPC::SyncMessage*>(message.get())->GetReplyDeserializer()); |
121 reply_result_ = false; | 125 reply_result_ = false; |
122 | 126 |
123 bool result = host_impl_->GetPpapiHost()->OnMessageReceived(*message); | 127 bool result = host_impl_->GetPpapiHost()->OnMessageReceived(*message); |
124 DCHECK(result) << "The message was not handled by the host."; | 128 DCHECK(result) << "The message was not handled by the host."; |
(...skipping 14 matching lines...) Expand all Loading... | |
139 // Dispatch plugin messages from the message loop. | 143 // Dispatch plugin messages from the message loop. |
140 base::MessageLoop::current()->PostTask( | 144 base::MessageLoop::current()->PostTask( |
141 FROM_HERE, | 145 FROM_HERE, |
142 base::Bind(&PepperInProcessRouter::DispatchPluginMsg, | 146 base::Bind(&PepperInProcessRouter::DispatchPluginMsg, |
143 weak_factory_.GetWeakPtr(), | 147 weak_factory_.GetWeakPtr(), |
144 base::Owned(message.release()))); | 148 base::Owned(message.release()))); |
145 } | 149 } |
146 return true; | 150 return true; |
147 } | 151 } |
148 | 152 |
153 void PepperInProcessRouter::DispatchHostMsg(IPC::Message* msg) { | |
154 bool handled = host_impl_->GetPpapiHost()->OnMessageReceived(*msg); | |
155 DCHECK(handled); | |
156 } | |
157 | |
149 void PepperInProcessRouter::DispatchPluginMsg(IPC::Message* msg) { | 158 void PepperInProcessRouter::DispatchPluginMsg(IPC::Message* msg) { |
150 bool handled = OnPluginMsgReceived(*msg); | 159 bool handled = OnPluginMsgReceived(*msg); |
151 DCHECK(handled); | 160 DCHECK(handled); |
152 } | 161 } |
153 | 162 |
154 bool PepperInProcessRouter::SendToBrowser(IPC::Message *msg) { | 163 bool PepperInProcessRouter::SendToBrowser(IPC::Message *msg) { |
155 return RenderThread::Get()->Send(msg); | 164 return RenderThread::Get()->Send(msg); |
156 } | 165 } |
157 | 166 |
158 } // namespace content | 167 } // namespace content |
OLD | NEW |