Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(703)

Side by Side Diff: content/browser/plugin_loader_posix.h

Issue 9317074: Create an API around UtilityProcessHost and use that from chrome. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_BROWSER_PLUGIN_LOADER_POSIX_H_ 5 #ifndef CONTENT_BROWSER_PLUGIN_LOADER_POSIX_H_
6 #define CONTENT_BROWSER_PLUGIN_LOADER_POSIX_H_ 6 #define CONTENT_BROWSER_PLUGIN_LOADER_POSIX_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
11 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
12 #include "base/time.h" 13 #include "base/time.h"
13 #include "content/browser/plugin_service_impl.h" 14 #include "content/browser/plugin_service_impl.h"
14 #include "content/browser/utility_process_host.h" 15 #include "content/public/browser/utility_process_host_client.h"
15 #include "ipc/ipc_message.h" 16 #include "ipc/ipc_message.h"
16 #include "webkit/plugins/webplugininfo.h" 17 #include "webkit/plugins/webplugininfo.h"
17 18
18 class FilePath;
19 class UtilityProcessHost;
20
21 namespace base { 19 namespace base {
22 class MessageLoopProxy; 20 class MessageLoopProxy;
23 } 21 }
24 22
23 namespace content {
24 class UtilityProcessHost;
25 }
26
25 // This class is responsible for managing the out-of-process plugin loading on 27 // This class is responsible for managing the out-of-process plugin loading on
26 // POSIX systems. It primarily lives on the IO thread, but has a brief stay on 28 // POSIX systems. It primarily lives on the IO thread, but has a brief stay on
27 // the FILE thread to iterate over plugin directories when it is first 29 // the FILE thread to iterate over plugin directories when it is first
28 // constructed. 30 // constructed.
29 // 31 //
30 // The following is the algorithm used to load plugins: 32 // The following is the algorithm used to load plugins:
31 // 1. This asks the PluginList for the list of all potential plugins to attempt 33 // 1. This asks the PluginList for the list of all potential plugins to attempt
32 // to load. This is referred to as the canonical list. 34 // to load. This is referred to as the canonical list.
33 // 2. The child process this hosts is forked and the canonical list is sent to 35 // 2. The child process this hosts is forked and the canonical list is sent to
34 // it. 36 // it.
35 // 3. The child process iterates over the canonical list, attempting to load 37 // 3. The child process iterates over the canonical list, attempting to load
36 // each plugin in the order specified by the list. It sends an IPC message 38 // each plugin in the order specified by the list. It sends an IPC message
37 // to the browser after each load, indicating success or failure. The two 39 // to the browser after each load, indicating success or failure. The two
38 // processes synchronize the position in the vector that will be used to 40 // processes synchronize the position in the vector that will be used to
39 // attempt to load the next plugin. 41 // attempt to load the next plugin.
40 // 4. If the child dies during this process, the host forks another child and 42 // 4. If the child dies during this process, the host forks another child and
41 // resumes loading at the position past the plugin that it just attempted to 43 // resumes loading at the position past the plugin that it just attempted to
42 // load, bypassing the problematic plugin. 44 // load, bypassing the problematic plugin.
43 // 5. This algorithm continues until the canonical list has been walked to the 45 // 5. This algorithm continues until the canonical list has been walked to the
44 // end, after which the list of loaded plugins is set on the PluginList and 46 // end, after which the list of loaded plugins is set on the PluginList and
45 // the completion callback is run. 47 // the completion callback is run.
46 class CONTENT_EXPORT PluginLoaderPosix : public UtilityProcessHost::Client, 48 class CONTENT_EXPORT PluginLoaderPosix
47 IPC::Message::Sender { 49 : public NON_EXPORTED_BASE(content::UtilityProcessHostClient),
50 public IPC::Message::Sender {
48 public: 51 public:
49 PluginLoaderPosix(); 52 PluginLoaderPosix();
50 53
51 // Must be called from the IO thread. 54 // Must be called from the IO thread.
52 void LoadPlugins( 55 void LoadPlugins(
53 scoped_refptr<base::MessageLoopProxy> target_loop, 56 scoped_refptr<base::MessageLoopProxy> target_loop,
54 const content::PluginService::GetPluginsCallback& callback); 57 const content::PluginService::GetPluginsCallback& callback);
55 58
56 // UtilityProcessHost::Client: 59 // UtilityProcessHostClient:
57 virtual void OnProcessCrashed(int exit_code) OVERRIDE; 60 virtual void OnProcessCrashed(int exit_code) OVERRIDE;
58 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 61 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
59 62
60 // IPC::Message::Sender: 63 // IPC::Message::Sender:
61 virtual bool Send(IPC::Message* msg) OVERRIDE; 64 virtual bool Send(IPC::Message* msg) OVERRIDE;
62 65
63 private: 66 private:
64 struct PendingCallback { 67 struct PendingCallback {
65 PendingCallback(scoped_refptr<base::MessageLoopProxy> target_loop, 68 PendingCallback(scoped_refptr<base::MessageLoopProxy> target_loop,
66 const content::PluginService::GetPluginsCallback& callback); 69 const content::PluginService::GetPluginsCallback& callback);
(...skipping 18 matching lines...) Expand all
85 // Checks if the plugin path is an internal plugin, and, if it is, adds it to 88 // Checks if the plugin path is an internal plugin, and, if it is, adds it to
86 // |loaded_plugins_|. 89 // |loaded_plugins_|.
87 bool MaybeAddInternalPlugin(const FilePath& plugin_path); 90 bool MaybeAddInternalPlugin(const FilePath& plugin_path);
88 91
89 // Runs all the registered callbacks on each's target loop if the condition 92 // Runs all the registered callbacks on each's target loop if the condition
90 // for ending the load process is done (i.e. the |next_load_index_| is outside 93 // for ending the load process is done (i.e. the |next_load_index_| is outside
91 // the range of the |canonical_list_|). 94 // the range of the |canonical_list_|).
92 bool MaybeRunPendingCallbacks(); 95 bool MaybeRunPendingCallbacks();
93 96
94 // The process host for which this is a client. 97 // The process host for which this is a client.
95 base::WeakPtr<UtilityProcessHost> process_host_; 98 base::WeakPtr<content::UtilityProcessHost> process_host_;
96 99
97 // A list of paths to plugins which will be loaded by the utility process, in 100 // A list of paths to plugins which will be loaded by the utility process, in
98 // the order specified by this vector. 101 // the order specified by this vector.
99 std::vector<FilePath> canonical_list_; 102 std::vector<FilePath> canonical_list_;
100 103
101 // The index in |canonical_list_| of the plugin that the child process will 104 // The index in |canonical_list_| of the plugin that the child process will
102 // attempt to load next. 105 // attempt to load next.
103 size_t next_load_index_; 106 size_t next_load_index_;
104 107
105 // Internal plugins that have been registered at the time of loading. 108 // Internal plugins that have been registered at the time of loading.
106 std::vector<webkit::WebPluginInfo> internal_plugins_; 109 std::vector<webkit::WebPluginInfo> internal_plugins_;
107 110
108 // A vector of plugins that have been loaded successfully. 111 // A vector of plugins that have been loaded successfully.
109 std::vector<webkit::WebPluginInfo> loaded_plugins_; 112 std::vector<webkit::WebPluginInfo> loaded_plugins_;
110 113
111 // The callback and message loop on which the callback will be run when the 114 // The callback and message loop on which the callback will be run when the
112 // plugin loading process has been completed. 115 // plugin loading process has been completed.
113 std::vector<PendingCallback> callbacks_; 116 std::vector<PendingCallback> callbacks_;
114 117
115 // The time at which plugin loading started. 118 // The time at which plugin loading started.
116 base::TimeTicks load_start_time_; 119 base::TimeTicks load_start_time_;
117 120
118 friend class MockPluginLoaderPosix; 121 friend class MockPluginLoaderPosix;
119 DISALLOW_COPY_AND_ASSIGN(PluginLoaderPosix); 122 DISALLOW_COPY_AND_ASSIGN(PluginLoaderPosix);
120 }; 123 };
121 124
122 #endif // CONTENT_BROWSER_PLUGIN_LOADER_POSIX_H_ 125 #endif // CONTENT_BROWSER_PLUGIN_LOADER_POSIX_H_
OLDNEW
« no previous file with comments | « content/browser/indexed_db/idbbindingutilities_browsertest.cc ('k') | content/browser/plugin_loader_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698