Chromium Code Reviews| 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 "base/metrics/field_trial.h" | 5 #include "base/metrics/field_trial.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
| 11 #include "base/build_time.h" | 11 #include "base/build_time.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/debug/activity_tracker.h" | 13 #include "base/debug/activity_tracker.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/metrics/field_trial_param_associator.h" | 15 #include "base/metrics/field_trial_param_associator.h" |
| 16 #include "base/process/memory.h" | 16 #include "base/process/memory.h" |
| 17 #include "base/process/process_handle.h" | |
| 18 #include "base/process/process_info.h" | |
| 17 #include "base/rand_util.h" | 19 #include "base/rand_util.h" |
| 18 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
| 19 #include "base/strings/string_split.h" | 21 #include "base/strings/string_split.h" |
| 20 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
| 21 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
| 22 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
| 23 #include "base/unguessable_token.h" | 25 #include "base/unguessable_token.h" |
| 24 | 26 |
| 25 // On POSIX, the fd is shared using the mapping in GlobalDescriptors. | 27 // On POSIX, the fd is shared using the mapping in GlobalDescriptors. |
| 26 #if defined(OS_POSIX) && !defined(OS_NACL) | 28 #if defined(OS_POSIX) && !defined(OS_NACL) |
| (...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1135 std::vector<base::StringPiece> tokens = base::SplitStringPiece( | 1137 std::vector<base::StringPiece> tokens = base::SplitStringPiece( |
| 1136 switch_value, ",", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL); | 1138 switch_value, ",", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL); |
| 1137 | 1139 |
| 1138 if (tokens.size() != 4) | 1140 if (tokens.size() != 4) |
| 1139 return SharedMemoryHandle(); | 1141 return SharedMemoryHandle(); |
| 1140 | 1142 |
| 1141 int field_trial_handle = 0; | 1143 int field_trial_handle = 0; |
| 1142 if (!base::StringToInt(tokens[0], &field_trial_handle)) | 1144 if (!base::StringToInt(tokens[0], &field_trial_handle)) |
| 1143 return SharedMemoryHandle(); | 1145 return SharedMemoryHandle(); |
| 1144 RawHandle handle = reinterpret_cast<RawHandle>(field_trial_handle); | 1146 RawHandle handle = reinterpret_cast<RawHandle>(field_trial_handle); |
| 1147 #if defined(OS_WIN) | |
| 1148 if (base::IsCurrentProcessElevated()) { | |
| 1149 // base::LaunchElevatedProcess doesn't have a way to duplicate the handle, | |
| 1150 // but this process can since by definition it's not sandboxed. | |
| 1151 base::ProcessId parent_pid = base::GetParentProcessId(GetCurrentProcess()); | |
| 1152 HANDLE parent_handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, parent_pid); | |
| 1153 DuplicateHandle(parent_handle, handle, GetCurrentProcess(), &handle, 0, | |
| 1154 FALSE, DUPLICATE_SAME_ACCESS); | |
| 1155 CloseHandle(parent_handle); | |
| 1156 } | |
|
(unused - use chromium)
2017/06/30 16:15:18
Having OS-dependent elevantion-level-dependent cod
Alexei Svitkine (slow)
2017/06/30 16:20:37
I agree this is not ideal. But I don't have a sugg
| |
| 1157 #endif | |
| 1145 | 1158 |
| 1146 base::UnguessableToken guid; | 1159 base::UnguessableToken guid; |
| 1147 if (!DeserializeGUIDFromStringPieces(tokens[1], tokens[2], &guid)) | 1160 if (!DeserializeGUIDFromStringPieces(tokens[1], tokens[2], &guid)) |
| 1148 return SharedMemoryHandle(); | 1161 return SharedMemoryHandle(); |
| 1149 | 1162 |
| 1150 int size; | 1163 int size; |
| 1151 if (!base::StringToInt(tokens[3], &size)) | 1164 if (!base::StringToInt(tokens[3], &size)) |
| 1152 return SharedMemoryHandle(); | 1165 return SharedMemoryHandle(); |
| 1153 | 1166 |
| 1154 return SharedMemoryHandle(handle, static_cast<size_t>(size), guid); | 1167 return SharedMemoryHandle(handle, static_cast<size_t>(size), guid); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1415 return; | 1428 return; |
| 1416 } | 1429 } |
| 1417 AutoLock auto_lock(global_->lock_); | 1430 AutoLock auto_lock(global_->lock_); |
| 1418 CHECK(!global_->PreLockedFind(trial->trial_name())) << trial->trial_name(); | 1431 CHECK(!global_->PreLockedFind(trial->trial_name())) << trial->trial_name(); |
| 1419 trial->AddRef(); | 1432 trial->AddRef(); |
| 1420 trial->SetTrialRegistered(); | 1433 trial->SetTrialRegistered(); |
| 1421 global_->registered_[trial->trial_name()] = trial; | 1434 global_->registered_[trial->trial_name()] = trial; |
| 1422 } | 1435 } |
| 1423 | 1436 |
| 1424 } // namespace base | 1437 } // namespace base |
| OLD | NEW |