| OLD | NEW |
| 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 #ifndef CHROME_PLUGIN_PLUGIN_CHANNEL_H_ | 5 #ifndef CHROME_PLUGIN_PLUGIN_CHANNEL_H_ |
| 6 #define CHROME_PLUGIN_PLUGIN_CHANNEL_H_ | 6 #define CHROME_PLUGIN_PLUGIN_CHANNEL_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 #include "base/scoped_handle.h" | 9 #include "base/scoped_handle.h" |
| 10 #include "chrome/plugin/plugin_channel_base.h" | 10 #include "chrome/plugin/plugin_channel_base.h" |
| 11 #include "chrome/plugin/webplugin_delegate_stub.h" | 11 #include "chrome/plugin/webplugin_delegate_stub.h" |
| 12 | 12 |
| 13 // Encapsulates an IPC channel between the plugin process and one renderer | 13 // Encapsulates an IPC channel between the plugin process and one renderer |
| 14 // process. On the renderer side there's a corresponding PluginChannelHost. | 14 // process. On the renderer side there's a corresponding PluginChannelHost. |
| 15 class PluginChannel : public PluginChannelBase { | 15 class PluginChannel : public PluginChannelBase { |
| 16 public: | 16 public: |
| 17 // renderer_handle is the the handle to the renderer process requesting the | 17 static PluginChannel* GetPluginChannel(MessageLoop* ipc_message_loop); |
| 18 // channel. The handle has to be valid in the context of the plugin process. | |
| 19 static PluginChannel* GetPluginChannel( | |
| 20 int process_id, HANDLE renderer_handle, MessageLoop* ipc_message_loop); | |
| 21 | 18 |
| 22 ~PluginChannel(); | 19 ~PluginChannel(); |
| 23 | 20 |
| 24 virtual bool Send(IPC::Message* msg); | 21 virtual bool Send(IPC::Message* msg); |
| 25 virtual void OnMessageReceived(const IPC::Message& message); | 22 virtual void OnMessageReceived(const IPC::Message& message); |
| 26 | 23 |
| 27 HANDLE renderer_handle() { return renderer_handle_.Get(); } | 24 HANDLE renderer_handle() { return renderer_handle_.Get(); } |
| 28 int GenerateRouteID(); | 25 int GenerateRouteID(); |
| 29 | 26 |
| 30 bool in_send() { return in_send_ != 0; } | 27 bool in_send() { return in_send_ != 0; } |
| 31 | 28 |
| 32 protected: | 29 protected: |
| 33 // IPC::Channel::Listener implementation: | 30 // IPC::Channel::Listener implementation: |
| 31 virtual void OnChannelConnected(int32 peer_pid); |
| 34 virtual void OnChannelError(); | 32 virtual void OnChannelError(); |
| 35 | 33 |
| 36 virtual void CleanUp(); | 34 virtual void CleanUp(); |
| 37 | 35 |
| 38 private: | 36 private: |
| 39 // Called on the plugin thread | 37 // Called on the plugin thread |
| 40 PluginChannel(); | 38 PluginChannel(); |
| 41 | 39 |
| 42 void OnControlMessageReceived(const IPC::Message& msg); | 40 void OnControlMessageReceived(const IPC::Message& msg); |
| 43 | 41 |
| 44 static PluginChannelBase* ClassFactory() { return new PluginChannel(); } | 42 static PluginChannelBase* ClassFactory() { return new PluginChannel(); } |
| 45 | 43 |
| 46 void OnCreateInstance(const std::string& mime_type, int* instance_id); | 44 void OnCreateInstance(const std::string& mime_type, int* instance_id); |
| 47 void OnDestroyInstance(int instance_id, IPC::Message* reply_msg); | 45 void OnDestroyInstance(int instance_id, IPC::Message* reply_msg); |
| 48 void OnGenerateRouteID(int* route_id); | 46 void OnGenerateRouteID(int* route_id); |
| 49 | 47 |
| 50 std::vector<scoped_refptr<WebPluginDelegateStub>> plugin_stubs_; | 48 std::vector<scoped_refptr<WebPluginDelegateStub>> plugin_stubs_; |
| 51 | 49 |
| 52 // Handle to the renderer process who is on the other side of the channel. | 50 // Handle to the renderer process who is on the other side of the channel. |
| 53 ScopedHandle renderer_handle_; | 51 ScopedHandle renderer_handle_; |
| 54 | 52 |
| 55 int in_send_; // Tracks if we're in a Send call. | 53 int in_send_; // Tracks if we're in a Send call. |
| 56 bool log_messages_; // True if we should log sent and received messages. | 54 bool log_messages_; // True if we should log sent and received messages. |
| 57 | 55 |
| 58 DISALLOW_EVIL_CONSTRUCTORS(PluginChannel); | 56 DISALLOW_EVIL_CONSTRUCTORS(PluginChannel); |
| 59 }; | 57 }; |
| 60 | 58 |
| 61 #endif // CHROME_PLUGIN_PLUGIN_CHANNEL_H_ | 59 #endif // CHROME_PLUGIN_PLUGIN_CHANNEL_H_ |
| OLD | NEW |