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

Side by Side Diff: base/memory/discardable_memory_allocator_android.h

Issue 136723005: Align ashmem region sizes to page size after ashmem creation failed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address William's comments Created 6 years, 11 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | base/memory/discardable_memory_allocator_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef BASE_MEMORY_DISCARDABLE_MEMORY_ALLOCATOR_H_ 5 #ifndef BASE_MEMORY_DISCARDABLE_MEMORY_ALLOCATOR_H_
6 #define BASE_MEMORY_DISCARDABLE_MEMORY_ALLOCATOR_H_ 6 #define BASE_MEMORY_DISCARDABLE_MEMORY_ALLOCATOR_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/base_export.h" 10 #include "base/base_export.h"
(...skipping 26 matching lines...) Expand all
37 // ashmem regions and is expected to be greater or equal than 32 MBytes. 37 // ashmem regions and is expected to be greater or equal than 32 MBytes.
38 DiscardableMemoryAllocator(const std::string& name, 38 DiscardableMemoryAllocator(const std::string& name,
39 size_t ashmem_region_size); 39 size_t ashmem_region_size);
40 40
41 ~DiscardableMemoryAllocator(); 41 ~DiscardableMemoryAllocator();
42 42
43 // Note that the allocator must outlive the returned DiscardableMemory 43 // Note that the allocator must outlive the returned DiscardableMemory
44 // instance. 44 // instance.
45 scoped_ptr<DiscardableMemory> Allocate(size_t size); 45 scoped_ptr<DiscardableMemory> Allocate(size_t size);
46 46
47 // Returns the size of the last ashmem region which was created. This is used
48 // for testing only.
49 size_t last_ashmem_region_size() const;
50
47 private: 51 private:
48 class AshmemRegion; 52 class AshmemRegion;
49 class DiscardableAshmemChunk; 53 class DiscardableAshmemChunk;
50 54
51 void DeleteAshmemRegion_Locked(AshmemRegion* region); 55 void DeleteAshmemRegion_Locked(AshmemRegion* region);
52 56
53 base::ThreadChecker thread_checker_; 57 ThreadChecker thread_checker_;
54 const std::string name_; 58 const std::string name_;
55 const size_t ashmem_region_size_; 59 const size_t ashmem_region_size_;
56 base::Lock lock_; 60 mutable Lock lock_;
61 size_t last_ashmem_region_size_;
57 ScopedVector<AshmemRegion> ashmem_regions_; 62 ScopedVector<AshmemRegion> ashmem_regions_;
58 63
59 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryAllocator); 64 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryAllocator);
60 }; 65 };
61 66
62 } // namespace internal 67 } // namespace internal
63 } // namespace base 68 } // namespace base
64 69
65 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_ALLOCATOR_H_ 70 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_ALLOCATOR_H_
OLDNEW
« no previous file with comments | « no previous file | base/memory/discardable_memory_allocator_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698