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/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 Loading... |
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" | |
36 #include "services/service_manager/public/cpp/interface_provider.h" | 35 #include "services/service_manager/public/cpp/interface_provider.h" |
37 | 36 |
38 #if defined(OS_LINUX) | 37 #if defined(OS_LINUX) |
39 #include "base/linux_util.h" | 38 #include "base/linux_util.h" |
40 #elif defined(OS_WIN) | 39 #elif defined(OS_WIN) |
41 #include "content/common/font_cache_dispatcher_win.h" | 40 #include "content/common/font_cache_dispatcher_win.h" |
42 #endif // OS_LINUX | 41 #endif // OS_LINUX |
43 | 42 |
44 namespace { | 43 namespace { |
45 | 44 |
46 // Global atomic to generate child process unique IDs. | 45 // Global atomic to generate child process unique IDs. |
47 base::StaticAtomicSequenceNumber g_unique_id; | 46 base::StaticAtomicSequenceNumber g_unique_id; |
48 | 47 |
49 } // namespace | 48 } // namespace |
50 | 49 |
51 namespace content { | 50 namespace content { |
52 | 51 |
53 int ChildProcessHost::kInvalidUniqueID = -1; | 52 int ChildProcessHost::kInvalidUniqueID = -1; |
54 | 53 |
| 54 uint64_t ChildProcessHost::kBrowserTracingProcessId = |
| 55 std::numeric_limits<uint64_t>::max(); |
| 56 |
55 // static | 57 // static |
56 ChildProcessHost* ChildProcessHost::Create(ChildProcessHostDelegate* delegate) { | 58 ChildProcessHost* ChildProcessHost::Create(ChildProcessHostDelegate* delegate) { |
57 return new ChildProcessHostImpl(delegate); | 59 return new ChildProcessHostImpl(delegate); |
58 } | 60 } |
59 | 61 |
60 // static | 62 // static |
61 base::FilePath ChildProcessHost::GetChildPath(int flags) { | 63 base::FilePath ChildProcessHost::GetChildPath(int flags) { |
62 base::FilePath child_path; | 64 base::FilePath child_path; |
63 | 65 |
64 child_path = base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( | 66 child_path = base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 | 198 |
197 uint64_t ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId( | 199 uint64_t ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId( |
198 int child_process_id) { | 200 int child_process_id) { |
199 // In single process mode, all the children are hosted in the same process, | 201 // In single process mode, all the children are hosted in the same process, |
200 // therefore the generated memory dump guids should not be conditioned by the | 202 // therefore the generated memory dump guids should not be conditioned by the |
201 // child process id. The clients need not be aware of SPM and the conversion | 203 // child process id. The clients need not be aware of SPM and the conversion |
202 // takes care of the SPM special case while translating child process ids to | 204 // takes care of the SPM special case while translating child process ids to |
203 // tracing process ids. | 205 // tracing process ids. |
204 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 206 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
205 switches::kSingleProcess)) | 207 switches::kSingleProcess)) |
206 return memory_instrumentation::mojom::kServiceTracingProcessId; | 208 return ChildProcessHost::kBrowserTracingProcessId; |
207 | 209 |
208 // The hash value is incremented so that the tracing id is never equal to | 210 // The hash value is incremented so that the tracing id is never equal to |
209 // MemoryDumpManager::kInvalidTracingProcessId. | 211 // MemoryDumpManager::kInvalidTracingProcessId. |
210 return static_cast<uint64_t>( | 212 return static_cast<uint64_t>( |
211 base::Hash(reinterpret_cast<const char*>(&child_process_id), | 213 base::Hash(reinterpret_cast<const char*>(&child_process_id), |
212 sizeof(child_process_id))) + | 214 sizeof(child_process_id))) + |
213 1; | 215 1; |
214 } | 216 } |
215 | 217 |
216 bool ChildProcessHostImpl::OnMessageReceived(const IPC::Message& msg) { | 218 bool ChildProcessHostImpl::OnMessageReceived(const IPC::Message& msg) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 void ChildProcessHostImpl::OnBadMessageReceived(const IPC::Message& message) { | 281 void ChildProcessHostImpl::OnBadMessageReceived(const IPC::Message& message) { |
280 delegate_->OnBadMessageReceived(message); | 282 delegate_->OnBadMessageReceived(message); |
281 } | 283 } |
282 | 284 |
283 void ChildProcessHostImpl::OnShutdownRequest() { | 285 void ChildProcessHostImpl::OnShutdownRequest() { |
284 if (delegate_->CanShutdown()) | 286 if (delegate_->CanShutdown()) |
285 Send(new ChildProcessMsg_Shutdown()); | 287 Send(new ChildProcessMsg_Shutdown()); |
286 } | 288 } |
287 | 289 |
288 } // namespace content | 290 } // namespace content |
OLD | NEW |