Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(767)

Side by Side Diff: base/metrics/field_trial.cc

Issue 2845113005: Replace base::SharedMemory read-only methods with GetReadOnlyHandle. (Closed)
Patch Set: Comments from thakis. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 DWORD access = SECTION_MAP_READ | SECTION_QUERY; 214 DWORD access = SECTION_MAP_READ | SECTION_QUERY;
215 HANDLE dst; 215 HANDLE dst;
216 if (!::DuplicateHandle(process, src, process, &dst, access, true, 0)) 216 if (!::DuplicateHandle(process, src, process, &dst, access, true, 0))
217 return kInvalidPlatformFile; 217 return kInvalidPlatformFile;
218 return dst; 218 return dst;
219 } 219 }
220 #endif 220 #endif
221 221
222 #if defined(OS_POSIX) && !defined(OS_NACL) 222 #if defined(OS_POSIX) && !defined(OS_NACL)
223 int CreateReadOnlyHandle(FieldTrialList::FieldTrialAllocator* allocator) { 223 int CreateReadOnlyHandle(FieldTrialList::FieldTrialAllocator* allocator) {
224 SharedMemoryHandle new_handle; 224 SharedMemoryHandle handle = allocator->shared_memory()->GetReadOnlyHandle();
225 allocator->shared_memory()->ShareReadOnlyToProcess(GetCurrentProcessHandle(), 225 return SharedMemory::GetFdFromSharedMemoryHandle(handle);
226 &new_handle);
227 return SharedMemory::GetFdFromSharedMemoryHandle(new_handle);
228 } 226 }
229 #endif 227 #endif
230 228
231 void OnOutOfMemory(size_t size) { 229 void OnOutOfMemory(size_t size) {
232 #if defined(OS_NACL) 230 #if defined(OS_NACL)
233 NOTREACHED(); 231 NOTREACHED();
234 #else 232 #else
235 TerminateBecauseOutOfMemory(size); 233 TerminateBecauseOutOfMemory(size);
236 #endif 234 #endif
237 } 235 }
(...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1355 return; 1353 return;
1356 } 1354 }
1357 AutoLock auto_lock(global_->lock_); 1355 AutoLock auto_lock(global_->lock_);
1358 CHECK(!global_->PreLockedFind(trial->trial_name())) << trial->trial_name(); 1356 CHECK(!global_->PreLockedFind(trial->trial_name())) << trial->trial_name();
1359 trial->AddRef(); 1357 trial->AddRef();
1360 trial->SetTrialRegistered(); 1358 trial->SetTrialRegistered();
1361 global_->registered_[trial->trial_name()] = trial; 1359 global_->registered_[trial->trial_name()] = trial;
1362 } 1360 }
1363 1361
1364 } // namespace base 1362 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/shared_memory_win.cc ('k') | content/browser/renderer_host/clipboard_message_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698