Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef BASE_ANDROID_LIBRARY_LOADER_LIBRARY_PREFETCHER_H_ | |
| 6 #define BASE_ANDROID_LIBRARY_LOADER_LIBRARY_PREFETCHER_H_ | |
| 7 | |
| 8 #include <jni.h> | |
| 9 | |
| 10 #include <stdio.h> | |
|
pasko
2015/03/27 13:29:28
please don't include what you don't use
Benoit L
2015/03/27 15:44:52
Done.
| |
| 11 #include <sys/types.h> | |
| 12 #include <string> | |
| 13 | |
| 14 #include "base/files/file_util.h" | |
| 15 #include "base/macros.h" | |
| 16 #include "base/strings/string_split.h" | |
| 17 | |
| 18 namespace base { | |
| 19 namespace android { | |
| 20 | |
| 21 class NativeLibraryPrefetcher { | |
| 22 public: | |
| 23 // Finds the ranges matching the native library, forks a low priority | |
| 24 // process pre-fetching these ranges and wait()s for it. | |
| 25 // Returns false on error. | |
| 26 static bool ForkAndPrefetchNativeLibrary(); | |
| 27 | |
| 28 protected: // Protected and not private for testing. | |
|
pasko
2015/03/27 13:29:28
fyi: there is FRIEND_TEST_ALL_PREFIXES
Benoit L
2015/03/27 15:44:52
Thank you for educating me on the standard practic
| |
| 29 struct Mapping { | |
| 30 uint64_t start; | |
| 31 uint64_t end; | |
| 32 std::string flags; | |
| 33 uint64_t offset; | |
|
pasko
2015/03/27 13:29:28
please remove offset, device, inode.
They are eas
Benoit L
2015/03/27 15:44:52
Done.
| |
| 34 std::string device; | |
| 35 int64_t inode; | |
| 36 std::string filename; | |
| 37 }; | |
| 38 | |
| 39 // Returns true for success. | |
| 40 static bool ParseMapping(const std::string& line, Mapping* mapping); | |
| 41 // Returns true if we should keep the mapping. | |
|
pasko
2015/03/27 13:29:28
'we should keep' is hard to understand, how about
| |
| 42 static bool MappingMatches(const Mapping& mapping); | |
| 43 // Finds the ranges matching the native library in /proc/self/maps. | |
| 44 // Returns true for success. | |
| 45 static bool FindRanges(std::vector<std::pair<uint64_t, uint64_t>>* range); | |
| 46 }; | |
| 47 | |
| 48 } // namespace android | |
| 49 } // namespace base | |
| 50 | |
| 51 #endif // BASE_ANDROID_LIBRARY_LOADER_LIBRARY_PREFETCHER_H_ | |
| OLD | NEW |