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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 (function() {
6 var internal = mojo.internal;
7
8 function constructRunOrClosePipeMessage(runOrClosePipeInput) {
9 var runOrClosePipeMessageParams = new
10 mojo.pipeControl2.RunOrClosePipeMessageParams();
11 runOrClosePipeMessageParams.input = runOrClosePipeInput;
12
13 var messageName = mojo.pipeControl2.kRunOrClosePipeMessageId;
14 var payloadSize =
15 mojo.pipeControl2.RunOrClosePipeMessageParams.encodedSize;
16
17 var builder = new internal.MessageV0Builder(messageName, payloadSize);
18 builder.encodeStruct(mojo.pipeControl2.RunOrClosePipeMessageParams,
19 runOrClosePipeMessageParams);
20 var message = builder.finish();
21 message.setInterfaceId(internal.kInvalidInterfaceId);
22 return message;
23 }
24
25 function PipeControlMessageProxy(receiver) {
26 this.receiver_ = receiver;
27 }
28
29 PipeControlMessageProxy.prototype.notifyPeerEndpointClosed = function(
30 interfaceId, reason) {
31 var message = this.constructPeerEndpointClosedMessage(interfaceId, reason);
32 this.receiver_.accept(message);
33 };
34
35 PipeControlMessageProxy.prototype.constructPeerEndpointClosedMessage =
36 function(interfaceId, reason) {
37 var event = new mojo.pipeControl2.PeerAssociatedEndpointClosedEvent();
38 event.id = interfaceId;
39 if (reason) {
40 event.disconnectReason = new mojo.pipeControl2.DisconnectReason({
41 customReason: reason.customReason,
42 description: reason.description});
43 }
44 var runOrClosePipeInput = new mojo.pipeControl2.RunOrClosePipeInput();
45 runOrClosePipeInput.peerAssociatedEndpointClosedEvent = event;
46 return constructRunOrClosePipeMessage(runOrClosePipeInput);
47 };
48
49 internal.PipeControlMessageProxy = PipeControlMessageProxy;
50 })();
OLDNEW
« 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