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/base_switches.h" |
10 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/feature_list.h" |
11 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
12 #include "base/hash.h" | 14 #include "base/hash.h" |
13 #include "base/logging.h" | 15 #include "base/logging.h" |
14 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 17 #include "base/metrics/field_trial.h" |
15 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
16 #include "base/numerics/safe_math.h" | 19 #include "base/numerics/safe_math.h" |
17 #include "base/path_service.h" | 20 #include "base/path_service.h" |
18 #include "base/process/process_metrics.h" | 21 #include "base/process/process_metrics.h" |
19 #include "base/rand_util.h" | 22 #include "base/rand_util.h" |
20 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
21 #include "base/synchronization/lock.h" | 24 #include "base/synchronization/lock.h" |
22 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 25 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
23 #include "build/build_config.h" | 26 #include "build/build_config.h" |
24 #include "content/common/child_process_messages.h" | 27 #include "content/common/child_process_messages.h" |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 // places in the code a value of 0 (rather than kInvalidUniqueID) was used as | 199 // places in the code a value of 0 (rather than kInvalidUniqueID) was used as |
197 // an invalid value. So we retain those semantics. | 200 // an invalid value. So we retain those semantics. |
198 int id = g_unique_id.GetNext() + 1; | 201 int id = g_unique_id.GetNext() + 1; |
199 | 202 |
200 CHECK_NE(0, id); | 203 CHECK_NE(0, id); |
201 CHECK_NE(kInvalidUniqueID, id); | 204 CHECK_NE(kInvalidUniqueID, id); |
202 | 205 |
203 return id; | 206 return id; |
204 } | 207 } |
205 | 208 |
| 209 void ChildProcessHostImpl::CopyEnableDisableFeatureFlags( |
| 210 base::CommandLine* cmd_line) { |
| 211 std::string enabled_features; |
| 212 std::string disabled_features; |
| 213 base::FeatureList::GetInstance()->GetFeatureOverrides(&enabled_features, |
| 214 &disabled_features); |
| 215 if (!enabled_features.empty()) |
| 216 cmd_line->AppendSwitchASCII(switches::kEnableFeatures, enabled_features); |
| 217 if (!disabled_features.empty()) |
| 218 cmd_line->AppendSwitchASCII(switches::kDisableFeatures, disabled_features); |
| 219 |
| 220 // If we run base::FieldTrials, we want to pass to their state to the |
| 221 // child process so that it can act in accordance with each state, or record |
| 222 // histograms relating to the base::FieldTrial states. |
| 223 std::string field_trial_states; |
| 224 base::FieldTrialList::AllStatesToString(&field_trial_states); |
| 225 if (!field_trial_states.empty()) { |
| 226 cmd_line->AppendSwitchASCII(switches::kForceFieldTrials, |
| 227 field_trial_states); |
| 228 } |
| 229 } |
| 230 |
206 uint64_t ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId( | 231 uint64_t ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId( |
207 int child_process_id) { | 232 int child_process_id) { |
208 // In single process mode, all the children are hosted in the same process, | 233 // In single process mode, all the children are hosted in the same process, |
209 // therefore the generated memory dump guids should not be conditioned by the | 234 // therefore the generated memory dump guids should not be conditioned by the |
210 // child process id. The clients need not be aware of SPM and the conversion | 235 // child process id. The clients need not be aware of SPM and the conversion |
211 // takes care of the SPM special case while translating child process ids to | 236 // takes care of the SPM special case while translating child process ids to |
212 // tracing process ids. | 237 // tracing process ids. |
213 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 238 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
214 switches::kSingleProcess)) | 239 switches::kSingleProcess)) |
215 return ChildProcessHost::kBrowserTracingProcessId; | 240 return ChildProcessHost::kBrowserTracingProcessId; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 } | 354 } |
330 | 355 |
331 void ChildProcessHostImpl::OnDeletedGpuMemoryBuffer( | 356 void ChildProcessHostImpl::OnDeletedGpuMemoryBuffer( |
332 gfx::GpuMemoryBufferId id, | 357 gfx::GpuMemoryBufferId id, |
333 const gpu::SyncToken& sync_token) { | 358 const gpu::SyncToken& sync_token) { |
334 // Note: Nothing to do here as ownership of shared memory backed | 359 // Note: Nothing to do here as ownership of shared memory backed |
335 // GpuMemoryBuffers is passed with IPC. | 360 // GpuMemoryBuffers is passed with IPC. |
336 } | 361 } |
337 | 362 |
338 } // namespace content | 363 } // namespace content |
OLD | NEW |