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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 // places in the code a value of 0 (rather than kInvalidUniqueID) was used as | 194 // places in the code a value of 0 (rather than kInvalidUniqueID) was used as |
192 // an invalid value. So we retain those semantics. | 195 // an invalid value. So we retain those semantics. |
193 int id = g_unique_id.GetNext() + 1; | 196 int id = g_unique_id.GetNext() + 1; |
194 | 197 |
195 CHECK_NE(0, id); | 198 CHECK_NE(0, id); |
196 CHECK_NE(kInvalidUniqueID, id); | 199 CHECK_NE(kInvalidUniqueID, id); |
197 | 200 |
198 return id; | 201 return id; |
199 } | 202 } |
200 | 203 |
| 204 void ChildProcessHostImpl::CopyFeatureAndFieldTrialFlags( |
| 205 base::CommandLine* cmd_line) { |
| 206 std::string enabled_features; |
| 207 std::string disabled_features; |
| 208 base::FeatureList::GetInstance()->GetFeatureOverrides(&enabled_features, |
| 209 &disabled_features); |
| 210 if (!enabled_features.empty()) |
| 211 cmd_line->AppendSwitchASCII(switches::kEnableFeatures, enabled_features); |
| 212 if (!disabled_features.empty()) |
| 213 cmd_line->AppendSwitchASCII(switches::kDisableFeatures, disabled_features); |
| 214 |
| 215 // If we run base::FieldTrials, we want to pass to their state to the |
| 216 // child process so that it can act in accordance with each state. |
| 217 std::string field_trial_states; |
| 218 base::FieldTrialList::AllStatesToString(&field_trial_states); |
| 219 if (!field_trial_states.empty()) { |
| 220 cmd_line->AppendSwitchASCII(switches::kForceFieldTrials, |
| 221 field_trial_states); |
| 222 } |
| 223 } |
| 224 |
201 uint64_t ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId( | 225 uint64_t ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId( |
202 int child_process_id) { | 226 int child_process_id) { |
203 // In single process mode, all the children are hosted in the same process, | 227 // In single process mode, all the children are hosted in the same process, |
204 // therefore the generated memory dump guids should not be conditioned by the | 228 // therefore the generated memory dump guids should not be conditioned by the |
205 // child process id. The clients need not be aware of SPM and the conversion | 229 // child process id. The clients need not be aware of SPM and the conversion |
206 // takes care of the SPM special case while translating child process ids to | 230 // takes care of the SPM special case while translating child process ids to |
207 // tracing process ids. | 231 // tracing process ids. |
208 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 232 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
209 switches::kSingleProcess)) | 233 switches::kSingleProcess)) |
210 return ChildProcessHost::kBrowserTracingProcessId; | 234 return ChildProcessHost::kBrowserTracingProcessId; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 } | 348 } |
325 | 349 |
326 void ChildProcessHostImpl::OnDeletedGpuMemoryBuffer( | 350 void ChildProcessHostImpl::OnDeletedGpuMemoryBuffer( |
327 gfx::GpuMemoryBufferId id, | 351 gfx::GpuMemoryBufferId id, |
328 const gpu::SyncToken& sync_token) { | 352 const gpu::SyncToken& sync_token) { |
329 // Note: Nothing to do here as ownership of shared memory backed | 353 // Note: Nothing to do here as ownership of shared memory backed |
330 // GpuMemoryBuffers is passed with IPC. | 354 // GpuMemoryBuffers is passed with IPC. |
331 } | 355 } |
332 | 356 |
333 } // namespace content | 357 } // namespace content |
OLD | NEW |