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

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

Issue 1001343002: Prefetch the native library from native code by parsing /proc/pid/maps. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Re-use existing /proc/maps parsing code. Created 5 years, 8 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
OLDNEW
(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 <stdint.h>
11 #include <sys/types.h>
pasko 2015/04/02 15:50:36 unnecessary?
Benoit L 2015/04/02 16:43:48 Done.
12 #include <string>
13
14 #include "base/debug/proc_maps_linux.h"
15 #include "base/gtest_prod_util.h"
16
17 namespace base {
18 namespace android {
19
20 class NativeLibraryPrefetcher {
21 public:
22 // Finds the ranges matching the native library, forks a low priority
23 // process pre-fetching these ranges and wait()s for it.
24 // Returns false on error.
25 static bool ForkAndPrefetchNativeLibrary();
26
27 // Returns true if the region matches native code or data.
28 static bool IsGoodToPrefetch(const base::debug::MappedMemoryRegion& region);
pasko 2015/04/02 15:50:36 this and following methods should be private
Benoit L 2015/04/02 16:43:48 Done.
29 // Filters the regions to keep only libchrome ranges if possible.
30 static void TakeOnlyLibchromeRangesIfPossible(
31 const std::vector<base::debug::MappedMemoryRegion>& regions,
32 std::vector<std::pair<uintptr_t, uintptr_t>>* ranges);
33 // Finds the ranges matching the native library in /proc/self/maps.
34 // Returns true for success.
35 static bool FindRanges(std::vector<std::pair<uintptr_t, uintptr_t>>* ranges);
36
37 FRIEND_TEST_ALL_PREFIXES(NativeLibraryPrefetcherTest,
38 TestIsGoodToPrefetchNoRange);
39 FRIEND_TEST_ALL_PREFIXES(NativeLibraryPrefetcherTest,
40 TestIsGoodToPrefetchUnreadableRange);
41 FRIEND_TEST_ALL_PREFIXES(NativeLibraryPrefetcherTest,
42 TestIsGoodToPrefetchSkipSharedRange);
43 FRIEND_TEST_ALL_PREFIXES(NativeLibraryPrefetcherTest,
44 TestIsGoodToPrefetchLibchromeRange);
45 FRIEND_TEST_ALL_PREFIXES(NativeLibraryPrefetcherTest,
46 TestIsGoodToPrefetchBaseApkRange);
47 FRIEND_TEST_ALL_PREFIXES(NativeLibraryPrefetcherTest,
48 TestTakeOnlyLibchromeRangesIfPossibleNoLibchrome);
49 FRIEND_TEST_ALL_PREFIXES(NativeLibraryPrefetcherTest,
50 TestTakeOnlyLibchromeRangesIfPossibleHasLibchrome);
51 };
52
53 } // namespace android
54 } // namespace base
55
56 #endif // BASE_ANDROID_LIBRARY_LOADER_LIBRARY_PREFETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698