| 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" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 void AddMappingForNPObjectOwner(int route_id, struct _NPP* owner); | 48 void AddMappingForNPObjectOwner(int route_id, struct _NPP* owner); |
| 49 void SetDefaultNPObjectOwner(struct _NPP* owner); | 49 void SetDefaultNPObjectOwner(struct _NPP* owner); |
| 50 void RemoveMappingForNPObjectOwner(int route_id); | 50 void RemoveMappingForNPObjectOwner(int route_id); |
| 51 | 51 |
| 52 NPObject* GetExistingNPObjectProxy(int route_id); | 52 NPObject* GetExistingNPObjectProxy(int route_id); |
| 53 int GetExistingRouteForNPObjectStub(NPObject* npobject); | 53 int GetExistingRouteForNPObjectStub(NPObject* npobject); |
| 54 struct _NPP* GetExistingNPObjectOwner(int route_id); | 54 struct _NPP* GetExistingNPObjectOwner(int route_id); |
| 55 int GetExistingRouteForNPObjectOwner(struct _NPP* owner); | 55 int GetExistingRouteForNPObjectOwner(struct _NPP* owner); |
| 56 | 56 |
| 57 // IPC::Sender implementation: | 57 // IPC::Sender implementation: |
| 58 virtual bool Send(IPC::Message* msg) override; | 58 bool Send(IPC::Message* msg) override; |
| 59 | 59 |
| 60 base::ProcessId peer_pid() { return channel_->GetPeerPID(); } | 60 base::ProcessId peer_pid() { return channel_->GetPeerPID(); } |
| 61 IPC::ChannelHandle channel_handle() const { return channel_handle_; } | 61 IPC::ChannelHandle channel_handle() const { return channel_handle_; } |
| 62 | 62 |
| 63 // Returns the number of open NPObject channels in this process. | 63 // Returns the number of open NPObject channels in this process. |
| 64 static int Count(); | 64 static int Count(); |
| 65 | 65 |
| 66 // Returns a new route id. | 66 // Returns a new route id. |
| 67 virtual int GenerateRouteID() = 0; | 67 virtual int GenerateRouteID() = 0; |
| 68 | 68 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 85 // Returns the event that's set when a call to the renderer causes a modal | 85 // Returns the event that's set when a call to the renderer causes a modal |
| 86 // dialog to come up. The default implementation returns NULL. Derived | 86 // dialog to come up. The default implementation returns NULL. Derived |
| 87 // classes should override this method if this functionality is required. | 87 // classes should override this method if this functionality is required. |
| 88 virtual base::WaitableEvent* GetModalDialogEvent(int render_view_id); | 88 virtual base::WaitableEvent* GetModalDialogEvent(int render_view_id); |
| 89 | 89 |
| 90 protected: | 90 protected: |
| 91 typedef NPChannelBase* (*ChannelFactory)(); | 91 typedef NPChannelBase* (*ChannelFactory)(); |
| 92 | 92 |
| 93 friend class base::RefCountedThreadSafe<NPChannelBase>; | 93 friend class base::RefCountedThreadSafe<NPChannelBase>; |
| 94 | 94 |
| 95 virtual ~NPChannelBase(); | 95 ~NPChannelBase() override; |
| 96 | 96 |
| 97 // Returns a NPChannelBase derived object for the given channel name. | 97 // Returns a NPChannelBase derived object for the given channel name. |
| 98 // If an existing channel exists returns that object, otherwise creates a | 98 // If an existing channel exists returns that object, otherwise creates a |
| 99 // new one. Even though on creation the object is refcounted, each caller | 99 // 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 | 100 // 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. | 101 // on the channel and its ref count is 0, the object deletes itself. |
| 102 static NPChannelBase* GetChannel( | 102 static NPChannelBase* GetChannel( |
| 103 const IPC::ChannelHandle& channel_handle, IPC::Channel::Mode mode, | 103 const IPC::ChannelHandle& channel_handle, IPC::Channel::Mode mode, |
| 104 ChannelFactory factory, base::MessageLoopProxy* ipc_message_loop, | 104 ChannelFactory factory, base::MessageLoopProxy* ipc_message_loop, |
| 105 bool create_pipe_now, base::WaitableEvent* shutdown_event); | 105 bool create_pipe_now, base::WaitableEvent* shutdown_event); |
| 106 | 106 |
| 107 // Sends a message to all instances. | 107 // Sends a message to all instances. |
| 108 static void Broadcast(IPC::Message* message); | 108 static void Broadcast(IPC::Message* message); |
| 109 | 109 |
| 110 // Called on the worker thread | 110 // Called on the worker thread |
| 111 NPChannelBase(); | 111 NPChannelBase(); |
| 112 | 112 |
| 113 virtual void CleanUp() { } | 113 virtual void CleanUp() { } |
| 114 | 114 |
| 115 // Implemented by derived classes to handle control messages | 115 // Implemented by derived classes to handle control messages |
| 116 virtual bool OnControlMessageReceived(const IPC::Message& msg); | 116 virtual bool OnControlMessageReceived(const IPC::Message& msg); |
| 117 | 117 |
| 118 // IPC::Listener implementation: | 118 // IPC::Listener implementation: |
| 119 virtual bool OnMessageReceived(const IPC::Message& msg) override; | 119 bool OnMessageReceived(const IPC::Message& msg) override; |
| 120 virtual void OnChannelConnected(int32 peer_pid) override; | 120 void OnChannelConnected(int32 peer_pid) override; |
| 121 virtual void OnChannelError() override; | 121 void OnChannelError() override; |
| 122 | 122 |
| 123 void set_send_unblocking_only_during_unblock_dispatch() { | 123 void set_send_unblocking_only_during_unblock_dispatch() { |
| 124 send_unblocking_only_during_unblock_dispatch_ = true; | 124 send_unblocking_only_during_unblock_dispatch_ = true; |
| 125 } | 125 } |
| 126 | 126 |
| 127 virtual bool Init(base::MessageLoopProxy* ipc_message_loop, | 127 virtual bool Init(base::MessageLoopProxy* ipc_message_loop, |
| 128 bool create_pipe_now, | 128 bool create_pipe_now, |
| 129 base::WaitableEvent* shutdown_event); | 129 base::WaitableEvent* shutdown_event); |
| 130 | 130 |
| 131 scoped_ptr<IPC::SyncChannel> channel_; | 131 scoped_ptr<IPC::SyncChannel> channel_; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 // have the unblock flag set, since they could be followed by a sync message | 186 // have the unblock flag set, since they could be followed by a sync message |
| 187 // that won't get dispatched until the call to the renderer is complete. | 187 // that won't get dispatched until the call to the renderer is complete. |
| 188 bool send_unblocking_only_during_unblock_dispatch_; | 188 bool send_unblocking_only_during_unblock_dispatch_; |
| 189 | 189 |
| 190 DISALLOW_COPY_AND_ASSIGN(NPChannelBase); | 190 DISALLOW_COPY_AND_ASSIGN(NPChannelBase); |
| 191 }; | 191 }; |
| 192 | 192 |
| 193 } // namespace content | 193 } // namespace content |
| 194 | 194 |
| 195 #endif // CONTENT_CHILD_NPAPI_NP_CHANNEL_BASE_H_ | 195 #endif // CONTENT_CHILD_NPAPI_NP_CHANNEL_BASE_H_ |
| OLD | NEW |