| 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 |
| 18 namespace content { | 19 namespace content { |
| 19 | 20 |
| 20 PluginLoaderPosix::PluginLoaderPosix() | 21 PluginLoaderPosix::PluginLoaderPosix() |
| (...skipping 17 matching lines...) Expand all Loading... |
| 38 bool handled = true; | 39 bool handled = true; |
| 39 IPC_BEGIN_MESSAGE_MAP(PluginLoaderPosix, message) | 40 IPC_BEGIN_MESSAGE_MAP(PluginLoaderPosix, message) |
| 40 IPC_MESSAGE_HANDLER(UtilityHostMsg_LoadedPlugin, OnPluginLoaded) | 41 IPC_MESSAGE_HANDLER(UtilityHostMsg_LoadedPlugin, OnPluginLoaded) |
| 41 IPC_MESSAGE_HANDLER(UtilityHostMsg_LoadPluginFailed, OnPluginLoadFailed) | 42 IPC_MESSAGE_HANDLER(UtilityHostMsg_LoadPluginFailed, OnPluginLoadFailed) |
| 42 IPC_MESSAGE_UNHANDLED(handled = false) | 43 IPC_MESSAGE_UNHANDLED(handled = false) |
| 43 IPC_END_MESSAGE_MAP() | 44 IPC_END_MESSAGE_MAP() |
| 44 return handled; | 45 return handled; |
| 45 } | 46 } |
| 46 | 47 |
| 47 void PluginLoaderPosix::OnProcessCrashed(int exit_code) { | 48 void PluginLoaderPosix::OnProcessCrashed(int exit_code) { |
| 49 RecordAction( |
| 50 base::UserMetricsAction("PluginLoaderPosix.UtilityProcessCrashed")); |
| 51 |
| 48 if (next_load_index_ == canonical_list_.size()) { | 52 if (next_load_index_ == canonical_list_.size()) { |
| 49 // How this case occurs is unknown. See crbug.com/111935. | 53 // How this case occurs is unknown. See crbug.com/111935. |
| 50 canonical_list_.clear(); | 54 canonical_list_.clear(); |
| 51 } else { | 55 } else { |
| 52 canonical_list_.erase(canonical_list_.begin(), | 56 canonical_list_.erase(canonical_list_.begin(), |
| 53 canonical_list_.begin() + next_load_index_ + 1); | 57 canonical_list_.begin() + next_load_index_ + 1); |
| 54 } | 58 } |
| 55 | 59 |
| 56 next_load_index_ = 0; | 60 next_load_index_ = 0; |
| 57 | 61 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 } | 97 } |
| 94 | 98 |
| 95 void PluginLoaderPosix::LoadPluginsInternal() { | 99 void PluginLoaderPosix::LoadPluginsInternal() { |
| 96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 100 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 97 | 101 |
| 98 // Check if the list is empty or all plugins have already been loaded before | 102 // Check if the list is empty or all plugins have already been loaded before |
| 99 // forking. | 103 // forking. |
| 100 if (MaybeRunPendingCallbacks()) | 104 if (MaybeRunPendingCallbacks()) |
| 101 return; | 105 return; |
| 102 | 106 |
| 107 RecordAction( |
| 108 base::UserMetricsAction("PluginLoaderPosix.LaunchUtilityProcess")); |
| 109 |
| 103 if (load_start_time_.is_null()) | 110 if (load_start_time_.is_null()) |
| 104 load_start_time_ = base::TimeTicks::Now(); | 111 load_start_time_ = base::TimeTicks::Now(); |
| 105 | 112 |
| 106 UtilityProcessHostImpl* host = new UtilityProcessHostImpl( | 113 UtilityProcessHostImpl* host = new UtilityProcessHostImpl( |
| 107 this, | 114 this, |
| 108 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get()); | 115 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get()); |
| 109 process_host_ = host->AsWeakPtr(); | 116 process_host_ = host->AsWeakPtr(); |
| 110 process_host_->DisableSandbox(); | 117 process_host_->DisableSandbox(); |
| 111 #if defined(OS_MACOSX) | 118 #if defined(OS_MACOSX) |
| 112 host->set_child_flags(ChildProcessHost::CHILD_ALLOW_HEAP_EXECUTION); | 119 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, | 199 scoped_refptr<base::MessageLoopProxy> loop, |
| 193 const PluginService::GetPluginsCallback& cb) | 200 const PluginService::GetPluginsCallback& cb) |
| 194 : target_loop(loop), | 201 : target_loop(loop), |
| 195 callback(cb) { | 202 callback(cb) { |
| 196 } | 203 } |
| 197 | 204 |
| 198 PluginLoaderPosix::PendingCallback::~PendingCallback() { | 205 PluginLoaderPosix::PendingCallback::~PendingCallback() { |
| 199 } | 206 } |
| 200 | 207 |
| 201 } // namespace content | 208 } // namespace content |
| OLD | NEW |