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

Side by Side Diff: chrome/plugin/plugin_channel_base.cc

Issue 402072: Merge 32397 - Only clears the unblock flag on sync IPCs during other sync dis... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/249/src/
Patch Set: Created 11 years, 1 month 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 | « chrome/plugin/plugin_channel_base.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/plugin/plugin_channel_base.h" 5 #include "chrome/plugin/plugin_channel_base.h"
6 6
7 #include "base/hash_tables.h" 7 #include "base/hash_tables.h"
8 #include "chrome/common/child_process.h" 8 #include "chrome/common/child_process.h"
9 #include "ipc/ipc_sync_message.h" 9 #include "ipc/ipc_sync_message.h"
10 10
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 iter->second->Send(new IPC::Message(*message)); 53 iter->second->Send(new IPC::Message(*message));
54 } 54 }
55 delete message; 55 delete message;
56 } 56 }
57 57
58 PluginChannelBase::PluginChannelBase() 58 PluginChannelBase::PluginChannelBase()
59 : plugin_count_(0), 59 : plugin_count_(0),
60 peer_pid_(0), 60 peer_pid_(0),
61 in_remove_route_(false), 61 in_remove_route_(false),
62 channel_valid_(false), 62 channel_valid_(false),
63 in_dispatch_(0), 63 in_sync_dispatch_(0),
64 send_unblocking_only_during_dispatch_(false) { 64 send_unblocking_only_during_sync_dispatch_(false) {
65 } 65 }
66 66
67 PluginChannelBase::~PluginChannelBase() { 67 PluginChannelBase::~PluginChannelBase() {
68 } 68 }
69 69
70 void PluginChannelBase::CleanupChannels() { 70 void PluginChannelBase::CleanupChannels() {
71 // Make a copy of the references as we can't iterate the map since items will 71 // Make a copy of the references as we can't iterate the map since items will
72 // be removed from it as we clean them up. 72 // be removed from it as we clean them up.
73 std::vector<scoped_refptr<PluginChannelBase> > channels; 73 std::vector<scoped_refptr<PluginChannelBase> > channels;
74 for (PluginChannelMap::const_iterator iter = g_plugin_channels_.begin(); 74 for (PluginChannelMap::const_iterator iter = g_plugin_channels_.begin();
(...skipping 18 matching lines...) Expand all
93 channel_valid_ = true; 93 channel_valid_ = true;
94 return true; 94 return true;
95 } 95 }
96 96
97 bool PluginChannelBase::Send(IPC::Message* message) { 97 bool PluginChannelBase::Send(IPC::Message* message) {
98 if (!channel_.get()) { 98 if (!channel_.get()) {
99 delete message; 99 delete message;
100 return false; 100 return false;
101 } 101 }
102 102
103 if (send_unblocking_only_during_dispatch_ && in_dispatch_ == 0 && 103 if (send_unblocking_only_during_sync_dispatch_ && in_sync_dispatch_ == 0 &&
104 message->is_sync()) { 104 message->is_sync()) {
105 message->set_unblock(false); 105 message->set_unblock(false);
106 } 106 }
107 107
108 return channel_->Send(message); 108 return channel_->Send(message);
109 } 109 }
110 110
111 int PluginChannelBase::Count() { 111 int PluginChannelBase::Count() {
112 return static_cast<int>(g_plugin_channels_.size()); 112 return static_cast<int>(g_plugin_channels_.size());
113 } 113 }
114 114
115 void PluginChannelBase::OnMessageReceived(const IPC::Message& message) { 115 void PluginChannelBase::OnMessageReceived(const IPC::Message& message) {
116 // This call might cause us to be deleted, so keep an extra reference to 116 // This call might cause us to be deleted, so keep an extra reference to
117 // ourself so that we can send the reply and decrement back in_dispatch_. 117 // ourself so that we can send the reply and decrement back in_dispatch_.
118 scoped_refptr<PluginChannelBase> me(this); 118 scoped_refptr<PluginChannelBase> me(this);
119 119
120 in_dispatch_++; 120 if (message.is_sync())
121 in_sync_dispatch_++;
121 if (message.routing_id() == MSG_ROUTING_CONTROL) { 122 if (message.routing_id() == MSG_ROUTING_CONTROL) {
122 OnControlMessageReceived(message); 123 OnControlMessageReceived(message);
123 } else { 124 } else {
124 bool routed = router_.RouteMessage(message); 125 bool routed = router_.RouteMessage(message);
125 if (!routed && message.is_sync()) { 126 if (!routed && message.is_sync()) {
126 // The listener has gone away, so we must respond or else the caller will 127 // The listener has gone away, so we must respond or else the caller will
127 // hang waiting for a reply. 128 // hang waiting for a reply.
128 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&message); 129 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&message);
129 reply->set_reply_error(); 130 reply->set_reply_error();
130 Send(reply); 131 Send(reply);
131 } 132 }
132 } 133 }
133 in_dispatch_--; 134 if (message.is_sync())
135 in_sync_dispatch_--;
134 } 136 }
135 137
136 void PluginChannelBase::OnChannelConnected(int32 peer_pid) { 138 void PluginChannelBase::OnChannelConnected(int32 peer_pid) {
137 peer_pid_ = peer_pid; 139 peer_pid_ = peer_pid;
138 } 140 }
139 141
140 void PluginChannelBase::AddRoute(int route_id, 142 void PluginChannelBase::AddRoute(int route_id,
141 IPC::Channel::Listener* listener, 143 IPC::Channel::Listener* listener,
142 bool npobject) { 144 bool npobject) {
143 if (npobject) { 145 if (npobject) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 209
208 void PluginChannelBase::OnChannelError() { 210 void PluginChannelBase::OnChannelError() {
209 #if defined(OS_POSIX) 211 #if defined(OS_POSIX)
210 if (channel_valid()) { 212 if (channel_valid()) {
211 IPC::RemoveAndCloseChannelSocket(channel_name()); 213 IPC::RemoveAndCloseChannelSocket(channel_name());
212 } 214 }
213 #endif 215 #endif
214 channel_valid_ = false; 216 channel_valid_ = false;
215 } 217 }
216 218
217 void PluginChannelBase::SendUnblockingOnlyDuringDispatch() { 219 void PluginChannelBase::SendUnblockingOnlyDuringSyncDispatch() {
218 send_unblocking_only_during_dispatch_ = true; 220 send_unblocking_only_during_sync_dispatch_ = true;
219 } 221 }
OLDNEW
« no previous file with comments | « chrome/plugin/plugin_channel_base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698