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