Flutter Engine
The Flutter Engine
dart_class_library.cc
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
9
10namespace tonic {
11
13
15 // Note that we don't need to delete these persistent handles because this
16 // object lives as long as the isolate. The handles will get deleted when the
17 // isolate dies.
18}
19
21 const auto& result = info_cache_.insert(std::make_pair(&info, nullptr));
22 if (!result.second) {
23 // Already present, return value.
24 return result.first->second;
25 }
26 return GetAndCacheClass(info.library_name, info.interface_name,
27 &result.first->second);
28}
29
31 const std::string& library_name,
32 const std::string& interface_name) {
33 auto key = std::make_pair(library_name, interface_name);
34 const auto& result = name_cache_.insert(std::make_pair(key, nullptr));
35 if (!result.second) {
36 // Already present, return value.
37 return result.first->second;
38 }
39 return GetAndCacheClass(library_name.c_str(), interface_name.c_str(),
40 &result.first->second);
41}
42
43Dart_PersistentHandle DartClassLibrary::GetAndCacheClass(
44 const char* library_name,
45 const char* interface_name,
46 Dart_PersistentHandle* cache_slot) {
47 auto it = providers_.find(library_name);
48 TONIC_DCHECK(it != providers_.end());
49
50 Dart_Handle class_handle = it->second->GetClassByName(interface_name);
51 *cache_slot = Dart_NewPersistentHandle(class_handle);
52 return *cache_slot;
53}
54
55} // namespace tonic
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
Dart_PersistentHandle GetClass(const DartWrapperInfo &info)
struct _Dart_Handle * Dart_Handle
Definition: dart_api.h:258
DART_EXPORT Dart_PersistentHandle Dart_NewPersistentHandle(Dart_Handle object)
Dart_Handle Dart_PersistentHandle
Definition: dart_api.h:259
GAsyncResult * result
#define TONIC_DCHECK
Definition: macros.h:32