OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef CONTENT_CHILD_NPAPI_NP_CHANNEL_BASE_H_ | 5 #ifndef CONTENT_CHILD_NPAPI_NP_CHANNEL_BASE_H_ |
6 #define CONTENT_CHILD_NPAPI_NP_CHANNEL_BASE_H_ | 6 #define CONTENT_CHILD_NPAPI_NP_CHANNEL_BASE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/process/process.h" | 14 #include "base/process/process.h" |
15 #include "content/child/npapi/npobject_base.h" | 15 #include "content/child/npapi/npobject_base.h" |
16 #include "content/common/message_router.h" | 16 #include "content/common/message_router.h" |
17 #include "ipc/ipc_channel_handle.h" | 17 #include "ipc/ipc_channel_handle.h" |
18 #include "ipc/ipc_sync_channel.h" | 18 #include "ipc/ipc_sync_channel.h" |
19 | 19 |
20 namespace base { | 20 namespace base { |
21 class SingleThreadTaskRunner; | 21 class SingleThreadTaskRunner; |
22 } | 22 } |
23 | 23 |
| 24 namespace IPC { |
| 25 class AttachmentBroker; |
| 26 } |
| 27 |
24 namespace content { | 28 namespace content { |
25 | 29 |
26 // Encapsulates an IPC channel between a renderer and another process. Used to | 30 // Encapsulates an IPC channel between a renderer and another process. Used to |
27 // proxy access to NP objects. | 31 // proxy access to NP objects. |
28 class NPChannelBase : public IPC::Listener, | 32 class NPChannelBase : public IPC::Listener, |
29 public IPC::Sender, | 33 public IPC::Sender, |
30 public base::RefCountedThreadSafe<NPChannelBase> { | 34 public base::RefCountedThreadSafe<NPChannelBase> { |
31 public: | 35 public: |
32 | 36 |
33 // WebPlugin[Delegate] call these on construction and destruction to setup | 37 // WebPlugin[Delegate] call these on construction and destruction to setup |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 // If an existing channel exists returns that object, otherwise creates a | 102 // If an existing channel exists returns that object, otherwise creates a |
99 // new one. Even though on creation the object is refcounted, each caller | 103 // new one. Even though on creation the object is refcounted, each caller |
100 // must still ref count the returned value. When there are no more routes | 104 // must still ref count the returned value. When there are no more routes |
101 // on the channel and its ref count is 0, the object deletes itself. | 105 // on the channel and its ref count is 0, the object deletes itself. |
102 static NPChannelBase* GetChannel( | 106 static NPChannelBase* GetChannel( |
103 const IPC::ChannelHandle& channel_handle, | 107 const IPC::ChannelHandle& channel_handle, |
104 IPC::Channel::Mode mode, | 108 IPC::Channel::Mode mode, |
105 ChannelFactory factory, | 109 ChannelFactory factory, |
106 base::SingleThreadTaskRunner* ipc_task_runner, | 110 base::SingleThreadTaskRunner* ipc_task_runner, |
107 bool create_pipe_now, | 111 bool create_pipe_now, |
108 base::WaitableEvent* shutdown_event); | 112 base::WaitableEvent* shutdown_event, |
| 113 IPC::AttachmentBroker* broker); |
109 | 114 |
110 // Sends a message to all instances. | 115 // Sends a message to all instances. |
111 static void Broadcast(IPC::Message* message); | 116 static void Broadcast(IPC::Message* message); |
112 | 117 |
113 // Called on the worker thread | 118 // Called on the worker thread |
114 NPChannelBase(); | 119 NPChannelBase(); |
115 | 120 |
116 virtual void CleanUp() { } | 121 virtual void CleanUp() { } |
117 | 122 |
118 // Implemented by derived classes to handle control messages | 123 // Implemented by derived classes to handle control messages |
119 virtual bool OnControlMessageReceived(const IPC::Message& msg); | 124 virtual bool OnControlMessageReceived(const IPC::Message& msg); |
120 | 125 |
121 // IPC::Listener implementation: | 126 // IPC::Listener implementation: |
122 bool OnMessageReceived(const IPC::Message& msg) override; | 127 bool OnMessageReceived(const IPC::Message& msg) override; |
123 void OnChannelConnected(int32 peer_pid) override; | 128 void OnChannelConnected(int32 peer_pid) override; |
124 void OnChannelError() override; | 129 void OnChannelError() override; |
125 | 130 |
126 void set_send_unblocking_only_during_unblock_dispatch() { | 131 void set_send_unblocking_only_during_unblock_dispatch() { |
127 send_unblocking_only_during_unblock_dispatch_ = true; | 132 send_unblocking_only_during_unblock_dispatch_ = true; |
128 } | 133 } |
129 | 134 |
130 virtual bool Init(base::SingleThreadTaskRunner* ipc_task_runner, | 135 virtual bool Init(base::SingleThreadTaskRunner* ipc_task_runner, |
131 bool create_pipe_now, | 136 bool create_pipe_now, |
132 base::WaitableEvent* shutdown_event); | 137 base::WaitableEvent* shutdown_event, |
| 138 IPC::AttachmentBroker* broker); |
133 | 139 |
134 scoped_ptr<IPC::SyncChannel> channel_; | 140 scoped_ptr<IPC::SyncChannel> channel_; |
135 IPC::ChannelHandle channel_handle_; | 141 IPC::ChannelHandle channel_handle_; |
136 | 142 |
137 private: | 143 private: |
138 IPC::Channel::Mode mode_; | 144 IPC::Channel::Mode mode_; |
139 // This tracks the number of routes registered without an NPObject. It's used | 145 // This tracks the number of routes registered without an NPObject. It's used |
140 // to manage the lifetime of this object. See comment for AddRoute() and | 146 // to manage the lifetime of this object. See comment for AddRoute() and |
141 // RemoveRoute(). | 147 // RemoveRoute(). |
142 int non_npobject_count_; | 148 int non_npobject_count_; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 // have the unblock flag set, since they could be followed by a sync message | 195 // have the unblock flag set, since they could be followed by a sync message |
190 // that won't get dispatched until the call to the renderer is complete. | 196 // that won't get dispatched until the call to the renderer is complete. |
191 bool send_unblocking_only_during_unblock_dispatch_; | 197 bool send_unblocking_only_during_unblock_dispatch_; |
192 | 198 |
193 DISALLOW_COPY_AND_ASSIGN(NPChannelBase); | 199 DISALLOW_COPY_AND_ASSIGN(NPChannelBase); |
194 }; | 200 }; |
195 | 201 |
196 } // namespace content | 202 } // namespace content |
197 | 203 |
198 #endif // CONTENT_CHILD_NPAPI_NP_CHANNEL_BASE_H_ | 204 #endif // CONTENT_CHILD_NPAPI_NP_CHANNEL_BASE_H_ |
OLD | NEW |