OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_PLUGIN_LOADER_H_ |
| 6 #define CONTENT_BROWSER_PLUGIN_LOADER_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/memory/ref_counted.h" |
| 11 #include "content/browser/plugin_service.h" |
| 12 #include "content/browser/utility_process_host.h" |
| 13 |
| 14 namespace base { |
| 15 class MessageLoopProxy; |
| 16 } |
| 17 |
| 18 namespace webkit { |
| 19 struct WebPluginInfo; |
| 20 } |
| 21 |
| 22 // Utility child process client that manages the IPC for loading plugins out of |
| 23 // process. |
| 24 class PluginLoader : public UtilityProcessHost::Client { |
| 25 public: |
| 26 PluginLoader(); |
| 27 virtual ~PluginLoader() OVERRIDE; |
| 28 |
| 29 // Meant to be called on the IO thread. Will invoke the callback on the target |
| 30 // loop when the plugins have been loaded. |
| 31 void LoadPlugins(base::MessageLoopProxy* target_loop, |
| 32 const PluginService::GetPluginsCallback& callback); |
| 33 |
| 34 // UtilityProcessHost::Client implementation: |
| 35 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 36 virtual void OnProcessCrashed(int exit_code) OVERRIDE; |
| 37 |
| 38 private: |
| 39 struct PendingCallback { |
| 40 PendingCallback(scoped_refptr<base::MessageLoopProxy> loop, |
| 41 const PluginService::GetPluginsCallback& callback); |
| 42 ~PendingCallback(); |
| 43 |
| 44 scoped_refptr<base::MessageLoopProxy> target_loop; |
| 45 PluginService::GetPluginsCallback callback; |
| 46 }; |
| 47 |
| 48 void StartLoadingIfNecessary(); |
| 49 |
| 50 void OnGotPlugins(const std::vector<webkit::WebPluginInfo>& plugins); |
| 51 |
| 52 UtilityProcessHost* process_host_; |
| 53 std::vector<PendingCallback> callbacks_; |
| 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(PluginLoader); |
| 56 }; |
| 57 |
| 58 #endif // CONTENT_BROWSER_PLUGIN_LOADER_H_ |
OLD | NEW |