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

Side by Side Diff: sandbox/linux/seccomp/maps.h

Issue 3225010: Pull seccomp-sandbox in via DEPS rather than using an in-tree copy... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 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 | Annotate | Revision Log
« no previous file with comments | « sandbox/linux/seccomp/madvise.cc ('k') | sandbox/linux/seccomp/maps.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 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 MAPS_H__
6 #define MAPS_H__
7
8 #include <elf.h>
9 #include <functional>
10 #include <map>
11 #include <string>
12
13 #include "allocator.h"
14
15 #if defined(__x86_64__)
16 typedef Elf64_Addr Elf_Addr;
17 #elif defined(__i386__)
18 typedef Elf32_Addr Elf_Addr;
19 #else
20 #error Undefined target platform
21 #endif
22
23 namespace playground {
24
25 class Library;
26 class Maps {
27 friend class Library;
28 public:
29 typedef std::basic_string<char, std::char_traits<char>,
30 SystemAllocator<char> > string;
31
32 Maps(int proc_self_maps);
33 ~Maps() { }
34
35 protected:
36 // A map with all the libraries currently loaded into the application.
37 // The key is a unique combination of device number, inode number, and
38 // file name. It should be treated as opaque.
39 typedef std::map<string, Library, std::less<string>,
40 SystemAllocator<std::pair<const string,
41 Library> > > LibraryMap;
42 friend class Iterator;
43 class Iterator {
44 friend class Maps;
45
46 protected:
47 explicit Iterator(Maps* maps);
48 Iterator(Maps* maps, bool at_beginning, bool at_end);
49 Maps::LibraryMap::iterator& getIterator() const;
50
51 public:
52 Iterator begin();
53 Iterator end();
54 Iterator& operator++();
55 Iterator operator++(int i);
56 Library* operator*() const;
57 bool operator==(const Iterator& iter) const;
58 bool operator!=(const Iterator& iter) const;
59 string name() const;
60
61 protected:
62 mutable LibraryMap::iterator iter_;
63 Maps *maps_;
64 bool at_beginning_;
65 bool at_end_;
66 };
67
68 public:
69 typedef class Iterator const_iterator;
70
71 const_iterator begin() {
72 return begin_iter_;
73 }
74
75 const_iterator end() {
76 return end_iter_;
77 }
78
79 char* allocNearAddr(char *addr, size_t size, int prot) const;
80
81 char* vsyscall() const { return vsyscall_; }
82
83 protected:
84 const int proc_self_maps_;
85 const Iterator begin_iter_;
86 const Iterator end_iter_;
87
88 LibraryMap libs_;
89 char* vsyscall_;
90 };
91
92 } // namespace
93
94 #endif // MAPS_H__
OLDNEW
« no previous file with comments | « sandbox/linux/seccomp/madvise.cc ('k') | sandbox/linux/seccomp/maps.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698