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

Unified Diff: mojo/public/js/new_bindings/lib/pipe_control_message_proxy.js

Issue 2893493002: Mojo JS bindings: update the new bindings with the associated interface feature. (Closed)
Patch Set: . Created 3 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: mojo/public/js/new_bindings/lib/pipe_control_message_proxy.js
diff --git a/mojo/public/js/new_bindings/lib/pipe_control_message_proxy.js b/mojo/public/js/new_bindings/lib/pipe_control_message_proxy.js
new file mode 100644
index 0000000000000000000000000000000000000000..55cf151d0f0851502a924c71e01c9d661e314a88
--- /dev/null
+++ b/mojo/public/js/new_bindings/lib/pipe_control_message_proxy.js
@@ -0,0 +1,50 @@
+// Copyright 2017 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.
+
+(function() {
+ var internal = mojo.internal;
+
+ function constructRunOrClosePipeMessage(runOrClosePipeInput) {
+ var runOrClosePipeMessageParams = new
+ mojo.pipeControl2.RunOrClosePipeMessageParams();
+ runOrClosePipeMessageParams.input = runOrClosePipeInput;
+
+ var messageName = mojo.pipeControl2.kRunOrClosePipeMessageId;
+ var payloadSize =
+ mojo.pipeControl2.RunOrClosePipeMessageParams.encodedSize;
+
+ var builder = new internal.MessageV0Builder(messageName, payloadSize);
+ builder.encodeStruct(mojo.pipeControl2.RunOrClosePipeMessageParams,
+ runOrClosePipeMessageParams);
+ var message = builder.finish();
+ message.setInterfaceId(internal.kInvalidInterfaceId);
+ return message;
+ }
+
+ function PipeControlMessageProxy(receiver) {
+ this.receiver_ = receiver;
+ }
+
+ PipeControlMessageProxy.prototype.notifyPeerEndpointClosed = function(
+ interfaceId, reason) {
+ var message = this.constructPeerEndpointClosedMessage(interfaceId, reason);
+ this.receiver_.accept(message);
+ };
+
+ PipeControlMessageProxy.prototype.constructPeerEndpointClosedMessage =
+ function(interfaceId, reason) {
+ var event = new mojo.pipeControl2.PeerAssociatedEndpointClosedEvent();
+ event.id = interfaceId;
+ if (reason) {
+ event.disconnectReason = new mojo.pipeControl2.DisconnectReason({
+ customReason: reason.customReason,
+ description: reason.description});
+ }
+ var runOrClosePipeInput = new mojo.pipeControl2.RunOrClosePipeInput();
+ runOrClosePipeInput.peerAssociatedEndpointClosedEvent = event;
+ return constructRunOrClosePipeMessage(runOrClosePipeInput);
+ };
+
+ internal.PipeControlMessageProxy = PipeControlMessageProxy;
+})();
« no previous file with comments | « mojo/public/js/new_bindings/lib/pipe_control_message_handler.js ('k') | mojo/public/js/new_bindings/router.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698