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

Side by Side Diff: runtime/bin/file.h

Issue 2694103004: Cleanup app snapshots on isolate/vm exit. (Closed)
Patch Set: merge Created 3 years, 10 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
« no previous file with comments | « runtime/bin/extensions_win.cc ('k') | runtime/bin/file_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 (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef RUNTIME_BIN_FILE_H_ 5 #ifndef RUNTIME_BIN_FILE_H_
6 #define RUNTIME_BIN_FILE_H_ 6 #define RUNTIME_BIN_FILE_H_
7 7
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <string.h> 10 #include <string.h>
11 #include <sys/types.h> 11 #include <sys/types.h>
12 12
13 #include "bin/builtin.h" 13 #include "bin/builtin.h"
14 #include "bin/dartutils.h" 14 #include "bin/dartutils.h"
15 #include "bin/log.h" 15 #include "bin/log.h"
16 #include "bin/reference_counting.h" 16 #include "bin/reference_counting.h"
17 17
18 namespace dart { 18 namespace dart {
19 namespace bin { 19 namespace bin {
20 20
21 // Forward declaration. 21 // Forward declaration.
22 class FileHandle; 22 class FileHandle;
23 23
24 class MappedMemory {
25 public:
26 MappedMemory(void* address, intptr_t size) : address_(address), size_(size) {}
27 ~MappedMemory() { Unmap(); }
28
29 void* address() const { return address_; }
30 intptr_t size() const { return size_; }
31
32 private:
33 void Unmap();
34
35 void* address_;
36 intptr_t size_;
37
38 DISALLOW_COPY_AND_ASSIGN(MappedMemory);
39 };
40
24 class File : public ReferenceCounted<File> { 41 class File : public ReferenceCounted<File> {
25 public: 42 public:
26 enum FileOpenMode { 43 enum FileOpenMode {
27 kRead = 0, 44 kRead = 0,
28 kWrite = 1, 45 kWrite = 1,
29 kTruncate = 1 << 2, 46 kTruncate = 1 << 2,
30 kWriteOnly = 1 << 3, 47 kWriteOnly = 1 << 3,
31 kWriteTruncate = kWrite | kTruncate, 48 kWriteTruncate = kWrite | kTruncate,
32 kWriteOnlyTruncate = kWriteOnly | kTruncate 49 kWriteOnlyTruncate = kWriteOnly | kTruncate
33 }; 50 };
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 kLockBlockingExclusive = 4, 93 kLockBlockingExclusive = 4,
77 kLockMax = 4 94 kLockMax = 4
78 }; 95 };
79 96
80 intptr_t GetFD(); 97 intptr_t GetFD();
81 98
82 enum MapType { 99 enum MapType {
83 kReadOnly = 0, 100 kReadOnly = 0,
84 kReadExecute = 1, 101 kReadExecute = 1,
85 }; 102 };
86 void* Map(MapType type, int64_t position, int64_t length); 103 MappedMemory* Map(MapType type, int64_t position, int64_t length);
87 104
88 // Read/Write attempt to transfer num_bytes to/from buffer. It returns 105 // Read/Write attempt to transfer num_bytes to/from buffer. It returns
89 // the number of bytes read/written. 106 // the number of bytes read/written.
90 int64_t Read(void* buffer, int64_t num_bytes); 107 int64_t Read(void* buffer, int64_t num_bytes);
91 int64_t Write(const void* buffer, int64_t num_bytes); 108 int64_t Write(const void* buffer, int64_t num_bytes);
92 109
93 // ReadFully and WriteFully do attempt to transfer num_bytes to/from 110 // ReadFully and WriteFully do attempt to transfer num_bytes to/from
94 // the buffer. In the event of short accesses they will loop internally until 111 // the buffer. In the event of short accesses they will loop internally until
95 // the whole buffer has been transferred or an error occurs. If an error 112 // the whole buffer has been transferred or an error occurs. If an error
96 // occurred the result will be set to false. 113 // occurred the result will be set to false.
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 Dart_WeakPersistentHandle weak_handle_; 247 Dart_WeakPersistentHandle weak_handle_;
231 248
232 friend class ReferenceCounted<File>; 249 friend class ReferenceCounted<File>;
233 DISALLOW_COPY_AND_ASSIGN(File); 250 DISALLOW_COPY_AND_ASSIGN(File);
234 }; 251 };
235 252
236 } // namespace bin 253 } // namespace bin
237 } // namespace dart 254 } // namespace dart
238 255
239 #endif // RUNTIME_BIN_FILE_H_ 256 #endif // RUNTIME_BIN_FILE_H_
OLDNEW
« no previous file with comments | « runtime/bin/extensions_win.cc ('k') | runtime/bin/file_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698