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

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

Issue 8787004: Make ChildProcessHost be used through an interface in content/public, instead of by inheritence. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years 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
« no previous file with comments | « content/browser/browser_child_process_host.h ('k') | content/browser/gpu/gpu_process_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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.h" 5 #include "content/browser/browser_child_process_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/process_util.h" 14 #include "base/process_util.h"
15 #include "base/stl_util.h" 15 #include "base/stl_util.h"
16 #include "base/string_util.h" 16 #include "base/string_util.h"
17 #include "content/browser/profiler_message_filter.h" 17 #include "content/browser/profiler_message_filter.h"
18 #include "content/browser/renderer_host/resource_message_filter.h" 18 #include "content/browser/renderer_host/resource_message_filter.h"
19 #include "content/browser/trace_message_filter.h" 19 #include "content/browser/trace_message_filter.h"
20 #include "content/common/child_process_host.h" 20 #include "content/common/child_process_host_impl.h"
21 #include "content/common/plugin_messages.h" 21 #include "content/common/plugin_messages.h"
22 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
23 #include "content/public/browser/child_process_data.h" 23 #include "content/public/browser/child_process_data.h"
24 #include "content/public/browser/content_browser_client.h" 24 #include "content/public/browser/content_browser_client.h"
25 #include "content/public/browser/notification_service.h" 25 #include "content/public/browser/notification_service.h"
26 #include "content/public/browser/notification_types.h" 26 #include "content/public/browser/notification_types.h"
27 #include "content/public/common/content_switches.h" 27 #include "content/public/common/content_switches.h"
28 #include "content/public/common/result_codes.h" 28 #include "content/public/common/result_codes.h"
29 29
30 #if defined(OS_WIN) 30 #if defined(OS_WIN)
31 #include "base/synchronization/waitable_event.h" 31 #include "base/synchronization/waitable_event.h"
32 #else 32 #else
33 #include "base/bind.h" 33 #include "base/bind.h"
34 #endif 34 #endif
35 35
36 using content::BrowserThread; 36 using content::BrowserThread;
37 using content::ChildProcessHost;
38 using content::ChildProcessHostImpl;
37 39
38 namespace { 40 namespace {
39 41
40 typedef std::list<BrowserChildProcessHost*> ChildProcessList; 42 typedef std::list<BrowserChildProcessHost*> ChildProcessList;
41 static base::LazyInstance<ChildProcessList> g_child_process_list = 43 static base::LazyInstance<ChildProcessList> g_child_process_list =
42 LAZY_INSTANCE_INITIALIZER; 44 LAZY_INSTANCE_INITIALIZER;
43 45
44 // Helper functions since the child process related notifications happen on the 46 // Helper functions since the child process related notifications happen on the
45 // UI thread. 47 // UI thread.
46 void ChildNotificationHelper(int notification_type, 48 void ChildNotificationHelper(int notification_type,
47 content::ChildProcessData data) { 49 content::ChildProcessData data) {
48 content::NotificationService::current()-> 50 content::NotificationService::current()->
49 Notify(notification_type, content::NotificationService::AllSources(), 51 Notify(notification_type, content::NotificationService::AllSources(),
50 content::Details<content::ChildProcessData>(&data)); 52 content::Details<content::ChildProcessData>(&data));
51 } 53 }
52 54
53 } // namespace 55 } // namespace
54 56
55 BrowserChildProcessHost::BrowserChildProcessHost( 57 BrowserChildProcessHost::BrowserChildProcessHost(
56 content::ProcessType type) 58 content::ProcessType type)
57 : ALLOW_THIS_IN_INITIALIZER_LIST(client_(this)), 59 : ALLOW_THIS_IN_INITIALIZER_LIST(client_(this)),
58 #if !defined(OS_WIN) 60 #if !defined(OS_WIN)
59 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), 61 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)),
60 #endif 62 #endif
61 disconnect_was_alive_(false) { 63 disconnect_was_alive_(false) {
62 data_.type = type; 64 data_.type = type;
63 data_.id = ChildProcessHost::GenerateChildProcessUniqueId(); 65 data_.id = ChildProcessHostImpl::GenerateChildProcessUniqueId();
64 66
65 child_process_host_.reset(new ChildProcessHost(this)); 67 child_process_host_.reset(ChildProcessHost::Create(this));
66 child_process_host_->AddFilter(new TraceMessageFilter); 68 child_process_host_->AddFilter(new TraceMessageFilter);
67 child_process_host_->AddFilter(new ProfilerMessageFilter); 69 child_process_host_->AddFilter(new ProfilerMessageFilter);
68 70
69 g_child_process_list.Get().push_back(this); 71 g_child_process_list.Get().push_back(this);
70 } 72 }
71 73
72 BrowserChildProcessHost::~BrowserChildProcessHost() { 74 BrowserChildProcessHost::~BrowserChildProcessHost() {
73 g_child_process_list.Get().remove(this); 75 g_child_process_list.Get().remove(this);
74 } 76 }
75 77
(...skipping 15 matching lines...) Expand all
91 93
92 content::GetContentClient()->browser()->AppendExtraCommandLineSwitches( 94 content::GetContentClient()->browser()->AppendExtraCommandLineSwitches(
93 cmd_line, id()); 95 cmd_line, id());
94 96
95 child_process_.reset(new ChildProcessLauncher( 97 child_process_.reset(new ChildProcessLauncher(
96 #if defined(OS_WIN) 98 #if defined(OS_WIN)
97 exposed_dir, 99 exposed_dir,
98 #elif defined(OS_POSIX) 100 #elif defined(OS_POSIX)
99 use_zygote, 101 use_zygote,
100 environ, 102 environ,
101 child_process_host()->channel()->TakeClientFileDescriptor(), 103 child_process_host()->TakeClientFileDescriptor(),
102 #endif 104 #endif
103 cmd_line, 105 cmd_line,
104 &client_)); 106 &client_));
105 } 107 }
106 108
107 base::ProcessHandle BrowserChildProcessHost::GetChildProcessHandle() const { 109 base::ProcessHandle BrowserChildProcessHost::GetChildProcessHandle() const {
108 DCHECK(child_process_.get()) 110 DCHECK(child_process_.get())
109 << "Requesting a child process handle before launching."; 111 << "Requesting a child process handle before launching.";
110 DCHECK(child_process_->GetHandle()) 112 DCHECK(child_process_->GetHandle())
111 << "Requesting a child process handle before launch has completed OK."; 113 << "Requesting a child process handle before launch has completed OK.";
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 295
294 return *iterator_; 296 return *iterator_;
295 } while (true); 297 } while (true);
296 298
297 return NULL; 299 return NULL;
298 } 300 }
299 301
300 bool BrowserChildProcessHost::Iterator::Done() { 302 bool BrowserChildProcessHost::Iterator::Done() {
301 return iterator_ == g_child_process_list.Get().end(); 303 return iterator_ == g_child_process_list.Get().end();
302 } 304 }
OLDNEW
« no previous file with comments | « content/browser/browser_child_process_host.h ('k') | content/browser/gpu/gpu_process_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698