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

Side by Side Diff: base/android/linker/crazy_linker/src/crazy_linker_ashmem.h

Issue 23717023: Android: Add chrome-specific dynamic linker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename library Created 7 years, 3 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
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CRAZY_LINKER_ASHMEM_H
6 #define CRAZY_LINKER_ASHMEM_H
7
8 #include <unistd.h>
9
10 namespace crazy {
11
12 // Helper class to hold a scoped ashmem region file descriptor.
13 class AshmemRegion {
14 public:
15 AshmemRegion() : fd_(-1) {}
16
17 ~AshmemRegion() {
18 Reset(-1);
19 }
20
21 int Get() const { return fd_; }
22
23 int Release() {
24 int ret = fd_;
25 fd_ = -1;
26 return ret;
27 }
28
29 void Reset(int fd) {
30 if (fd_ != -1) {
31 ::close(fd_);
32 }
33 fd_ = fd;
34 }
35
36 // Try to allocate a new ashmem region of |region_size|
37 // (page-aligned) bytes. |region_name| is optional, if not NULL
38 // it will be the name of the region (only used for debugging).
39 // Returns true on success, false otherwise.
40 bool Allocate(size_t region_size, const char* region_name);
41
42 // Change the protection flags of the region. Returns true on success.
43 bool SetProtectionFlags(int prot_flags);
44
45 private:
46 AshmemRegion(const AshmemRegion& other);
47 AshmemRegion& operator=(const AshmemRegion& other);
48
49 int fd_;
50 };
51
52 } // namespace crazy
53
54 #endif // CRAZY_LINKER_ASHMEM_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698