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 "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 Loading... |
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 Loading... |
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 |
OLD | NEW |