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

Side by Side Diff: runtime/bin/file_android.cc

Issue 2405393002: Use a single file for app snapshots. (Closed)
Patch Set: gen_snapshot Created 4 years, 2 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/file.h ('k') | runtime/bin/file_fuchsia.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_ANDROID) 6 #if defined(TARGET_OS_ANDROID)
7 7
8 #include "bin/file.h" 8 #include "bin/file.h"
9 9
10 #include <errno.h> // NOLINT 10 #include <errno.h> // NOLINT
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 intptr_t File::GetFD() { 71 intptr_t File::GetFD() {
72 return handle_->fd(); 72 return handle_->fd();
73 } 73 }
74 74
75 75
76 bool File::IsClosed() { 76 bool File::IsClosed() {
77 return handle_->fd() == kClosedFd; 77 return handle_->fd() == kClosedFd;
78 } 78 }
79 79
80 80
81 void* File::MapExecutable(intptr_t* len) { 81 void* File::Map(MapType type, int64_t position, int64_t length) {
82 ASSERT(handle_->fd() >= 0); 82 ASSERT(handle_->fd() >= 0);
83 83 int prot = PROT_NONE;
84 intptr_t length = Length(); 84 switch (type) {
85 void* addr = mmap(0, length, 85 case kReadOnly:
86 PROT_READ | PROT_EXEC, MAP_PRIVATE, 86 prot = PROT_READ;
87 handle_->fd(), 0); 87 break;
88 case kReadExecute:
89 prot = PROT_READ | PROT_EXEC;
90 break;
91 default:
92 return NULL;
93 }
94 void* addr = mmap(NULL, length, prot, MAP_PRIVATE,
95 handle_->fd(), position);
88 if (addr == MAP_FAILED) { 96 if (addr == MAP_FAILED) {
89 *len = -1; 97 return NULL;
90 } else {
91 *len = length;
92 } 98 }
93 return addr; 99 return addr;
94 } 100 }
95 101
96 102
97 int64_t File::Read(void* buffer, int64_t num_bytes) { 103 int64_t File::Read(void* buffer, int64_t num_bytes) {
98 ASSERT(handle_->fd() >= 0); 104 ASSERT(handle_->fd() >= 0);
99 return TEMP_FAILURE_RETRY(read(handle_->fd(), buffer, num_bytes)); 105 return TEMP_FAILURE_RETRY(read(handle_->fd(), buffer, num_bytes));
100 } 106 }
101 107
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 return ((file_1_info.st_ino == file_2_info.st_ino) && 514 return ((file_1_info.st_ino == file_2_info.st_ino) &&
509 (file_1_info.st_dev == file_2_info.st_dev)) ? 515 (file_1_info.st_dev == file_2_info.st_dev)) ?
510 File::kIdentical : 516 File::kIdentical :
511 File::kDifferent; 517 File::kDifferent;
512 } 518 }
513 519
514 } // namespace bin 520 } // namespace bin
515 } // namespace dart 521 } // namespace dart
516 522
517 #endif // defined(TARGET_OS_ANDROID) 523 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« no previous file with comments | « runtime/bin/file.h ('k') | runtime/bin/file_fuchsia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698