Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(459)

Unified Diff: mojo/public/dart/src/message.dart

Issue 814543006: Move //mojo/{public, edk} underneath //third_party (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/dart/src/interface.dart ('k') | mojo/public/dart/src/message_pipe.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/dart/src/message.dart
diff --git a/mojo/public/dart/src/message.dart b/mojo/public/dart/src/message.dart
deleted file mode 100644
index 2cdda8adb1f8ee29011baf173192d66bc309f593..0000000000000000000000000000000000000000
--- a/mojo/public/dart/src/message.dart
+++ /dev/null
@@ -1,97 +0,0 @@
-// Copyright 2014 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 bindings;
-
-class MessageHeader {
- static const int kSimpleMessageSize = 16;
- static const int kSimpleMessageNumFields = 2;
- static const int kMessageWithRequestIdSize = 24;
- static const int kMessageWithRequestIdNumFields = 3;
- static const int kMessageTypeOffset = DataHeader.kHeaderSize;
- static const int kMessageFlagsOffset = kMessageTypeOffset + 4;
- static const int kMessageRequestIdOffset = kMessageFlagsOffset + 4;
- static const int kMessageExpectsResponse = 1 << 0;
- static const int kMessageIsResponse = 1 << 1;
-
- DataHeader _header;
- int type;
- int flags;
- int requestId;
-
- static bool mustHaveRequestId(int flags) =>
- (flags & (kMessageExpectsResponse | kMessageIsResponse)) != 0;
-
- MessageHeader(this.type) :
- _header = new DataHeader(kSimpleMessageSize, kSimpleMessageNumFields),
- flags = 0,
- requestId = 0;
-
- MessageHeader.withRequestId(this.type, this.flags, this.requestId) :
- _header = new DataHeader(
- kMessageWithRequestIdSize, kMessageWithRequestIdNumFields);
-
- MessageHeader.fromMessage(Message message) {
- var decoder = new Decoder(message);
- _header = decoder.decodeDataHeader();
- type = decoder.decodeUint32(kMessageTypeOffset);
- flags = decoder.decodeUint32(kMessageFlagsOffset);
- if (mustHaveRequestId(flags)) {
- if (_header.size < kMessageWithRequestIdSize) {
- throw 'Incorrect message size. Got: ${_header.size} ' +
- 'wanted $kMessageWithRequestIdSize';
- }
- requestId = decoder.decodeUint64(kMessageRequestIdOffset);
- } else {
- requestId = 0;
- }
- }
-
- int get size => _header.size;
- bool get hasRequestId => mustHaveRequestId(flags);
-
- void encode(Encoder encoder) {
- encoder.encodeDataHeader(_header);
- encoder.encodeUint32(type, kMessageTypeOffset);
- encoder.encodeUint32(flags, kMessageFlagsOffset);
- if (hasRequestId) {
- encoder.encodeUint64(requestId, kMessageRequestIdOffset);
- }
- }
-
- ServiceMessage get serviceMessage => new ServiceMessage(this);
-
- String toString() => "MessageHeader($_header, $type, $flags, $requestId)";
-}
-
-
-class Message {
- final ByteData buffer;
- final List<core.MojoHandle> handles;
- Message(this.buffer, this.handles);
- String toString() =>
- "Message(numBytes=${buffer.lengthInBytes}, numHandles=${handles.length})";
-}
-
-
-class ServiceMessage extends Message {
- final MessageHeader header;
- Message _payload;
-
- ServiceMessage(Message message, this.header)
- : super(message.buffer, message.handles);
-
- ServiceMessage.fromMessage(Message message)
- : this(message, new MessageHeader.fromMessage(message));
-
- Message get payload {
- if (_payload == null) {
- var truncatedBuffer = new ByteData.view(buffer.buffer, header.size);
- _payload = new Message(truncatedBuffer, handles);
- }
- return _payload;
- }
-
- String toString() => "ServiceMessage($header, $_payload)";
-}
« no previous file with comments | « mojo/public/dart/src/interface.dart ('k') | mojo/public/dart/src/message_pipe.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698