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 "content/plugin/plugin_channel_base.h" | 5 #include "content/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 11 matching lines...) Expand all Loading... |
22 | 22 |
23 static PluginChannelMap g_plugin_channels_; | 23 static PluginChannelMap g_plugin_channels_; |
24 | 24 |
25 static base::LazyInstance<std::stack<scoped_refptr<PluginChannelBase> > > | 25 static base::LazyInstance<std::stack<scoped_refptr<PluginChannelBase> > > |
26 lazy_plugin_channel_stack_(base::LINKER_INITIALIZED); | 26 lazy_plugin_channel_stack_(base::LINKER_INITIALIZED); |
27 | 27 |
28 static int next_pipe_id = 0; | 28 static int next_pipe_id = 0; |
29 | 29 |
30 PluginChannelBase* PluginChannelBase::GetChannel( | 30 PluginChannelBase* PluginChannelBase::GetChannel( |
31 const IPC::ChannelHandle& channel_handle, IPC::Channel::Mode mode, | 31 const IPC::ChannelHandle& channel_handle, IPC::Channel::Mode mode, |
32 PluginChannelFactory factory, MessageLoop* ipc_message_loop, | 32 PluginChannelFactory factory, base::MessageLoopProxy* ipc_message_loop, |
33 bool create_pipe_now) { | 33 bool create_pipe_now) { |
34 scoped_refptr<PluginChannelBase> channel; | 34 scoped_refptr<PluginChannelBase> channel; |
35 std::string channel_key = channel_handle.name; | 35 std::string channel_key = channel_handle.name; |
36 PluginChannelMap::const_iterator iter = g_plugin_channels_.find(channel_key); | 36 PluginChannelMap::const_iterator iter = g_plugin_channels_.find(channel_key); |
37 if (iter == g_plugin_channels_.end()) { | 37 if (iter == g_plugin_channels_.end()) { |
38 channel = factory(); | 38 channel = factory(); |
39 } else { | 39 } else { |
40 channel = iter->second; | 40 channel = iter->second; |
41 } | 41 } |
42 | 42 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 NPObjectBase* PluginChannelBase::GetNPObjectListenerForRoute(int route_id) { | 106 NPObjectBase* PluginChannelBase::GetNPObjectListenerForRoute(int route_id) { |
107 ListenerMap::iterator iter = npobject_listeners_.find(route_id); | 107 ListenerMap::iterator iter = npobject_listeners_.find(route_id); |
108 if (iter == npobject_listeners_.end()) { | 108 if (iter == npobject_listeners_.end()) { |
109 DLOG(WARNING) << "Invalid route id passed in:" << route_id; | 109 DLOG(WARNING) << "Invalid route id passed in:" << route_id; |
110 return NULL; | 110 return NULL; |
111 } | 111 } |
112 return iter->second; | 112 return iter->second; |
113 } | 113 } |
114 | 114 |
115 bool PluginChannelBase::Init(MessageLoop* ipc_message_loop, | 115 bool PluginChannelBase::Init(base::MessageLoopProxy* ipc_message_loop, |
116 bool create_pipe_now) { | 116 bool create_pipe_now) { |
117 channel_.reset(new IPC::SyncChannel( | 117 channel_.reset(new IPC::SyncChannel( |
118 channel_handle_, mode_, this, ipc_message_loop, create_pipe_now, | 118 channel_handle_, mode_, this, ipc_message_loop, create_pipe_now, |
119 ChildProcess::current()->GetShutDownEvent())); | 119 ChildProcess::current()->GetShutDownEvent())); |
120 channel_valid_ = true; | 120 channel_valid_ = true; |
121 return true; | 121 return true; |
122 } | 122 } |
123 | 123 |
124 bool PluginChannelBase::Send(IPC::Message* message) { | 124 bool PluginChannelBase::Send(IPC::Message* message) { |
125 if (!channel_.get()) { | 125 if (!channel_.get()) { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 | 232 |
233 bool PluginChannelBase::OnControlMessageReceived(const IPC::Message& msg) { | 233 bool PluginChannelBase::OnControlMessageReceived(const IPC::Message& msg) { |
234 NOTREACHED() << | 234 NOTREACHED() << |
235 "should override in subclass if you care about control messages"; | 235 "should override in subclass if you care about control messages"; |
236 return false; | 236 return false; |
237 } | 237 } |
238 | 238 |
239 void PluginChannelBase::OnChannelError() { | 239 void PluginChannelBase::OnChannelError() { |
240 channel_valid_ = false; | 240 channel_valid_ = false; |
241 } | 241 } |
OLD | NEW |