Flutter iOS Embedder
FlutterCallbackCache.mm
Go to the documentation of this file.
1 // Copyright 2013 The Flutter 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 
6 
7 #include "flutter/fml/logging.h"
8 #include "flutter/lib/ui/plugins/callback_cache.h"
9 
11 
12 @implementation FlutterCallbackInformation
13 @end
14 
15 @implementation FlutterCallbackCache
16 
17 + (FlutterCallbackInformation*)lookupCallbackInformation:(int64_t)handle {
18  auto info = flutter::DartCallbackCache::GetCallbackInformation(handle);
19  if (info == nullptr) {
20  return nil;
21  }
22  FlutterCallbackInformation* new_info = [[FlutterCallbackInformation alloc] init];
23  new_info.callbackName = [NSString stringWithUTF8String:info->name.c_str()];
24  new_info.callbackClassName = [NSString stringWithUTF8String:info->class_name.c_str()];
25  new_info.callbackLibraryPath = [NSString stringWithUTF8String:info->library_path.c_str()];
26  return new_info;
27 }
28 
29 + (void)setCachePath:(NSString*)path {
30  FML_DCHECK(path != nil);
31  flutter::DartCallbackCache::SetCachePath([path UTF8String]);
32  NSString* cache_path =
33  [NSString stringWithUTF8String:flutter::DartCallbackCache::GetCachePath().c_str()];
34  // Set the "Do Not Backup" flag to ensure that the cache isn't moved off disk in
35  // low-memory situations.
36  if (![[NSFileManager defaultManager] fileExistsAtPath:cache_path]) {
37  [[NSFileManager defaultManager] createFileAtPath:cache_path contents:nil attributes:nil];
38  NSError* error = nil;
39  NSURL* URL = [NSURL fileURLWithPath:cache_path];
40  BOOL success = [URL setResourceValue:[NSNumber numberWithBool:YES]
41  forKey:NSURLIsExcludedFromBackupKey
42  error:&error];
43  if (!success) {
44  NSLog(@"Error excluding %@ from backup %@", [URL lastPathComponent], error);
45  }
46  }
47 }
48 
49 @end
FlutterCallbackInformation::callbackLibraryPath
NSString * callbackLibraryPath
Definition: FlutterCallbackCache.h:29
FlutterCallbackCache
Definition: FlutterCallbackCache.h:37
FlutterCallbackCache_Internal.h
FlutterCallbackInformation::callbackName
NSString * callbackName
Definition: FlutterCallbackCache.h:21
FLUTTER_ASSERT_ARC
Definition: FlutterChannelKeyResponder.mm:13
FlutterCallbackInformation::callbackClassName
NSString * callbackClassName
Definition: FlutterCallbackCache.h:25
FlutterCallbackInformation
Definition: FlutterCallbackCache.h:17