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

Side by Side Diff: content/browser/loader/resource_buffer.cc

Issue 1453383002: base: Make shared memory backed by Mach primitives by default. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Force a POSIX test to use POSIX shared memory. Created 5 years, 1 month 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
« no previous file with comments | « base/memory/shared_memory_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/browser/loader/resource_buffer.h" 5 #include "content/browser/loader/resource_buffer.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 CHECK(!IsInitialized()); 47 CHECK(!IsInitialized());
48 48
49 // It would be wasteful if these are not multiples of min_allocation_size. 49 // It would be wasteful if these are not multiples of min_allocation_size.
50 CHECK_EQ(0, buffer_size % min_allocation_size); 50 CHECK_EQ(0, buffer_size % min_allocation_size);
51 CHECK_EQ(0, max_allocation_size % min_allocation_size); 51 CHECK_EQ(0, max_allocation_size % min_allocation_size);
52 52
53 buf_size_ = buffer_size; 53 buf_size_ = buffer_size;
54 min_alloc_size_ = min_allocation_size; 54 min_alloc_size_ = min_allocation_size;
55 max_alloc_size_ = max_allocation_size; 55 max_alloc_size_ = max_allocation_size;
56 56
57 #if defined(OS_MACOSX) && !defined(OS_IOS)
58 return shared_mem_.CreateAndMapAnonymousMach(buf_size_);
59 #else
60 return shared_mem_.CreateAndMapAnonymous(buf_size_); 57 return shared_mem_.CreateAndMapAnonymous(buf_size_);
61 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
62 } 58 }
63 59
64 bool ResourceBuffer::IsInitialized() const { 60 bool ResourceBuffer::IsInitialized() const {
65 return shared_mem_.memory() != NULL; 61 return shared_mem_.memory() != NULL;
66 } 62 }
67 63
68 bool ResourceBuffer::ShareToProcess( 64 bool ResourceBuffer::ShareToProcess(
69 base::ProcessHandle process_handle, 65 base::ProcessHandle process_handle,
70 base::SharedMemoryHandle* shared_memory_handle, 66 base::SharedMemoryHandle* shared_memory_handle,
71 int* shared_memory_size) { 67 int* shared_memory_size) {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 CHECK(alloc_sizes_.empty()); 172 CHECK(alloc_sizes_.empty());
177 alloc_start_ = -1; 173 alloc_start_ = -1;
178 alloc_end_ = -1; 174 alloc_end_ = -1;
179 } else if (alloc_start_ == buf_size_) { 175 } else if (alloc_start_ == buf_size_) {
180 CHECK(!alloc_sizes_.empty()); 176 CHECK(!alloc_sizes_.empty());
181 alloc_start_ = 0; 177 alloc_start_ = 0;
182 } 178 }
183 } 179 }
184 180
185 } // namespace content 181 } // namespace content
OLDNEW
« no previous file with comments | « base/memory/shared_memory_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698