Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Migrated away from UnmodifiableUint8ListView #47276

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions lib/ui/fixtures/ui_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,16 @@ void platformMessagePortResponseTest() async {
@pragma('vm:entry-point')
void platformMessageResponseTest() {
_callPlatformMessageResponseDart((ByteData? result) {
if (result is UnmodifiableByteDataView &&
result.lengthInBytes == 100) {
_finishCallResponse(true);
if (result is ByteData && result.lengthInBytes == 100) {
int value = result.getInt8(0);
bool didThrowOnModify = false;
try {
result.setInt8(0, value);
} catch (e) {
didThrowOnModify = true;
}
// This should be a read only buffer.
_finishCallResponse(didThrowOnModify);
} else {
_finishCallResponse(false);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/platform_dispatcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const String _kFlutterKeyDataChannel = 'flutter/keydata';

@pragma('vm:entry-point')
ByteData? _wrapUnmodifiableByteData(ByteData? byteData) =>
byteData == null ? null : UnmodifiableByteDataView(byteData);
byteData?.asUnmodifiableView();

/// A token that represents a root isolate.
class RootIsolateToken {
Expand Down
4 changes: 2 additions & 2 deletions shell/platform/fuchsia/dart-pkg/zircon/test/zircon_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ void main() {
expect(fileResult.status, equals(ZX.OK));
MapResult mapResult = System.vmoMap(fileResult.handle);
expect(mapResult.status, equals(ZX.OK));
Uint8List fileData = UnmodifiableUint8ListView(mapResult.data);
Uint8List fileData = mapResult.data.asUnmodifiableView();
String fileString = utf8.decode(fileData.sublist(0, fileResult.numBytes));
expect(fileString, equals(fuchsia));
});
Expand All @@ -610,7 +610,7 @@ void main() {
// Read from the duplicate.
MapResult mapResult = System.vmoMap(duplicate);
expect(mapResult.status, equals(ZX.OK));
Uint8List vmoData = UnmodifiableUint8ListView(mapResult.data);
Uint8List vmoData = mapResult.data.asUnmodifiableView();
String vmoString = utf8.decode(vmoData.sublist(0, data.length));
expect(vmoString, equals(fuchsia));
});
Expand Down