Flutter Engine
tonic::DartClassLibrary Class Reference

#include <dart_class_library.h>

Public Member Functions

 DartClassLibrary ()
 
 ~DartClassLibrary ()
 
void add_provider (const std::string &library_name, std::unique_ptr< DartClassProvider > provider)
 
Dart_PersistentHandle GetClass (const DartWrapperInfo &info)
 
Dart_PersistentHandle GetClass (const std::string &library_name, const std::string &interface_name)
 

Detailed Description

Definition at line 18 of file dart_class_library.h.

Constructor & Destructor Documentation

◆ DartClassLibrary()

tonic::DartClassLibrary::DartClassLibrary ( )
explicit

Definition at line 12 of file dart_class_library.cc.

12 {}

◆ ~DartClassLibrary()

tonic::DartClassLibrary::~DartClassLibrary ( )

Definition at line 14 of file dart_class_library.cc.

14  {
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 }

Member Function Documentation

◆ add_provider()

void tonic::DartClassLibrary::add_provider ( const std::string &  library_name,
std::unique_ptr< DartClassProvider provider 
)
inline

Definition at line 23 of file dart_class_library.h.

References GetClass(), and TONIC_DISALLOW_COPY_AND_ASSIGN.

Referenced by flutter::DartIsolate::GetMessageHandlingTaskRunner().

24  {
25  providers_.insert(std::make_pair(library_name, std::move(provider)));
26  }

◆ GetClass() [1/2]

Dart_PersistentHandle tonic::DartClassLibrary::GetClass ( const DartWrapperInfo info)

Definition at line 20 of file dart_class_library.cc.

References tonic::DartWrapperInfo::interface_name, and tonic::DartWrapperInfo::library_name.

Referenced by add_provider(), tonic::DartWrappable::CreateDartWrapper(), and tonic::DartWrappable::GetTypeForWrapper().

20  {
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 }

◆ GetClass() [2/2]

Dart_PersistentHandle tonic::DartClassLibrary::GetClass ( const std::string &  library_name,
const std::string &  interface_name 
)

Definition at line 30 of file dart_class_library.cc.

References TONIC_DCHECK.

32  {
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 }

The documentation for this class was generated from the following files: