Chromium Code Reviews| 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 "base/metrics/user_metrics.h" | |
| 11 #include "content/browser/utility_process_host_impl.h" | 12 #include "content/browser/utility_process_host_impl.h" |
| 12 #include "content/common/child_process_host_impl.h" | 13 #include "content/common/child_process_host_impl.h" |
| 13 #include "content/common/plugin_list.h" | 14 #include "content/common/plugin_list.h" |
| 14 #include "content/common/utility_messages.h" | 15 #include "content/common/utility_messages.h" |
| 15 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 16 #include "content/public/browser/plugin_service.h" | 17 #include "content/public/browser/plugin_service.h" |
| 17 | 18 |
| 19 using base::RecordAction; | |
| 20 using base::UserMetricsAction; | |
|
jochen (gone - plz use gerrit)
2014/01/16 15:32:50
i don't think it's necessary to use "using"... usu
| |
| 21 | |
| 18 namespace content { | 22 namespace content { |
| 19 | 23 |
| 20 PluginLoaderPosix::PluginLoaderPosix() | 24 PluginLoaderPosix::PluginLoaderPosix() |
| 21 : next_load_index_(0) { | 25 : next_load_index_(0) { |
| 22 } | 26 } |
| 23 | 27 |
| 24 void PluginLoaderPosix::LoadPlugins( | 28 void PluginLoaderPosix::LoadPlugins( |
| 25 scoped_refptr<base::MessageLoopProxy> target_loop, | 29 scoped_refptr<base::MessageLoopProxy> target_loop, |
| 26 const PluginService::GetPluginsCallback& callback) { | 30 const PluginService::GetPluginsCallback& callback) { |
| 27 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 31 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 38 bool handled = true; | 42 bool handled = true; |
| 39 IPC_BEGIN_MESSAGE_MAP(PluginLoaderPosix, message) | 43 IPC_BEGIN_MESSAGE_MAP(PluginLoaderPosix, message) |
| 40 IPC_MESSAGE_HANDLER(UtilityHostMsg_LoadedPlugin, OnPluginLoaded) | 44 IPC_MESSAGE_HANDLER(UtilityHostMsg_LoadedPlugin, OnPluginLoaded) |
| 41 IPC_MESSAGE_HANDLER(UtilityHostMsg_LoadPluginFailed, OnPluginLoadFailed) | 45 IPC_MESSAGE_HANDLER(UtilityHostMsg_LoadPluginFailed, OnPluginLoadFailed) |
| 42 IPC_MESSAGE_UNHANDLED(handled = false) | 46 IPC_MESSAGE_UNHANDLED(handled = false) |
| 43 IPC_END_MESSAGE_MAP() | 47 IPC_END_MESSAGE_MAP() |
| 44 return handled; | 48 return handled; |
| 45 } | 49 } |
| 46 | 50 |
| 47 void PluginLoaderPosix::OnProcessCrashed(int exit_code) { | 51 void PluginLoaderPosix::OnProcessCrashed(int exit_code) { |
| 52 RecordAction(UserMetricsAction("PluginLoaderPosix.UtilityProcessCrashed")); | |
| 53 | |
| 48 if (next_load_index_ == canonical_list_.size()) { | 54 if (next_load_index_ == canonical_list_.size()) { |
| 49 // How this case occurs is unknown. See crbug.com/111935. | 55 // How this case occurs is unknown. See crbug.com/111935. |
| 50 canonical_list_.clear(); | 56 canonical_list_.clear(); |
| 51 } else { | 57 } else { |
| 52 canonical_list_.erase(canonical_list_.begin(), | 58 canonical_list_.erase(canonical_list_.begin(), |
| 53 canonical_list_.begin() + next_load_index_ + 1); | 59 canonical_list_.begin() + next_load_index_ + 1); |
| 54 } | 60 } |
| 55 | 61 |
| 56 next_load_index_ = 0; | 62 next_load_index_ = 0; |
| 57 | 63 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 } | 99 } |
| 94 | 100 |
| 95 void PluginLoaderPosix::LoadPluginsInternal() { | 101 void PluginLoaderPosix::LoadPluginsInternal() { |
| 96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 102 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 97 | 103 |
| 98 // Check if the list is empty or all plugins have already been loaded before | 104 // Check if the list is empty or all plugins have already been loaded before |
| 99 // forking. | 105 // forking. |
| 100 if (MaybeRunPendingCallbacks()) | 106 if (MaybeRunPendingCallbacks()) |
| 101 return; | 107 return; |
| 102 | 108 |
| 109 RecordAction(UserMetricsAction("PluginLoaderPosix.LaunchUtilityProcess")); | |
| 110 | |
| 103 if (load_start_time_.is_null()) | 111 if (load_start_time_.is_null()) |
| 104 load_start_time_ = base::TimeTicks::Now(); | 112 load_start_time_ = base::TimeTicks::Now(); |
| 105 | 113 |
| 106 UtilityProcessHostImpl* host = new UtilityProcessHostImpl( | 114 UtilityProcessHostImpl* host = new UtilityProcessHostImpl( |
| 107 this, | 115 this, |
| 108 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get()); | 116 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get()); |
| 109 process_host_ = host->AsWeakPtr(); | 117 process_host_ = host->AsWeakPtr(); |
| 110 process_host_->DisableSandbox(); | 118 process_host_->DisableSandbox(); |
| 111 #if defined(OS_MACOSX) | 119 #if defined(OS_MACOSX) |
| 112 host->set_child_flags(ChildProcessHost::CHILD_ALLOW_HEAP_EXECUTION); | 120 host->set_child_flags(ChildProcessHost::CHILD_ALLOW_HEAP_EXECUTION); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 scoped_refptr<base::MessageLoopProxy> loop, | 200 scoped_refptr<base::MessageLoopProxy> loop, |
| 193 const PluginService::GetPluginsCallback& cb) | 201 const PluginService::GetPluginsCallback& cb) |
| 194 : target_loop(loop), | 202 : target_loop(loop), |
| 195 callback(cb) { | 203 callback(cb) { |
| 196 } | 204 } |
| 197 | 205 |
| 198 PluginLoaderPosix::PendingCallback::~PendingCallback() { | 206 PluginLoaderPosix::PendingCallback::~PendingCallback() { |
| 199 } | 207 } |
| 200 | 208 |
| 201 } // namespace content | 209 } // namespace content |
| OLD | NEW |