OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <stack> | 7 #include <stack> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 message->set_unblock(false); | 133 message->set_unblock(false); |
134 } | 134 } |
135 | 135 |
136 return channel_->Send(message); | 136 return channel_->Send(message); |
137 } | 137 } |
138 | 138 |
139 int PluginChannelBase::Count() { | 139 int PluginChannelBase::Count() { |
140 return static_cast<int>(g_plugin_channels_.size()); | 140 return static_cast<int>(g_plugin_channels_.size()); |
141 } | 141 } |
142 | 142 |
143 void PluginChannelBase::OnMessageReceived(const IPC::Message& message) { | 143 bool PluginChannelBase::OnMessageReceived(const IPC::Message& message) { |
144 // This call might cause us to be deleted, so keep an extra reference to | 144 // This call might cause us to be deleted, so keep an extra reference to |
145 // ourself so that we can send the reply and decrement back in_dispatch_. | 145 // ourself so that we can send the reply and decrement back in_dispatch_. |
146 lazy_plugin_channel_stack_.Pointer()->push( | 146 lazy_plugin_channel_stack_.Pointer()->push( |
147 scoped_refptr<PluginChannelBase>(this)); | 147 scoped_refptr<PluginChannelBase>(this)); |
148 | 148 |
| 149 bool handled; |
149 if (message.should_unblock()) | 150 if (message.should_unblock()) |
150 in_unblock_dispatch_++; | 151 in_unblock_dispatch_++; |
151 if (message.routing_id() == MSG_ROUTING_CONTROL) { | 152 if (message.routing_id() == MSG_ROUTING_CONTROL) { |
152 OnControlMessageReceived(message); | 153 handled = OnControlMessageReceived(message); |
153 } else { | 154 } else { |
154 bool routed = router_.RouteMessage(message); | 155 handled = router_.RouteMessage(message); |
155 if (!routed && message.is_sync()) { | 156 if (!handled && message.is_sync()) { |
156 // The listener has gone away, so we must respond or else the caller will | 157 // The listener has gone away, so we must respond or else the caller will |
157 // hang waiting for a reply. | 158 // hang waiting for a reply. |
158 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&message); | 159 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&message); |
159 reply->set_reply_error(); | 160 reply->set_reply_error(); |
160 Send(reply); | 161 Send(reply); |
161 } | 162 } |
162 } | 163 } |
163 if (message.should_unblock()) | 164 if (message.should_unblock()) |
164 in_unblock_dispatch_--; | 165 in_unblock_dispatch_--; |
165 | 166 |
166 lazy_plugin_channel_stack_.Pointer()->pop(); | 167 lazy_plugin_channel_stack_.Pointer()->pop(); |
| 168 return handled; |
167 } | 169 } |
168 | 170 |
169 void PluginChannelBase::OnChannelConnected(int32 peer_pid) { | 171 void PluginChannelBase::OnChannelConnected(int32 peer_pid) { |
170 peer_pid_ = peer_pid; | 172 peer_pid_ = peer_pid; |
171 } | 173 } |
172 | 174 |
173 void PluginChannelBase::AddRoute(int route_id, | 175 void PluginChannelBase::AddRoute(int route_id, |
174 IPC::Channel::Listener* listener, | 176 IPC::Channel::Listener* listener, |
175 NPObjectBase* npobject) { | 177 NPObjectBase* npobject) { |
176 if (npobject) { | 178 if (npobject) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 if (iter->second == this) { | 223 if (iter->second == this) { |
222 g_plugin_channels_.erase(iter); | 224 g_plugin_channels_.erase(iter); |
223 return; | 225 return; |
224 } | 226 } |
225 } | 227 } |
226 | 228 |
227 NOTREACHED(); | 229 NOTREACHED(); |
228 } | 230 } |
229 } | 231 } |
230 | 232 |
231 void PluginChannelBase::OnControlMessageReceived(const IPC::Message& msg) { | 233 bool PluginChannelBase::OnControlMessageReceived(const IPC::Message& msg) { |
232 NOTREACHED() << | 234 NOTREACHED() << |
233 "should override in subclass if you care about control messages"; | 235 "should override in subclass if you care about control messages"; |
| 236 return false; |
234 } | 237 } |
235 | 238 |
236 void PluginChannelBase::OnChannelError() { | 239 void PluginChannelBase::OnChannelError() { |
237 channel_valid_ = false; | 240 channel_valid_ = false; |
238 } | 241 } |
OLD | NEW |