Flutter Engine
flutter::testing::TestDartNativeResolver Class Reference

#include <test_dart_native_resolver.h>

Inheritance diagram for flutter::testing::TestDartNativeResolver:

Public Member Functions

 TestDartNativeResolver ()
 
 ~TestDartNativeResolver ()
 
void AddNativeCallback (std::string name, Dart_NativeFunction callback)
 
void SetNativeResolverForIsolate ()
 

Detailed Description

Definition at line 30 of file test_dart_native_resolver.h.

Constructor & Destructor Documentation

◆ TestDartNativeResolver()

flutter::testing::TestDartNativeResolver::TestDartNativeResolver ( )
default

◆ ~TestDartNativeResolver()

flutter::testing::TestDartNativeResolver::~TestDartNativeResolver ( )
default

Member Function Documentation

◆ AddNativeCallback()

void flutter::testing::TestDartNativeResolver::AddNativeCallback ( std::string  name,
Dart_NativeFunction  callback 
)

Definition at line 21 of file test_dart_native_resolver.cc.

References name.

22  {
23  native_callbacks_[name] = callback;
24 }
const char * name
Definition: fuchsia.cc:50

◆ SetNativeResolverForIsolate()

void flutter::testing::TestDartNativeResolver::SetNativeResolverForIsolate ( )

Definition at line 68 of file test_dart_native_resolver.cc.

References flutter::testing::DartNativeEntrySymbolCallback(), FML_CHECK, flutter::testing::gIsolateResolvers, and tonic::LogIfError().

68  {
69  FML_CHECK(!Dart_IsError(Dart_RootLibrary()));
70  auto result = Dart_SetNativeResolver(Dart_RootLibrary(),
71  DartNativeEntryResolverCallback,
74  << "Could not set native resolver in test.";
75 
76  std::scoped_lock lock(gIsolateResolversMutex);
77  gIsolateResolvers[Dart_CurrentIsolate()] = shared_from_this();
78 
79  std::vector<Dart_Isolate> isolates_with_dead_resolvers;
80  for (const auto& entry : gIsolateResolvers) {
81  if (!entry.second.lock()) {
82  isolates_with_dead_resolvers.push_back(entry.first);
83  }
84  }
85 
86  for (const auto& dead_isolate : isolates_with_dead_resolvers) {
87  gIsolateResolvers.erase(dead_isolate);
88  }
89 }
static const uint8_t * DartNativeEntrySymbolCallback(Dart_NativeFunction function)
static std::map< Dart_Isolate, std::weak_ptr< TestDartNativeResolver > > gIsolateResolvers
static std::mutex gIsolateResolversMutex
#define FML_CHECK(condition)
Definition: logging.h:68
bool LogIfError(Dart_Handle handle)
Definition: dart_error.cc:15

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