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