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

Side by Side Diff: content/renderer/pepper/pepper_in_process_router.cc

Issue 23688004: Change the PepperInProcessRouter to defer resource destruction messages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment explaining fix. Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « content/renderer/pepper/pepper_in_process_router.h ('k') | no next file » | 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/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
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 // If this is a resource destroyed message, post a task to dispatch it.
114 DCHECK(result) << "The message was not handled by the host."; 114 // Dispatching it synchronously can cause the host to re-enter the proxy
115 return true; 115 // code while we're still in the resource destructor, leading to a crash.
116 // http://crbug.com/276368.
117 // This won't cause message reordering problems because the resource
118 // destroyed message is always the last one sent for a resource.
119 if (message->type() == PpapiHostMsg_ResourceDestroyed::ID) {
120 base::MessageLoop::current()->PostTask(
121 FROM_HERE,
122 base::Bind(&PepperInProcessRouter::DispatchHostMsg,
123 weak_factory_.GetWeakPtr(),
124 base::Owned(message.release())));
125 return true;
126 } else {
127 bool result = host_impl_->GetPpapiHost()->OnMessageReceived(*message);
128 DCHECK(result) << "The message was not handled by the host.";
129 return true;
130 }
116 } 131 }
117 132
118 pending_message_id_ = IPC::SyncMessage::GetMessageId(*message); 133 pending_message_id_ = IPC::SyncMessage::GetMessageId(*message);
119 reply_deserializer_.reset( 134 reply_deserializer_.reset(
120 static_cast<IPC::SyncMessage*>(message.get())->GetReplyDeserializer()); 135 static_cast<IPC::SyncMessage*>(message.get())->GetReplyDeserializer());
121 reply_result_ = false; 136 reply_result_ = false;
122 137
123 bool result = host_impl_->GetPpapiHost()->OnMessageReceived(*message); 138 bool result = host_impl_->GetPpapiHost()->OnMessageReceived(*message);
124 DCHECK(result) << "The message was not handled by the host."; 139 DCHECK(result) << "The message was not handled by the host.";
125 140
(...skipping 13 matching lines...) Expand all
139 // Dispatch plugin messages from the message loop. 154 // Dispatch plugin messages from the message loop.
140 base::MessageLoop::current()->PostTask( 155 base::MessageLoop::current()->PostTask(
141 FROM_HERE, 156 FROM_HERE,
142 base::Bind(&PepperInProcessRouter::DispatchPluginMsg, 157 base::Bind(&PepperInProcessRouter::DispatchPluginMsg,
143 weak_factory_.GetWeakPtr(), 158 weak_factory_.GetWeakPtr(),
144 base::Owned(message.release()))); 159 base::Owned(message.release())));
145 } 160 }
146 return true; 161 return true;
147 } 162 }
148 163
164 void PepperInProcessRouter::DispatchHostMsg(IPC::Message* msg) {
165 bool handled = host_impl_->GetPpapiHost()->OnMessageReceived(*msg);
166 DCHECK(handled);
167 }
168
149 void PepperInProcessRouter::DispatchPluginMsg(IPC::Message* msg) { 169 void PepperInProcessRouter::DispatchPluginMsg(IPC::Message* msg) {
150 bool handled = OnPluginMsgReceived(*msg); 170 bool handled = OnPluginMsgReceived(*msg);
151 DCHECK(handled); 171 DCHECK(handled);
152 } 172 }
153 173
154 bool PepperInProcessRouter::SendToBrowser(IPC::Message *msg) { 174 bool PepperInProcessRouter::SendToBrowser(IPC::Message *msg) {
155 return RenderThread::Get()->Send(msg); 175 return RenderThread::Get()->Send(msg);
156 } 176 }
157 177
158 } // namespace content 178 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_in_process_router.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698