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

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

Issue 1472313002: Revert of base: Make shared memory backed by Mach primitives by default. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
57 return shared_mem_.CreateAndMapAnonymous(buf_size_); 60 return shared_mem_.CreateAndMapAnonymous(buf_size_);
61 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
58 } 62 }
59 63
60 bool ResourceBuffer::IsInitialized() const { 64 bool ResourceBuffer::IsInitialized() const {
61 return shared_mem_.memory() != NULL; 65 return shared_mem_.memory() != NULL;
62 } 66 }
63 67
64 bool ResourceBuffer::ShareToProcess( 68 bool ResourceBuffer::ShareToProcess(
65 base::ProcessHandle process_handle, 69 base::ProcessHandle process_handle,
66 base::SharedMemoryHandle* shared_memory_handle, 70 base::SharedMemoryHandle* shared_memory_handle,
67 int* shared_memory_size) { 71 int* shared_memory_size) {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 CHECK(alloc_sizes_.empty()); 176 CHECK(alloc_sizes_.empty());
173 alloc_start_ = -1; 177 alloc_start_ = -1;
174 alloc_end_ = -1; 178 alloc_end_ = -1;
175 } else if (alloc_start_ == buf_size_) { 179 } else if (alloc_start_ == buf_size_) {
176 CHECK(!alloc_sizes_.empty()); 180 CHECK(!alloc_sizes_.empty());
177 alloc_start_ = 0; 181 alloc_start_ = 0;
178 } 182 }
179 } 183 }
180 184
181 } // namespace content 185 } // 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