mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
For consistency with the rest of dart:ui, check required parameters with assert(param != null) rather than throwing ArgumentError. ArgumentError is typically reserved for checking the validity of non-null args -- e.g. that a list has the required number of elements.
43 lines
1.5 KiB
Dart
43 lines
1.5 KiB
Dart
// Copyright 2018 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
part of dart.ui;
|
|
|
|
abstract class IsolateNameServer {
|
|
// Looks up the [SendPort] associated with a given name. Returns null
|
|
// if the name does not exist.
|
|
//
|
|
// `name` must not be null.
|
|
static SendPort lookupPortByName(String name) {
|
|
assert(name != null, "'name' cannot be null.");
|
|
return _lookupPortByName(name);
|
|
}
|
|
|
|
// Registers a SendPort with a given name. Returns true if registration is
|
|
// successful, false if the name entry already exists.
|
|
//
|
|
// `port` and `name` must not be null.
|
|
static bool registerPortWithName(SendPort port, String name) {
|
|
assert(port != null, "'port' cannot be null.");
|
|
assert(name != null, "'name' cannot be null.");
|
|
return _registerPortWithName(port, name);
|
|
}
|
|
|
|
// Removes a name to SendPort mapping given a name. Returns true if the
|
|
// mapping was successfully removed, false if the mapping does not exist.
|
|
//
|
|
// `name` must not be null.
|
|
static bool removePortNameMapping(String name) {
|
|
assert(name != null, "'name' cannot be null.");
|
|
return _removePortNameMapping(name);
|
|
}
|
|
|
|
static SendPort _lookupPortByName(String name)
|
|
native 'IsolateNameServerNatives_LookupPortByName';
|
|
static bool _registerPortWithName(SendPort port, String name)
|
|
native 'IsolateNameServerNatives_RegisterPortWithName';
|
|
static bool _removePortNameMapping(String name)
|
|
native 'IsolateNameServerNatives_RemovePortNameMapping';
|
|
}
|