Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
callback_cache.h
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
5#ifndef FLUTTER_LIB_UI_PLUGINS_CALLBACK_CACHE_H_
6#define FLUTTER_LIB_UI_PLUGINS_CALLBACK_CACHE_H_
7
8#include <map>
9#include <memory>
10#include <mutex>
11#include <string>
12
13#include "flutter/fml/macros.h"
14#include "third_party/dart/runtime/include/dart_api.h"
15
16namespace flutter {
17
19 std::string name;
20 std::string class_name;
21 std::string library_path;
22};
23
25 public:
26 static void SetCachePath(const std::string& path);
27 static std::string GetCachePath() { return cache_path_; }
28
29 static int64_t GetCallbackHandle(const std::string& name,
30 const std::string& class_name,
31 const std::string& library_path);
32
33 static Dart_Handle GetCallback(int64_t handle);
34
35 static std::unique_ptr<DartCallbackRepresentation> GetCallbackInformation(
36 int64_t handle);
37
38 static void LoadCacheFromDisk();
39
40 private:
41 static Dart_Handle LookupDartClosure(const std::string& name,
42 const std::string& class_name,
43 const std::string& library_path);
44
45 static void SaveCacheToDisk();
46
47 static std::mutex mutex_;
48 static std::string cache_path_;
49
50 static std::map<int64_t, DartCallbackRepresentation> cache_;
51
53};
54
55} // namespace flutter
56
57#endif // FLUTTER_LIB_UI_PLUGINS_CALLBACK_CACHE_H_
static std::unique_ptr< DartCallbackRepresentation > GetCallbackInformation(int64_t handle)
static int64_t GetCallbackHandle(const std::string &name, const std::string &class_name, const std::string &library_path)
static Dart_Handle GetCallback(int64_t handle)
static void SetCachePath(const std::string &path)
static std::string GetCachePath()
struct _Dart_Handle * Dart_Handle
Definition dart_api.h:258
#define FML_DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName)
Definition macros.h:37
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition switches.h:57
DEF_SWITCHES_START aot vmservice shared library name
Definition switches.h:32