diff options
Diffstat (limited to 'chromium/base/metrics/field_trial.cc')
-rw-r--r-- | chromium/base/metrics/field_trial.cc | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/chromium/base/metrics/field_trial.cc b/chromium/base/metrics/field_trial.cc index 7f7b372da00..0214f5a876c 100644 --- a/chromium/base/metrics/field_trial.cc +++ b/chromium/base/metrics/field_trial.cc @@ -229,7 +229,20 @@ bool DeserializeGUIDFromStringPieces(base::StringPiece first, *guid = base::UnguessableToken::Deserialize(high, low); return true; } -#endif + +// Extract a read-only SharedMemoryHandle from an existing |shared_memory| +// handle. Note that on Android, this also makes the whole region read-only. +SharedMemoryHandle GetSharedMemoryReadOnlyHandle(SharedMemory* shared_memory) { + SharedMemoryHandle result = shared_memory->GetReadOnlyHandle(); +#if defined(OS_ANDROID) + // On Android, turn the region read-only. This prevents any future + // writable mapping attempts, but the original one in |shm| survives + // and is still usable in the current process. + result.SetRegionReadOnly(); +#endif // OS_ANDROID + return result; +} +#endif // !OS_NACL } // namespace @@ -1306,10 +1319,8 @@ void FieldTrialList::InstantiateFieldTrialAllocatorIfNeeded() { global_->field_trial_allocator_.get()); #if !defined(OS_NACL) - // Set |readonly_allocator_handle_| so we can pass it to be inherited and - // via the command line. - global_->readonly_allocator_handle_ = - global_->field_trial_allocator_->shared_memory()->GetReadOnlyHandle(); + global_->readonly_allocator_handle_ = GetSharedMemoryReadOnlyHandle( + global_->field_trial_allocator_->shared_memory()); #endif } |