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

Unified Diff: third_party/android_crazy_linker/src/src/crazy_linker_api.cpp

Issue 643803003: Add UMA for testing whether device supports memory mapping APK files with executable permissions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: third_party/android_crazy_linker/src/src/crazy_linker_api.cpp
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_api.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_api.cpp
index 10a64bfa63ee9b6290ba88a64ec33340d48073e4..162f00cf220bcb420a18cd7fee036d6540d4905f 100644
--- a/third_party/android_crazy_linker/src/src/crazy_linker_api.cpp
+++ b/third_party/android_crazy_linker/src/src/crazy_linker_api.cpp
@@ -6,6 +6,7 @@
#include <crazy_linker.h>
+#include <limits.h>
#include <string.h>
#include "crazy_linker_error.h"
@@ -24,6 +25,7 @@ using crazy::Error;
using crazy::SearchPathList;
using crazy::ScopedGlobalLock;
using crazy::LibraryView;
+using crazy::FileDescriptor;
//
// crazy_context_t
@@ -387,4 +389,20 @@ void crazy_library_close_with_context(crazy_library_t* library,
}
}
+crazy_status_t crazy_linker_test_load_from_apk(const char* apkfile_name) {
+ FileDescriptor fd(apkfile_name);
+
+ LOG("%s: Memory mapping the first page of %s\n", __FUNCTION__, apkfile_name);
+ void* address = fd.Map(NULL, PAGE_SIZE, PROT_EXEC, MAP_PRIVATE, 0);
+
+ crazy_status_t status = CRAZY_STATUS_FAILURE;
+ if (address != MAP_FAILED) {
+ status = CRAZY_STATUS_SUCCESS;
+ munmap(address, PAGE_SIZE);
+ }
picksi1 2014/10/10 10:52:18 I think this would be clearer is we swapped the if
petrcermak 2014/10/10 14:20:14 Done.
+
+ LOG(" %s\n", status == CRAZY_STATUS_SUCCESS ? "supported" : "NOT supported");
+ return status;
+}
+
} // extern "C"

Powered by Google App Engine
This is Rietveld 408576698