Index: base/android/library_loader/library_prefetcher.h |
diff --git a/base/android/library_loader/library_prefetcher.h b/base/android/library_loader/library_prefetcher.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3100742fbf3e21f87b4223eb4e33b702e030c6ce |
--- /dev/null |
+++ b/base/android/library_loader/library_prefetcher.h |
@@ -0,0 +1,51 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef BASE_ANDROID_LIBRARY_LOADER_LIBRARY_PREFETCHER_H_ |
+#define BASE_ANDROID_LIBRARY_LOADER_LIBRARY_PREFETCHER_H_ |
+ |
+#include <jni.h> |
+ |
+#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.
|
+#include <sys/types.h> |
+#include <string> |
+ |
+#include "base/files/file_util.h" |
+#include "base/macros.h" |
+#include "base/strings/string_split.h" |
+ |
+namespace base { |
+namespace android { |
+ |
+class NativeLibraryPrefetcher { |
+ public: |
+ // Finds the ranges matching the native library, forks a low priority |
+ // process pre-fetching these ranges and wait()s for it. |
+ // Returns false on error. |
+ static bool ForkAndPrefetchNativeLibrary(); |
+ |
+ 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
|
+ struct Mapping { |
+ uint64_t start; |
+ uint64_t end; |
+ std::string flags; |
+ 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.
|
+ std::string device; |
+ int64_t inode; |
+ std::string filename; |
+ }; |
+ |
+ // Returns true for success. |
+ static bool ParseMapping(const std::string& line, Mapping* mapping); |
+ // Returns true if we should keep the mapping. |
pasko
2015/03/27 13:29:28
'we should keep' is hard to understand, how about
|
+ static bool MappingMatches(const Mapping& mapping); |
+ // Finds the ranges matching the native library in /proc/self/maps. |
+ // Returns true for success. |
+ static bool FindRanges(std::vector<std::pair<uint64_t, uint64_t>>* range); |
+}; |
+ |
+} // namespace android |
+} // namespace base |
+ |
+#endif // BASE_ANDROID_LIBRARY_LOADER_LIBRARY_PREFETCHER_H_ |