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

Side by Side Diff: base/android/library_loader/library_prefetcher.cc

Issue 1233043003: Remove some legacy versions of StartsWith and EndsWith. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 | « no previous file | base/strings/string_util.h » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "base/android/library_loader/library_prefetcher.h" 5 #include "base/android/library_loader/library_prefetcher.h"
6 6
7 #include <sys/resource.h> 7 #include <sys/resource.h>
8 #include <sys/wait.h> 8 #include <sys/wait.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 #include <utility> 10 #include <utility>
(...skipping 18 matching lines...) Expand all
29 // APK. 29 // APK.
30 const char* kSuffixesToMatch[] = {kLibchromeSuffix, "base.apk"}; 30 const char* kSuffixesToMatch[] = {kLibchromeSuffix, "base.apk"};
31 31
32 bool IsReadableAndPrivate(const base::debug::MappedMemoryRegion& region) { 32 bool IsReadableAndPrivate(const base::debug::MappedMemoryRegion& region) {
33 return region.permissions & base::debug::MappedMemoryRegion::READ && 33 return region.permissions & base::debug::MappedMemoryRegion::READ &&
34 region.permissions & base::debug::MappedMemoryRegion::PRIVATE; 34 region.permissions & base::debug::MappedMemoryRegion::PRIVATE;
35 } 35 }
36 36
37 bool PathMatchesSuffix(const std::string& path) { 37 bool PathMatchesSuffix(const std::string& path) {
38 for (size_t i = 0; i < arraysize(kSuffixesToMatch); i++) { 38 for (size_t i = 0; i < arraysize(kSuffixesToMatch); i++) {
39 if (EndsWith(path, kSuffixesToMatch[i], true)) { 39 if (EndsWith(path, kSuffixesToMatch[i], CompareCase::SENSITIVE)) {
40 return true; 40 return true;
41 } 41 }
42 } 42 }
43 return false; 43 return false;
44 } 44 }
45 45
46 // For each range, reads a byte per page to force it into the page cache. 46 // For each range, reads a byte per page to force it into the page cache.
47 // Heap allocations, syscalls and library functions are not allowed in this 47 // Heap allocations, syscalls and library functions are not allowed in this
48 // function. 48 // function.
49 // Returns true for success. 49 // Returns true for success.
(...skipping 25 matching lines...) Expand all
75 return PathMatchesSuffix(region.path) && 75 return PathMatchesSuffix(region.path) &&
76 IsReadableAndPrivate(region); // .text and .data mappings are private. 76 IsReadableAndPrivate(region); // .text and .data mappings are private.
77 } 77 }
78 78
79 // static 79 // static
80 void NativeLibraryPrefetcher::FilterLibchromeRangesOnlyIfPossible( 80 void NativeLibraryPrefetcher::FilterLibchromeRangesOnlyIfPossible(
81 const std::vector<base::debug::MappedMemoryRegion>& regions, 81 const std::vector<base::debug::MappedMemoryRegion>& regions,
82 std::vector<AddressRange>* ranges) { 82 std::vector<AddressRange>* ranges) {
83 bool has_libchrome_region = false; 83 bool has_libchrome_region = false;
84 for (const base::debug::MappedMemoryRegion& region : regions) { 84 for (const base::debug::MappedMemoryRegion& region : regions) {
85 if (EndsWith(region.path, kLibchromeSuffix, true)) { 85 if (EndsWith(region.path, kLibchromeSuffix, CompareCase::SENSITIVE)) {
86 has_libchrome_region = true; 86 has_libchrome_region = true;
87 break; 87 break;
88 } 88 }
89 } 89 }
90 for (const base::debug::MappedMemoryRegion& region : regions) { 90 for (const base::debug::MappedMemoryRegion& region : regions) {
91 if (has_libchrome_region && 91 if (has_libchrome_region &&
92 !EndsWith(region.path, kLibchromeSuffix, true)) { 92 !EndsWith(region.path, kLibchromeSuffix, CompareCase::SENSITIVE)) {
93 continue; 93 continue;
94 } 94 }
95 ranges->push_back(std::make_pair(region.start, region.end)); 95 ranges->push_back(std::make_pair(region.start, region.end));
96 } 96 }
97 } 97 }
98 98
99 // static 99 // static
100 bool NativeLibraryPrefetcher::FindRanges(std::vector<AddressRange>* ranges) { 100 bool NativeLibraryPrefetcher::FindRanges(std::vector<AddressRange>* ranges) {
101 std::string proc_maps; 101 std::string proc_maps;
102 if (!base::debug::ReadProcMaps(&proc_maps)) 102 if (!base::debug::ReadProcMaps(&proc_maps))
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 if (WIFEXITED(status)) { 141 if (WIFEXITED(status)) {
142 return WEXITSTATUS(status) == 0; 142 return WEXITSTATUS(status) == 0;
143 } 143 }
144 } 144 }
145 return false; 145 return false;
146 } 146 }
147 } 147 }
148 148
149 } // namespace android 149 } // namespace android
150 } // namespace base 150 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/strings/string_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698