Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1027)

Side by Side Diff: content/browser/browser_child_process_host_impl.cc

Issue 12662019: Split the ProcessType enum into process types that content knows about (which will remain in src\co… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/browser_child_process_host_impl.h" 5 #include "content/browser/browser_child_process_host_impl.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 10 matching lines...) Expand all
21 #include "content/browser/profiler_message_filter.h" 21 #include "content/browser/profiler_message_filter.h"
22 #include "content/browser/tracing/trace_message_filter.h" 22 #include "content/browser/tracing/trace_message_filter.h"
23 #include "content/common/child_process_host_impl.h" 23 #include "content/common/child_process_host_impl.h"
24 #include "content/common/plugin_messages.h" 24 #include "content/common/plugin_messages.h"
25 #include "content/public/browser/browser_child_process_host_delegate.h" 25 #include "content/public/browser/browser_child_process_host_delegate.h"
26 #include "content/public/browser/browser_child_process_observer.h" 26 #include "content/public/browser/browser_child_process_observer.h"
27 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
28 #include "content/public/browser/child_process_data.h" 28 #include "content/public/browser/child_process_data.h"
29 #include "content/public/browser/content_browser_client.h" 29 #include "content/public/browser/content_browser_client.h"
30 #include "content/public/common/content_switches.h" 30 #include "content/public/common/content_switches.h"
31 #include "content/public/common/process_type.h"
31 #include "content/public/common/result_codes.h" 32 #include "content/public/common/result_codes.h"
32 33
33 #if defined(OS_MACOSX) 34 #if defined(OS_MACOSX)
34 #include "content/browser/mach_broker_mac.h" 35 #include "content/browser/mach_broker_mac.h"
35 #endif 36 #endif
36 37
37 namespace content { 38 namespace content {
38 namespace { 39 namespace {
39 40
40 static base::LazyInstance<BrowserChildProcessHostImpl::BrowserChildProcessList> 41 static base::LazyInstance<BrowserChildProcessHostImpl::BrowserChildProcessList>
(...skipping 13 matching lines...) Expand all
54 } 55 }
55 56
56 void NotifyProcessCrashed(const ChildProcessData& data) { 57 void NotifyProcessCrashed(const ChildProcessData& data) {
57 FOR_EACH_OBSERVER(BrowserChildProcessObserver, g_observers.Get(), 58 FOR_EACH_OBSERVER(BrowserChildProcessObserver, g_observers.Get(),
58 BrowserChildProcessCrashed(data)); 59 BrowserChildProcessCrashed(data));
59 } 60 }
60 61
61 } // namespace 62 } // namespace
62 63
63 BrowserChildProcessHost* BrowserChildProcessHost::Create( 64 BrowserChildProcessHost* BrowserChildProcessHost::Create(
64 ProcessType type, 65 int process_type,
65 BrowserChildProcessHostDelegate* delegate) { 66 BrowserChildProcessHostDelegate* delegate) {
66 return new BrowserChildProcessHostImpl(type, delegate); 67 return new BrowserChildProcessHostImpl(process_type, delegate);
67 } 68 }
68 69
69 #if defined(OS_MACOSX) 70 #if defined(OS_MACOSX)
70 base::ProcessMetrics::PortProvider* BrowserChildProcessHost::GetPortProvider() { 71 base::ProcessMetrics::PortProvider* BrowserChildProcessHost::GetPortProvider() {
71 return MachBroker::GetInstance(); 72 return MachBroker::GetInstance();
72 } 73 }
73 #endif 74 #endif
74 75
75 // static 76 // static
76 BrowserChildProcessHostImpl::BrowserChildProcessList* 77 BrowserChildProcessHostImpl::BrowserChildProcessList*
77 BrowserChildProcessHostImpl::GetIterator() { 78 BrowserChildProcessHostImpl::GetIterator() {
78 return g_child_process_list.Pointer(); 79 return g_child_process_list.Pointer();
79 } 80 }
80 81
81 // static 82 // static
82 void BrowserChildProcessHostImpl::AddObserver( 83 void BrowserChildProcessHostImpl::AddObserver(
83 BrowserChildProcessObserver* observer) { 84 BrowserChildProcessObserver* observer) {
84 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 85 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
85 g_observers.Get().AddObserver(observer); 86 g_observers.Get().AddObserver(observer);
86 } 87 }
87 88
88 // static 89 // static
89 void BrowserChildProcessHostImpl::RemoveObserver( 90 void BrowserChildProcessHostImpl::RemoveObserver(
90 BrowserChildProcessObserver* observer) { 91 BrowserChildProcessObserver* observer) {
91 // TODO(phajdan.jr): Check thread after fixing http://crbug.com/167126. 92 // TODO(phajdan.jr): Check thread after fixing http://crbug.com/167126.
92 g_observers.Get().RemoveObserver(observer); 93 g_observers.Get().RemoveObserver(observer);
93 } 94 }
94 95
95 BrowserChildProcessHostImpl::BrowserChildProcessHostImpl( 96 BrowserChildProcessHostImpl::BrowserChildProcessHostImpl(
96 ProcessType type, 97 int process_type,
97 BrowserChildProcessHostDelegate* delegate) 98 BrowserChildProcessHostDelegate* delegate)
98 : data_(type), 99 : data_(process_type),
99 delegate_(delegate) { 100 delegate_(delegate) {
100 data_.id = ChildProcessHostImpl::GenerateChildProcessUniqueId(); 101 data_.id = ChildProcessHostImpl::GenerateChildProcessUniqueId();
101 102
102 child_process_host_.reset(ChildProcessHost::Create(this)); 103 child_process_host_.reset(ChildProcessHost::Create(this));
103 child_process_host_->AddFilter(new TraceMessageFilter); 104 child_process_host_->AddFilter(new TraceMessageFilter);
104 child_process_host_->AddFilter(new ProfilerMessageFilter(type)); 105 child_process_host_->AddFilter(new ProfilerMessageFilter(process_type));
105 child_process_host_->AddFilter(new HistogramMessageFilter()); 106 child_process_host_->AddFilter(new HistogramMessageFilter());
106 107
107 g_child_process_list.Get().push_back(this); 108 g_child_process_list.Get().push_back(this);
108 GetContentClient()->browser()->BrowserChildProcessHostCreated(this); 109 GetContentClient()->browser()->BrowserChildProcessHostCreated(this);
109 } 110 }
110 111
111 BrowserChildProcessHostImpl::~BrowserChildProcessHostImpl() { 112 BrowserChildProcessHostImpl::~BrowserChildProcessHostImpl() {
112 g_child_process_list.Get().remove(this); 113 g_child_process_list.Get().remove(this);
113 114
114 #if defined(OS_WIN) 115 #if defined(OS_WIN)
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 259 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
259 DCHECK(data_.handle != base::kNullProcessHandle); 260 DCHECK(data_.handle != base::kNullProcessHandle);
260 int exit_code; 261 int exit_code;
261 base::TerminationStatus status = GetTerminationStatus(&exit_code); 262 base::TerminationStatus status = GetTerminationStatus(&exit_code);
262 switch (status) { 263 switch (status) {
263 case base::TERMINATION_STATUS_PROCESS_CRASHED: 264 case base::TERMINATION_STATUS_PROCESS_CRASHED:
264 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: { 265 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: {
265 delegate_->OnProcessCrashed(exit_code); 266 delegate_->OnProcessCrashed(exit_code);
266 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 267 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
267 base::Bind(&NotifyProcessCrashed, data_)); 268 base::Bind(&NotifyProcessCrashed, data_));
268 UMA_HISTOGRAM_ENUMERATION("ChildProcess.Crashed", 269 UMA_HISTOGRAM_ENUMERATION("ChildProcess.Crashed2",
scottmg 2013/03/22 02:56:35 why 2 now?
jam 2013/03/22 04:58:37 because the enum values have changed. i'll update
269 data_.type, 270 data_.process_type,
270 PROCESS_TYPE_MAX); 271 PROCESS_TYPE_MAX);
271 break; 272 break;
272 } 273 }
273 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED: { 274 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED: {
274 delegate_->OnProcessCrashed(exit_code); 275 delegate_->OnProcessCrashed(exit_code);
275 // Report that this child process was killed. 276 // Report that this child process was killed.
276 UMA_HISTOGRAM_ENUMERATION("ChildProcess.Killed", 277 UMA_HISTOGRAM_ENUMERATION("ChildProcess.Killed2",
277 data_.type, 278 data_.process_type,
278 PROCESS_TYPE_MAX); 279 PROCESS_TYPE_MAX);
279 break; 280 break;
280 } 281 }
281 case base::TERMINATION_STATUS_STILL_RUNNING: { 282 case base::TERMINATION_STATUS_STILL_RUNNING: {
282 UMA_HISTOGRAM_ENUMERATION("ChildProcess.DisconnectedAlive", 283 UMA_HISTOGRAM_ENUMERATION("ChildProcess.DisconnectedAlive2",
283 data_.type, 284 data_.process_type,
284 PROCESS_TYPE_MAX); 285 PROCESS_TYPE_MAX);
285 } 286 }
286 default: 287 default:
287 break; 288 break;
288 } 289 }
289 UMA_HISTOGRAM_ENUMERATION("ChildProcess.Disconnected", 290 UMA_HISTOGRAM_ENUMERATION("ChildProcess.Disconnected2",
290 data_.type, 291 data_.process_type,
291 PROCESS_TYPE_MAX); 292 PROCESS_TYPE_MAX);
292 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 293 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
293 base::Bind(&NotifyProcessHostDisconnected, data_)); 294 base::Bind(&NotifyProcessHostDisconnected, data_));
294 delete delegate_; // Will delete us 295 delete delegate_; // Will delete us
295 } 296 }
296 297
297 bool BrowserChildProcessHostImpl::Send(IPC::Message* message) { 298 bool BrowserChildProcessHostImpl::Send(IPC::Message* message) {
298 return child_process_host_->Send(message); 299 return child_process_host_->Send(message);
299 } 300 }
300 301
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 337
337 void BrowserChildProcessHostImpl::OnProcessExitedEarly( 338 void BrowserChildProcessHostImpl::OnProcessExitedEarly(
338 base::WaitableEvent* event) { 339 base::WaitableEvent* event) {
339 DeleteProcessWaitableEvent(event); 340 DeleteProcessWaitableEvent(event);
340 OnChildDisconnected(); 341 OnChildDisconnected();
341 } 342 }
342 343
343 #endif 344 #endif
344 345
345 } // namespace content 346 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698