OLD | NEW |
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" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 public IPC::Sender { | 49 public IPC::Sender { |
50 public: | 50 public: |
51 PluginLoaderPosix(); | 51 PluginLoaderPosix(); |
52 | 52 |
53 // Must be called from the IO thread. The |callback| will be called on the IO | 53 // Must be called from the IO thread. The |callback| will be called on the IO |
54 // thread too. | 54 // thread too. |
55 void GetPlugins(const PluginService::GetPluginsCallback& callback); | 55 void GetPlugins(const PluginService::GetPluginsCallback& callback); |
56 | 56 |
57 // UtilityProcessHostClient: | 57 // UtilityProcessHostClient: |
58 void OnProcessCrashed(int exit_code) override; | 58 void OnProcessCrashed(int exit_code) override; |
| 59 void OnProcessLaunchFailed() override; |
59 bool OnMessageReceived(const IPC::Message& message) override; | 60 bool OnMessageReceived(const IPC::Message& message) override; |
60 | 61 |
61 // IPC::Sender: | 62 // IPC::Sender: |
62 bool Send(IPC::Message* msg) override; | 63 bool Send(IPC::Message* msg) override; |
63 | 64 |
64 private: | 65 private: |
65 ~PluginLoaderPosix() override; | 66 ~PluginLoaderPosix() override; |
66 | 67 |
67 // Called on the FILE thread to get the list of plugin paths to probe. | 68 // Called on the FILE thread to get the list of plugin paths to probe. |
68 void GetPluginsToLoad(); | 69 void GetPluginsToLoad(); |
69 | 70 |
70 // Must be called on the IO thread. | 71 // Must be called on the IO thread. |
71 virtual void LoadPluginsInternal(); | 72 virtual void LoadPluginsInternal(); |
72 | 73 |
73 // Called after plugin loading has finished, if we don't know whether the | 74 // Called after plugin loading has finished, if we don't know whether the |
74 // plugin list has been invalidated in the mean time. | 75 // plugin list has been invalidated in the mean time. |
75 void GetPluginsWrapper( | 76 void GetPluginsWrapper( |
76 const PluginService::GetPluginsCallback& callback, | 77 const PluginService::GetPluginsCallback& callback, |
77 const std::vector<WebPluginInfo>& plugins_unused); | 78 const std::vector<WebPluginInfo>& plugins_unused); |
78 | 79 |
79 // Message handlers. | 80 // Message handlers. |
80 void OnPluginLoaded(uint32 index, const WebPluginInfo& plugin); | 81 void OnPluginLoaded(uint32 index, const WebPluginInfo& plugin); |
81 void OnPluginLoadFailed(uint32 index, const base::FilePath& plugin_path); | 82 void OnPluginLoadFailed(uint32 index, const base::FilePath& plugin_path); |
82 | 83 |
83 // Checks if the plugin path is an internal plugin, and, if it is, adds it to | 84 // Returns an iterator to the plugin in |internal_plugins_| whose path |
84 // |loaded_plugins_|. | 85 // matches |plugin_path|. |
85 bool MaybeAddInternalPlugin(const base::FilePath& plugin_path); | 86 std::vector<WebPluginInfo>::iterator FindInternalPlugin( |
| 87 const base::FilePath& plugin_path); |
86 | 88 |
87 // Runs all the registered callbacks on each's target loop if the condition | 89 // Runs all the registered callbacks on each's target loop if the condition |
88 // for ending the load process is done (i.e. the |next_load_index_| is outside | 90 // for ending the load process is done (i.e. the |next_load_index_| is outside |
89 // the range of the |canonical_list_|). | 91 // the range of the |canonical_list_|). |
90 bool MaybeRunPendingCallbacks(); | 92 bool MaybeRunPendingCallbacks(); |
91 | 93 |
| 94 // Returns true if there are no plugins left to load. |
| 95 bool IsFinishedLoadingPlugins(); |
| 96 |
| 97 // This method should be called when the plugins are finished loading. |
| 98 // It updates the PluginList's list of plugins, and runs the queued callbacks. |
| 99 void FinishedLoadingPlugins(); |
| 100 |
| 101 // Launches the utility process that loads the plugins. |
| 102 // Virtual for testing. |
| 103 virtual bool LaunchUtilityProcess(); |
| 104 |
92 // The process host for which this is a client. | 105 // The process host for which this is a client. |
93 base::WeakPtr<UtilityProcessHost> process_host_; | 106 base::WeakPtr<UtilityProcessHost> process_host_; |
94 | 107 |
95 // A list of paths to plugins which will be loaded by the utility process, in | 108 // A list of paths to plugins which will be loaded by the utility process, in |
96 // the order specified by this vector. | 109 // the order specified by this vector. |
97 std::vector<base::FilePath> canonical_list_; | 110 std::vector<base::FilePath> canonical_list_; |
98 | 111 |
99 // The index in |canonical_list_| of the plugin that the child process will | 112 // The index in |canonical_list_| of the plugin that the child process will |
100 // attempt to load next. | 113 // attempt to load next. |
101 size_t next_load_index_; | 114 size_t next_load_index_; |
102 | 115 |
103 // Internal plugins that have been registered at the time of loading. | 116 // Internal plugins that have been registered at the time of loading. |
104 std::vector<WebPluginInfo> internal_plugins_; | 117 std::vector<WebPluginInfo> internal_plugins_; |
105 | 118 |
106 // A vector of plugins that have been loaded successfully. | 119 // A vector of plugins that have been loaded successfully. |
107 std::vector<WebPluginInfo> loaded_plugins_; | 120 std::vector<WebPluginInfo> loaded_plugins_; |
108 | 121 |
109 // The callback and message loop on which the callback will be run when the | 122 // The callback and message loop on which the callback will be run when the |
110 // plugin loading process has been completed. | 123 // plugin loading process has been completed. |
111 std::vector<PluginService::GetPluginsCallback> callbacks_; | 124 std::vector<PluginService::GetPluginsCallback> callbacks_; |
112 | 125 |
113 // The time at which plugin loading started. | 126 // True if there is (or is about to be) a utility process that loads plugins. |
114 base::TimeTicks load_start_time_; | 127 bool loading_plugins_; |
115 | 128 |
116 friend class MockPluginLoaderPosix; | 129 friend class MockPluginLoaderPosix; |
117 DISALLOW_COPY_AND_ASSIGN(PluginLoaderPosix); | 130 DISALLOW_COPY_AND_ASSIGN(PluginLoaderPosix); |
118 }; | 131 }; |
119 | 132 |
120 } // namespace content | 133 } // namespace content |
121 | 134 |
122 #endif // CONTENT_BROWSER_PLUGIN_LOADER_POSIX_H_ | 135 #endif // CONTENT_BROWSER_PLUGIN_LOADER_POSIX_H_ |
OLD | NEW |