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 #include "content/browser/plugin_loader_posix.h" | 5 #include "content/browser/plugin_loader_posix.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "content/browser/utility_process_host_impl.h" | 11 #include "content/browser/utility_process_host_impl.h" |
12 #include "content/common/child_process_host_impl.h" | 12 #include "content/common/child_process_host_impl.h" |
13 #include "content/common/plugin_list.h" | 13 #include "content/common/plugin_list.h" |
14 #include "content/common/utility_messages.h" | 14 #include "content/common/utility_messages.h" |
15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
16 #include "content/public/browser/plugin_service.h" | 16 #include "content/public/browser/plugin_service.h" |
17 #include "content/public/browser/user_metrics.h" | 17 #include "content/public/browser/user_metrics.h" |
18 | 18 |
19 namespace content { | 19 namespace content { |
20 | 20 |
21 PluginLoaderPosix::PluginLoaderPosix() | 21 PluginLoaderPosix::PluginLoaderPosix() |
22 : next_load_index_(0), loading_plugins_(false) { | 22 : next_load_index_(0), loading_plugins_(false) { |
23 } | 23 } |
24 | 24 |
25 void PluginLoaderPosix::GetPlugins( | 25 void PluginLoaderPosix::GetPlugins( |
26 const PluginService::GetPluginsCallback& callback) { | 26 const PluginService::GetPluginsCallback& callback) { |
27 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 27 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
28 | 28 |
29 std::vector<WebPluginInfo> cached_plugins; | 29 std::vector<WebPluginInfo> cached_plugins; |
30 if (PluginList::Singleton()->GetPluginsNoRefresh(&cached_plugins)) { | 30 if (PluginList::Singleton()->GetPluginsNoRefresh(&cached_plugins)) { |
31 // Can't assume the caller is reentrant. | 31 // Can't assume the caller is reentrant. |
32 base::MessageLoop::current()->PostTask(FROM_HERE, | 32 base::MessageLoop::current()->PostTask(FROM_HERE, |
33 base::Bind(callback, cached_plugins)); | 33 base::Bind(callback, cached_plugins)); |
34 return; | 34 return; |
35 } | 35 } |
36 | 36 |
37 if (!loading_plugins_) { | 37 if (!loading_plugins_) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 bool PluginLoaderPosix::Send(IPC::Message* message) { | 91 bool PluginLoaderPosix::Send(IPC::Message* message) { |
92 if (process_host_.get()) | 92 if (process_host_.get()) |
93 return process_host_->Send(message); | 93 return process_host_->Send(message); |
94 return false; | 94 return false; |
95 } | 95 } |
96 | 96 |
97 PluginLoaderPosix::~PluginLoaderPosix() { | 97 PluginLoaderPosix::~PluginLoaderPosix() { |
98 } | 98 } |
99 | 99 |
100 void PluginLoaderPosix::GetPluginsToLoad() { | 100 void PluginLoaderPosix::GetPluginsToLoad() { |
101 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 101 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
102 | 102 |
103 base::TimeTicks start_time(base::TimeTicks::Now()); | 103 base::TimeTicks start_time(base::TimeTicks::Now()); |
104 | 104 |
105 loaded_plugins_.clear(); | 105 loaded_plugins_.clear(); |
106 next_load_index_ = 0; | 106 next_load_index_ = 0; |
107 | 107 |
108 canonical_list_.clear(); | 108 canonical_list_.clear(); |
109 PluginList::Singleton()->GetPluginPathsToLoad( | 109 PluginList::Singleton()->GetPluginPathsToLoad( |
110 &canonical_list_, | 110 &canonical_list_, |
111 PluginService::GetInstance()->NPAPIPluginsSupported()); | 111 PluginService::GetInstance()->NPAPIPluginsSupported()); |
112 | 112 |
113 internal_plugins_.clear(); | 113 internal_plugins_.clear(); |
114 PluginList::Singleton()->GetInternalPlugins(&internal_plugins_); | 114 PluginList::Singleton()->GetInternalPlugins(&internal_plugins_); |
115 | 115 |
116 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 116 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
117 base::Bind(&PluginLoaderPosix::LoadPluginsInternal, | 117 base::Bind(&PluginLoaderPosix::LoadPluginsInternal, |
118 make_scoped_refptr(this))); | 118 make_scoped_refptr(this))); |
119 | 119 |
120 LOCAL_HISTOGRAM_TIMES("PluginLoaderPosix.GetPluginList", | 120 LOCAL_HISTOGRAM_TIMES("PluginLoaderPosix.GetPluginList", |
121 (base::TimeTicks::Now() - start_time) * | 121 (base::TimeTicks::Now() - start_time) * |
122 base::Time::kMicrosecondsPerMillisecond); | 122 base::Time::kMicrosecondsPerMillisecond); |
123 } | 123 } |
124 | 124 |
125 void PluginLoaderPosix::LoadPluginsInternal() { | 125 void PluginLoaderPosix::LoadPluginsInternal() { |
126 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 126 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
127 | 127 |
128 // Check if the list is empty or all plugins have already been loaded before | 128 // Check if the list is empty or all plugins have already been loaded before |
129 // forking. | 129 // forking. |
130 if (IsFinishedLoadingPlugins()) { | 130 if (IsFinishedLoadingPlugins()) { |
131 FinishedLoadingPlugins(); | 131 FinishedLoadingPlugins(); |
132 return; | 132 return; |
133 } | 133 } |
134 | 134 |
135 RecordAction( | 135 RecordAction( |
136 base::UserMetricsAction("PluginLoaderPosix.LaunchUtilityProcess")); | 136 base::UserMetricsAction("PluginLoaderPosix.LaunchUtilityProcess")); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 FROM_HERE, base::Bind(callback, loaded_plugins_)); | 230 FROM_HERE, base::Bind(callback, loaded_plugins_)); |
231 } | 231 } |
232 callbacks_.clear(); | 232 callbacks_.clear(); |
233 } | 233 } |
234 | 234 |
235 bool PluginLoaderPosix::LaunchUtilityProcess() { | 235 bool PluginLoaderPosix::LaunchUtilityProcess() { |
236 return process_host_->Send(new UtilityMsg_LoadPlugins(canonical_list_)); | 236 return process_host_->Send(new UtilityMsg_LoadPlugins(canonical_list_)); |
237 } | 237 } |
238 | 238 |
239 } // namespace content | 239 } // namespace content |
OLD | NEW |