mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Some components in the Flutter engine were derived from the forked blink codebase. While the forked components have either been removed or rewritten, the use of the blink namespace has mostly (and inconsistently) remained. This renames the blink namesapce to flutter for consistency. There are no functional changes in this patch.
49 lines
1.4 KiB
C++
49 lines
1.4 KiB
C++
// Copyright 2013 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "flutter/lib/ui/isolate_name_server/isolate_name_server.h"
|
|
|
|
namespace flutter {
|
|
|
|
IsolateNameServer::IsolateNameServer() {}
|
|
|
|
IsolateNameServer::~IsolateNameServer() = default;
|
|
|
|
Dart_Port IsolateNameServer::LookupIsolatePortByName(const std::string& name) {
|
|
std::lock_guard<std::mutex> lock(mutex_);
|
|
return LookupIsolatePortByNameUnprotected(name);
|
|
}
|
|
|
|
Dart_Port IsolateNameServer::LookupIsolatePortByNameUnprotected(
|
|
const std::string& name) {
|
|
auto port_iterator = port_mapping_.find(name);
|
|
if (port_iterator != port_mapping_.end()) {
|
|
return port_iterator->second;
|
|
}
|
|
return ILLEGAL_PORT;
|
|
}
|
|
|
|
bool IsolateNameServer::RegisterIsolatePortWithName(Dart_Port port,
|
|
const std::string& name) {
|
|
std::lock_guard<std::mutex> lock(mutex_);
|
|
if (LookupIsolatePortByNameUnprotected(name) != ILLEGAL_PORT) {
|
|
// Name is already registered.
|
|
return false;
|
|
}
|
|
port_mapping_[name] = port;
|
|
return true;
|
|
}
|
|
|
|
bool IsolateNameServer::RemoveIsolateNameMapping(const std::string& name) {
|
|
std::lock_guard<std::mutex> lock(mutex_);
|
|
auto port_iterator = port_mapping_.find(name);
|
|
if (port_iterator == port_mapping_.end()) {
|
|
return false;
|
|
}
|
|
port_mapping_.erase(port_iterator);
|
|
return true;
|
|
}
|
|
|
|
} // namespace flutter
|