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 <deque> | |
9 #include <vector> | 8 #include <vector> |
10 | 9 |
11 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
12 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
13 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
14 #include "base/time/time.h" | 13 #include "base/time/time.h" |
15 #include "content/browser/plugin_service_impl.h" | 14 #include "content/browser/plugin_service_impl.h" |
16 #include "content/public/browser/utility_process_host_client.h" | 15 #include "content/public/browser/utility_process_host_client.h" |
17 #include "content/public/common/webplugininfo.h" | 16 #include "content/public/common/webplugininfo.h" |
18 #include "ipc/ipc_sender.h" | 17 #include "ipc/ipc_sender.h" |
(...skipping 26 matching lines...) Expand all Loading... | |
45 // 5. This algorithm continues until the canonical list has been walked to the | 44 // 5. This algorithm continues until the canonical list has been walked to the |
46 // end, after which the list of loaded plugins is set on the PluginList and | 45 // end, after which the list of loaded plugins is set on the PluginList and |
47 // the completion callback is run. | 46 // the completion callback is run. |
48 class CONTENT_EXPORT PluginLoaderPosix | 47 class CONTENT_EXPORT PluginLoaderPosix |
49 : public NON_EXPORTED_BASE(UtilityProcessHostClient), | 48 : public NON_EXPORTED_BASE(UtilityProcessHostClient), |
50 public IPC::Sender { | 49 public IPC::Sender { |
51 public: | 50 public: |
52 PluginLoaderPosix(); | 51 PluginLoaderPosix(); |
53 | 52 |
54 // Must be called from the IO thread. | 53 // Must be called from the IO thread. |
55 void LoadPlugins( | 54 void GetPlugins(const PluginService::GetPluginsCallback& callback); |
56 scoped_refptr<base::MessageLoopProxy> target_loop, | |
Robert Sesek
2014/01/21 15:17:22
You're changing the calling semantics in terms of
Bernhard Bauer
2014/01/21 15:48:25
Done.
| |
57 const PluginService::GetPluginsCallback& callback); | |
58 | 55 |
59 // UtilityProcessHostClient: | 56 // UtilityProcessHostClient: |
60 virtual void OnProcessCrashed(int exit_code) OVERRIDE; | 57 virtual void OnProcessCrashed(int exit_code) OVERRIDE; |
61 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 58 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
62 | 59 |
63 // IPC::Sender: | 60 // IPC::Sender: |
64 virtual bool Send(IPC::Message* msg) OVERRIDE; | 61 virtual bool Send(IPC::Message* msg) OVERRIDE; |
65 | 62 |
66 private: | 63 private: |
67 struct PendingCallback { | |
68 PendingCallback(scoped_refptr<base::MessageLoopProxy> target_loop, | |
69 const PluginService::GetPluginsCallback& callback); | |
70 ~PendingCallback(); | |
71 | |
72 scoped_refptr<base::MessageLoopProxy> target_loop; | |
73 PluginService::GetPluginsCallback callback; | |
74 }; | |
75 | |
76 virtual ~PluginLoaderPosix(); | 64 virtual ~PluginLoaderPosix(); |
77 | 65 |
78 // Called on the FILE thread to get the list of plugin paths to probe. | 66 // Called on the FILE thread to get the list of plugin paths to probe. |
79 void GetPluginsToLoad(); | 67 void GetPluginsToLoad(); |
80 | 68 |
81 // Must be called on the IO thread. | 69 // Must be called on the IO thread. |
82 virtual void LoadPluginsInternal(); | 70 virtual void LoadPluginsInternal(); |
83 | 71 |
72 void GetPluginsWrapper( | |
Robert Sesek
2014/01/21 15:17:22
Please comment.
Bernhard Bauer
2014/01/21 15:48:25
Done.
| |
73 const PluginService::GetPluginsCallback& callback, | |
74 const std::vector<WebPluginInfo>& plugins); | |
75 | |
76 void PluginLoadingFinished( | |
77 const std::vector<WebPluginInfo>& plugins); | |
78 | |
84 // Message handlers. | 79 // Message handlers. |
85 void OnPluginLoaded(uint32 index, const WebPluginInfo& plugin); | 80 void OnPluginLoaded(uint32 index, const WebPluginInfo& plugin); |
86 void OnPluginLoadFailed(uint32 index, const base::FilePath& plugin_path); | 81 void OnPluginLoadFailed(uint32 index, const base::FilePath& plugin_path); |
87 | 82 |
88 // Checks if the plugin path is an internal plugin, and, if it is, adds it to | 83 // Checks if the plugin path is an internal plugin, and, if it is, adds it to |
89 // |loaded_plugins_|. | 84 // |loaded_plugins_|. |
90 bool MaybeAddInternalPlugin(const base::FilePath& plugin_path); | 85 bool MaybeAddInternalPlugin(const base::FilePath& plugin_path); |
91 | 86 |
92 // Runs all the registered callbacks on each's target loop if the condition | 87 // Runs all the registered callbacks on each's target loop if the condition |
93 // for ending the load process is done (i.e. the |next_load_index_| is outside | 88 // for ending the load process is done (i.e. the |next_load_index_| is outside |
(...skipping 12 matching lines...) Expand all Loading... | |
106 size_t next_load_index_; | 101 size_t next_load_index_; |
107 | 102 |
108 // Internal plugins that have been registered at the time of loading. | 103 // Internal plugins that have been registered at the time of loading. |
109 std::vector<WebPluginInfo> internal_plugins_; | 104 std::vector<WebPluginInfo> internal_plugins_; |
110 | 105 |
111 // A vector of plugins that have been loaded successfully. | 106 // A vector of plugins that have been loaded successfully. |
112 std::vector<WebPluginInfo> loaded_plugins_; | 107 std::vector<WebPluginInfo> loaded_plugins_; |
113 | 108 |
114 // The callback and message loop on which the callback will be run when the | 109 // The callback and message loop on which the callback will be run when the |
115 // plugin loading process has been completed. | 110 // plugin loading process has been completed. |
116 std::deque<PendingCallback> callbacks_; | 111 std::vector<PluginService::GetPluginsCallback> callbacks_; |
117 | 112 |
118 // The time at which plugin loading started. | 113 // The time at which plugin loading started. |
119 base::TimeTicks load_start_time_; | 114 base::TimeTicks load_start_time_; |
120 | 115 |
121 friend class MockPluginLoaderPosix; | 116 friend class MockPluginLoaderPosix; |
122 DISALLOW_COPY_AND_ASSIGN(PluginLoaderPosix); | 117 DISALLOW_COPY_AND_ASSIGN(PluginLoaderPosix); |
123 }; | 118 }; |
124 | 119 |
125 } // namespace content | 120 } // namespace content |
126 | 121 |
127 #endif // CONTENT_BROWSER_PLUGIN_LOADER_POSIX_H_ | 122 #endif // CONTENT_BROWSER_PLUGIN_LOADER_POSIX_H_ |
OLD | NEW |