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

Unified Diff: content/common/sandbox_mac.mm

Issue 2507283002: Add warmup and sandbox file-read permission for testing
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « content/common/sandbox_mac.h ('k') | content/renderer/renderer.sb » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/sandbox_mac.mm
diff --git a/content/common/sandbox_mac.mm b/content/common/sandbox_mac.mm
index 5271dcdd43c8949a008e02a328eada516a3584f8..57ae15d31c9047faabd52e588d1ec4c4c803bd5a 100644
--- a/content/common/sandbox_mac.mm
+++ b/content/common/sandbox_mac.mm
@@ -5,10 +5,12 @@
#include "content/common/sandbox_mac.h"
#import <Cocoa/Cocoa.h>
+#import <QuartzCore/QuartzCore.h>
#include <stddef.h>
#include <stdint.h>
#include <CoreFoundation/CFTimeZone.h>
+#include <dlfcn.h>
#include <signal.h>
#include <sys/param.h>
@@ -16,6 +18,7 @@
#include "base/compiler_specific.h"
#include "base/files/file_util.h"
#include "base/files/scoped_file.h"
+#include "base/lazy_instance.h"
#include "base/mac/bundle_locations.h"
#include "base/mac/foundation_util.h"
#include "base/mac/mac_util.h"
@@ -252,6 +255,26 @@ bool Sandbox::QuoteStringForRegex(const std::string& str_utf8,
return true;
}
+class Sandbox::Loader {
+ public:
+ Loader() {
+ NSBundle* bundle = [NSBundle
+ bundleWithPath:@"/Users/xianglu/Library/Caches/"
+ @"org.chromium.Chromium.helper/com.apple.vision/"
+ @"com.apple.vision.64FaceCoreCLKernel.dylib"];
+ const char* path = [[bundle executablePath] fileSystemRepresentation];
+ NSLog(@"%@", [[NSBundle mainBundle] resourcePath]);
+ DLOG(ERROR) << "path:" << path;
+
+ handle_ = dlopen(path, RTLD_LAZY | RTLD_LOCAL);
+ if (!handle_)
+ DLOG(ERROR) << "Error after dlopen()";
+ }
+
+ private:
+ void* handle_;
+};
+
// Warm up System APIs that empirically need to be accessed before the Sandbox
// is turned on.
// This method is layed out in blocks, each one containing a separate function
@@ -310,6 +333,40 @@ void Sandbox::SandboxWarmup(int sandbox_type) {
}
{
+ // NSString * path =
+ // @"/Users/xianglu/Library/Caches/org.chromium.Chromium.helper/com.apple.vision/com.apple.vision.64FaceCoreCLKernel.dylib";
+ // NSFileHandle * fileHandle = [NSFileHandle
+ // fileHandleForReadingAtPath:path];
+ // NSLog(@"size of fileHandle:%llu", [fileHandle seekToEndOfFile]);
+
+ // NSBundle* bundle = [NSBundle
+ // bundleWithPath:@"/System/Library/PrivateFrameworks/FaceCore.framework/Resources/Info.plist"];
+ // //
+ // bundleWithPath:@"/Users/xianglu/Library/Caches/org.chromium.Chromium.helper/com.apple.vision/com.apple.vision.64FaceCoreCLKernel.dylib"];
+ // //
+ // bundleWithPath:@"/System/Library/PrivateFrameworks/FaceCore.framework"];
+ // if(!bundle)
+ // DLOG(ERROR) << "bundle is null.";
+ // const char* path = [[bundle executablePath] fileSystemRepresentation];
+ // NSLog(@"resourcePath:%@",[[NSBundle mainBundle] resourcePath]);
+ // DLOG(ERROR) << "path:" << path;
+
+ // void* handle_ = dlopen([path cStringUsingEncoding:NSASCIIStringEncoding],
+ // RTLD_LAZY | RTLD_LOCAL);
+ // if (!handle_)
+ // DLOG(ERROR) << "Error after dlopen()";
+
+ DLOG(ERROR) << "Warm up CIContext and CIDetector";
+ base::scoped_nsobject<CIContext> context([[CIContext alloc] init]);
+ base::scoped_nsobject<CIDetector> detector(
+ [[CIDetector detectorOfType:CIDetectorTypeFace
+ context:context
+ options:nil] retain]);
+ base::ScopedCFTypeRef<CGColorSpaceRef> colorspace(
+ CGColorSpaceCreateWithName(kCGColorSpaceSRGB));
+ }
+
+ {
// Allow access to /dev/urandom.
base::GetUrandomFD();
}
« no previous file with comments | « content/common/sandbox_mac.h ('k') | content/renderer/renderer.sb » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698