| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_BROWSER_PPAPI_PLUGIN_PROCESS_HOST_H_ | 5 #ifndef CHROME_BROWSER_PPAPI_PLUGIN_PROCESS_HOST_H_ |
| 6 #define CHROME_BROWSER_PPAPI_PLUGIN_PROCESS_HOST_H_ | 6 #define CHROME_BROWSER_PPAPI_PLUGIN_PROCESS_HOST_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <queue> | 9 // TODO(jam): remove this file when all files have been converted. |
| 10 | 10 #include "content/browser/ppapi_plugin_process_host.h" |
| 11 #include "base/basictypes.h" | |
| 12 #include "base/file_path.h" | |
| 13 #include "chrome/browser/browser_child_process_host.h" | |
| 14 | |
| 15 class PpapiPluginProcessHost : public BrowserChildProcessHost { | |
| 16 public: | |
| 17 class Client { | |
| 18 public: | |
| 19 // Gets the information about the renderer that's requesting the channel. | |
| 20 virtual void GetChannelInfo(base::ProcessHandle* renderer_handle, | |
| 21 int* renderer_id) = 0; | |
| 22 | |
| 23 // Called when the channel is asynchronously opened to the plugin or on | |
| 24 // error. On error, the parameters should be: | |
| 25 // base::kNullProcessHandle | |
| 26 // IPC::ChannelHandle() | |
| 27 virtual void OnChannelOpened(base::ProcessHandle plugin_process_handle, | |
| 28 const IPC::ChannelHandle& channel_handle) = 0; | |
| 29 }; | |
| 30 | |
| 31 // You must call init before doing anything else. | |
| 32 explicit PpapiPluginProcessHost(); | |
| 33 virtual ~PpapiPluginProcessHost(); | |
| 34 | |
| 35 // Actually launches the process with the given plugin path. Returns true | |
| 36 // on success (the process was spawned). | |
| 37 bool Init(const FilePath& path); | |
| 38 | |
| 39 // Opens a new channel to the plugin. The client will be notified when the | |
| 40 // channel is ready or if there's an error. | |
| 41 void OpenChannelToPlugin(Client* client); | |
| 42 | |
| 43 const FilePath& plugin_path() const { return plugin_path_; } | |
| 44 | |
| 45 // The client pointer must remain valid until its callback is issued. | |
| 46 | |
| 47 private: | |
| 48 | |
| 49 void RequestPluginChannel(Client* client); | |
| 50 | |
| 51 virtual bool CanShutdown(); | |
| 52 virtual void OnProcessLaunched(); | |
| 53 | |
| 54 virtual bool OnMessageReceived(const IPC::Message& msg); | |
| 55 virtual void OnChannelConnected(int32 peer_pid); | |
| 56 virtual void OnChannelError(); | |
| 57 | |
| 58 void CancelRequests(); | |
| 59 | |
| 60 // IPC message handlers. | |
| 61 void OnRendererPluginChannelCreated(const IPC::ChannelHandle& handle); | |
| 62 | |
| 63 // Channel requests that we are waiting to send to the plugin process once | |
| 64 // the channel is opened. | |
| 65 std::vector<Client*> pending_requests_; | |
| 66 | |
| 67 // Channel requests that we have already sent to the plugin process, but | |
| 68 // haven't heard back about yet. | |
| 69 std::queue<Client*> sent_requests_; | |
| 70 | |
| 71 // Path to the plugin library. | |
| 72 FilePath plugin_path_; | |
| 73 | |
| 74 DISALLOW_COPY_AND_ASSIGN(PpapiPluginProcessHost); | |
| 75 }; | |
| 76 | 11 |
| 77 #endif // CHROME_BROWSER_PPAPI_PLUGIN_PROCESS_HOST_H_ | 12 #endif // CHROME_BROWSER_PPAPI_PLUGIN_PROCESS_HOST_H_ |
| 78 | 13 |
| OLD | NEW |