| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/memory/discardable_memory_ashmem_allocator.h" | 5 #include "base/memory/discardable_memory_ashmem_allocator.h" |
| 6 | 6 |
| 7 #include <sys/mman.h> | 7 #include <sys/mman.h> |
| 8 #include <unistd.h> | 8 #include <unistd.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| 11 #include <cmath> | 11 #include <cmath> |
| 12 #include <limits> | 12 #include <limits> |
| 13 #include <set> | 13 #include <set> |
| 14 #include <utility> | 14 #include <utility> |
| 15 | 15 |
| 16 #include "base/basictypes.h" | 16 #include "base/basictypes.h" |
| 17 #include "base/containers/hash_tables.h" | 17 #include "base/containers/hash_tables.h" |
| 18 #include "base/file_util.h" | 18 #include "base/files/file_util.h" |
| 19 #include "base/files/scoped_file.h" | 19 #include "base/files/scoped_file.h" |
| 20 #include "base/logging.h" | 20 #include "base/logging.h" |
| 21 #include "base/memory/scoped_vector.h" | 21 #include "base/memory/scoped_vector.h" |
| 22 #include "third_party/ashmem/ashmem.h" | 22 #include "third_party/ashmem/ashmem.h" |
| 23 | 23 |
| 24 // The allocator consists of three parts (classes): | 24 // The allocator consists of three parts (classes): |
| 25 // - DiscardableMemoryAshmemAllocator: entry point of all allocations (through | 25 // - DiscardableMemoryAshmemAllocator: entry point of all allocations (through |
| 26 // its Allocate() method) that are dispatched to the AshmemRegion instances | 26 // its Allocate() method) that are dispatched to the AshmemRegion instances |
| 27 // (which it owns). | 27 // (which it owns). |
| 28 // - AshmemRegion: manages allocations and destructions inside a single large | 28 // - AshmemRegion: manages allocations and destructions inside a single large |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 DCHECK_LE(ashmem_regions_.size(), 5U); | 519 DCHECK_LE(ashmem_regions_.size(), 5U); |
| 520 const ScopedVector<AshmemRegion>::iterator it = std::find( | 520 const ScopedVector<AshmemRegion>::iterator it = std::find( |
| 521 ashmem_regions_.begin(), ashmem_regions_.end(), region); | 521 ashmem_regions_.begin(), ashmem_regions_.end(), region); |
| 522 DCHECK(ashmem_regions_.end() != it); | 522 DCHECK(ashmem_regions_.end() != it); |
| 523 std::swap(*it, ashmem_regions_.back()); | 523 std::swap(*it, ashmem_regions_.back()); |
| 524 ashmem_regions_.pop_back(); | 524 ashmem_regions_.pop_back(); |
| 525 } | 525 } |
| 526 | 526 |
| 527 } // namespace internal | 527 } // namespace internal |
| 528 } // namespace base | 528 } // namespace base |
| OLD | NEW |