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

Unified Diff: third_party/mojo/src/mojo/public/dart/lib/src/control_message.dart

Issue 1142043005: Update mojo sdk to rev 1dc8a9a5db73d3718d99917fadf31f5fb2ebad4f (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix type conversion errors on win64 for some msvs Created 5 years, 7 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
Index: third_party/mojo/src/mojo/public/dart/lib/src/control_message.dart
diff --git a/third_party/mojo/src/mojo/public/dart/lib/src/control_message.dart b/third_party/mojo/src/mojo/public/dart/lib/src/control_message.dart
new file mode 100644
index 0000000000000000000000000000000000000000..de71a980423903c3b9205b585f4c6c9d03b91bd5
--- /dev/null
+++ b/third_party/mojo/src/mojo/public/dart/lib/src/control_message.dart
@@ -0,0 +1,61 @@
+// Copyright 2015 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;
+
+// Handles InterfaceControlMessages for a stub.
+class ControlMessageHandler {
+ static bool isControlMessage(ServiceMessage message) =>
+ _isRun(message) || _isRunOrClose(message);
+
+ static bool _isRun(ServiceMessage message) =>
+ (message.header.type == icm.kRunMessageId);
+
+ static bool _isRunOrClose(ServiceMessage message) =>
+ (message.header.type == icm.kRunOrClosePipeMessageId);
+
+ static Future<Message> handleMessage(Stub stub,
+ int interface_version,
+ ServiceMessage message) {
+ assert(isControlMessage(message));
+ if (_isRun(message)) {
+ return _handleRun(stub, interface_version, message);
+ } else {
+ assert(_isRunOrClose(message));
+ return _handleRunOrClose(stub, interface_version, message);
+ }
+ }
+
+ static Future<Message> _handleRun(Stub stub,
+ int interface_version,
+ ServiceMessage message) {
+ // Construct RunMessage response.
+ var response = new icm.RunResponseMessageParams();
+ response.reserved0 = 16;
+ response.reserved1 = 0;
+ response.queryVersionResult = new icm.QueryVersionResult();
+ response.queryVersionResult.version = interface_version;
+ // Return response.
+ return new Future.value(
+ stub.buildResponseWithId(response,
+ icm.kRunMessageId,
+ message.header.requestId,
+ MessageHeader.kMessageIsResponse));
+ }
+
+ static Future<Message> _handleRunOrClose(Stub stub,
+ int interface_version,
+ ServiceMessage message) {
+ // Deserialize message.
+ var params = icm.RunOrClosePipeMessageParams.deserialize(message.payload);
+ // Grab required version.
+ var requiredVersion = params.requireVersion.version;
+ if (interface_version >= requiredVersion) {
+ // Stub meets the requirements.
+ return;
+ }
+ // Stub does not implement required version. Close the pipe immediately.
+ stub.close(immediate: true);
+ }
+}
« no previous file with comments | « third_party/mojo/src/mojo/public/dart/lib/src/codec.dart ('k') | third_party/mojo/src/mojo/public/dart/lib/src/data_pipe.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698