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

Side by Side Diff: content/common/child_process_host_impl.cc

Issue 2741203002: memory-infra: Finish moving to Mojo (3nd attempt) (Closed)
Patch Set: rebase Created 3 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
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/common/child_process_host_impl.h" 5 #include "content/common/child_process_host_impl.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/atomic_sequence_num.h" 9 #include "base/atomic_sequence_num.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 14 matching lines...) Expand all
25 #include "content/common/child_process_messages.h" 25 #include "content/common/child_process_messages.h"
26 #include "content/public/common/child_process_host_delegate.h" 26 #include "content/public/common/child_process_host_delegate.h"
27 #include "content/public/common/content_paths.h" 27 #include "content/public/common/content_paths.h"
28 #include "content/public/common/content_switches.h" 28 #include "content/public/common/content_switches.h"
29 #include "ipc/ipc.mojom.h" 29 #include "ipc/ipc.mojom.h"
30 #include "ipc/ipc_channel.h" 30 #include "ipc/ipc_channel.h"
31 #include "ipc/ipc_channel_mojo.h" 31 #include "ipc/ipc_channel_mojo.h"
32 #include "ipc/ipc_logging.h" 32 #include "ipc/ipc_logging.h"
33 #include "ipc/message_filter.h" 33 #include "ipc/message_filter.h"
34 #include "mojo/edk/embedder/embedder.h" 34 #include "mojo/edk/embedder/embedder.h"
35 #include "services/resource_coordinator/public/interfaces/memory/constants.mojom .h"
35 #include "services/service_manager/public/cpp/interface_provider.h" 36 #include "services/service_manager/public/cpp/interface_provider.h"
36 37
37 #if defined(OS_LINUX) 38 #if defined(OS_LINUX)
38 #include "base/linux_util.h" 39 #include "base/linux_util.h"
39 #elif defined(OS_WIN) 40 #elif defined(OS_WIN)
40 #include "content/common/font_cache_dispatcher_win.h" 41 #include "content/common/font_cache_dispatcher_win.h"
41 #endif // OS_LINUX 42 #endif // OS_LINUX
42 43
43 namespace { 44 namespace {
44 45
45 // Global atomic to generate child process unique IDs. 46 // Global atomic to generate child process unique IDs.
46 base::StaticAtomicSequenceNumber g_unique_id; 47 base::StaticAtomicSequenceNumber g_unique_id;
47 48
48 } // namespace 49 } // namespace
49 50
50 namespace content { 51 namespace content {
51 52
52 int ChildProcessHost::kInvalidUniqueID = -1; 53 int ChildProcessHost::kInvalidUniqueID = -1;
53 54
54 uint64_t ChildProcessHost::kBrowserTracingProcessId =
55 std::numeric_limits<uint64_t>::max();
56
57 // static 55 // static
58 ChildProcessHost* ChildProcessHost::Create(ChildProcessHostDelegate* delegate) { 56 ChildProcessHost* ChildProcessHost::Create(ChildProcessHostDelegate* delegate) {
59 return new ChildProcessHostImpl(delegate); 57 return new ChildProcessHostImpl(delegate);
60 } 58 }
61 59
62 // static 60 // static
63 base::FilePath ChildProcessHost::GetChildPath(int flags) { 61 base::FilePath ChildProcessHost::GetChildPath(int flags) {
64 base::FilePath child_path; 62 base::FilePath child_path;
65 63
66 child_path = base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( 64 child_path = base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 196
199 uint64_t ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId( 197 uint64_t ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId(
200 int child_process_id) { 198 int child_process_id) {
201 // In single process mode, all the children are hosted in the same process, 199 // In single process mode, all the children are hosted in the same process,
202 // therefore the generated memory dump guids should not be conditioned by the 200 // therefore the generated memory dump guids should not be conditioned by the
203 // child process id. The clients need not be aware of SPM and the conversion 201 // child process id. The clients need not be aware of SPM and the conversion
204 // takes care of the SPM special case while translating child process ids to 202 // takes care of the SPM special case while translating child process ids to
205 // tracing process ids. 203 // tracing process ids.
206 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 204 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
207 switches::kSingleProcess)) 205 switches::kSingleProcess))
208 return ChildProcessHost::kBrowserTracingProcessId; 206 return memory_instrumentation::mojom::kServiceTracingProcessId;
209 207
210 // The hash value is incremented so that the tracing id is never equal to 208 // The hash value is incremented so that the tracing id is never equal to
211 // MemoryDumpManager::kInvalidTracingProcessId. 209 // MemoryDumpManager::kInvalidTracingProcessId.
212 return static_cast<uint64_t>( 210 return static_cast<uint64_t>(
213 base::Hash(reinterpret_cast<const char*>(&child_process_id), 211 base::Hash(reinterpret_cast<const char*>(&child_process_id),
214 sizeof(child_process_id))) + 212 sizeof(child_process_id))) +
215 1; 213 1;
216 } 214 }
217 215
218 bool ChildProcessHostImpl::OnMessageReceived(const IPC::Message& msg) { 216 bool ChildProcessHostImpl::OnMessageReceived(const IPC::Message& msg) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 void ChildProcessHostImpl::OnBadMessageReceived(const IPC::Message& message) { 279 void ChildProcessHostImpl::OnBadMessageReceived(const IPC::Message& message) {
282 delegate_->OnBadMessageReceived(message); 280 delegate_->OnBadMessageReceived(message);
283 } 281 }
284 282
285 void ChildProcessHostImpl::OnShutdownRequest() { 283 void ChildProcessHostImpl::OnShutdownRequest() {
286 if (delegate_->CanShutdown()) 284 if (delegate_->CanShutdown())
287 Send(new ChildProcessMsg_Shutdown()); 285 Send(new ChildProcessMsg_Shutdown());
288 } 286 }
289 287
290 } // namespace content 288 } // namespace content
OLDNEW
« no previous file with comments | « content/common/child_process_host_impl.h ('k') | content/public/app/mojo/content_browser_manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698