Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / mojo / public / js / bindings / core.js
1 // Copyright 2014 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 // Module "mojo/public/js/bindings/core"
6 //
7 // Note: This file is for documentation purposes only. The code here is not
8 // actually executed. The real module is implemented natively in Mojo.
9 //
10 // This module provides the JavaScript bindings for mojo/public/c/system/core.h.
11 // Refer to that file for more detailed documentation for equivalent methods.
12
13 while (1);
14
15 /**
16  * MojoHandle: An opaque handles to a Mojo object (e.g. a message pipe).
17  */
18 var kInvalidHandle;
19
20 /**
21  * MojoResult {number}: Result codes for Mojo operations.
22  * See core.h for more information.
23  */
24 var RESULT_OK;
25 var RESULT_CANCELLED;
26 var RESULT_UNKNOWN;
27 var RESULT_INVALID_ARGUMENT;
28 var RESULT_DEADLINE_EXCEEDED;
29 var RESULT_NOT_FOUND;
30 var RESULT_ALREADY_EXISTS;
31 var RESULT_PERMISSION_DENIED;
32 var RESULT_RESOURCE_EXHAUSTED;
33 var RESULT_FAILED_PRECONDITION;
34 var RESULT_ABORTED;
35 var RESULT_OUT_OF_RANGE;
36 var RESULT_UNIMPLEMENTED;
37 var RESULT_INTERNAL;
38 var RESULT_UNAVAILABLE;
39 var RESULT_DATA_LOSS;
40 var RESULT_BUSY;
41 var RESULT_SHOULD_WAIT;
42
43 /**
44  * MojoDeadline {number}: Used to specify deadlines (timeouts), in microseconds.
45  * See core.h for more information.
46  */
47 var DEADLINE_INDEFINITE;
48
49 /**
50  * MojoWaitFlags: Used to specify the state of a handle to wait on (e.g., the
51  * ability to read or write to it).
52  * See core.h for more information.
53  */
54 var WAIT_FLAG_NONE;
55 var WAIT_FLAG_READABLE;
56 var WAIT_FLAG_WRITABLE;
57 var WAIT_FLAG_EVERYTHING;
58
59 /*
60  * MojoWriteMessageFlags: Used to specify different modes to |writeMessage()|.
61  * See core.h for more information.
62  */
63 var WRITE_MESSAGE_FLAG_NONE;
64
65 /**
66  * MojoReadMessageFlags: Used to specify different modes to |readMessage()|.
67  * See core.h for more information.
68  */
69 var READ_MESSAGE_FLAG_NONE;
70 var READ_MESSAGE_FLAG_MAY_DISCARD;
71
72 /**
73  * MojoCreateDataPipeOptions: Used to specify creation parameters for a data
74  * pipe to |createDataPipe()|.
75  * See core.h for more information.
76  */
77 dictionary MojoCreateDataPipeOptions {
78   MojoCreateDataPipeOptionsFlags flags;  // See below.
79   int32 elementNumBytes;  // The size of an element, in bytes.
80   int32 capacityNumBytes;  // The capacity of the data pipe, in bytes.
81 };
82
83 // MojoCreateDataPipeOptionsFlags
84 var CREATE_DATA_PIPE_OPTIONS_FLAG_NONE;
85 var CREATE_DATA_PIPE_OPTIONS_FLAG_MAY_DISCARD;
86
87 /*
88  * MojoWriteDataFlags: Used to specify different modes to |writeData()|.
89  * See core.h for more information.
90  */
91 var WRITE_DATA_FLAG_NONE;
92 var WRITE_DATA_FLAG_ALL_OR_NONE;
93
94 /**
95  * MojoReadDataFlags: Used to specify different modes to |readData()|.
96  * See core.h for more information.
97  */
98 var READ_DATA_FLAG_NONE;
99 var READ_DATA_FLAG_ALL_OR_NONE;
100 var READ_DATA_FLAG_DISCARD;
101 var READ_DATA_FLAG_QUERY;
102
103 /**
104  * Closes the given |handle|. See MojoClose for more info.
105  * @param {MojoHandle} Handle to close.
106  * @return {MojoResult} Result code.
107  */
108 function close(handle) { [native code] }
109
110 /**
111  * Waits on the given handle until the state indicated by |waitFlags| is
112  * satisfied or until |deadline| is passed. See MojoWait for more information.
113  *
114  * @param {MojoHandle} handle Handle to wait on.
115  * @param {MojoWaitFlags} waitFlags Specifies the condition to wait for.
116  * @param {MojoDeadline} deadline Stops waiting if this is reached.
117  * @return {MojoResult} Result code.
118  */
119 function wait(handle, waitFlags, deadline) { [native code] }
120
121 /**
122  * Waits on |handles[0]|, ..., |handles[handles.length-1]| for at least one of
123  * them to satisfy the state indicated by |flags[0]|, ...,
124  * |flags[handles.length-1]|, respectively, or until |deadline| has passed.
125  * See MojoWaitMany for more information.
126  *
127  * @param {Array.MojoHandle} handles Handles to wait on.
128  * @param {Array.MojoWaitFlags} waitFlags Specifies the condition to wait for,
129  *   for each corresponding handle. Must be the same length as |handles|.
130  * @param {MojoDeadline} deadline Stops waiting if this is reached.
131  * @return {MojoResult} Result code.
132  */
133 function waitMany(handles, waitFlags, deadline) { [native code] }
134
135 /**
136  * Creates a message pipe. This function always succeeds.
137  * See MojoCreateMessagePipe for more information on message pipes.
138  *
139  * @return {MessagePipe} An object of the form {
140  *     handle0,
141  *     handle1,
142  *   }
143  *   where |handle0| and |handle1| are MojoHandles to each end of the channel.
144  */
145 function createMessagePipe() { [native code] }
146
147 /**
148  * Writes a message to the message pipe endpoint given by |handle|. See
149  * MojoWriteMessage for more information, including return codes.
150  *
151  * @param {MojoHandle} handle The endpoint to write to.
152  * @param {ArrayBufferView} buffer The message data. May be empty.
153  * @param {Array.MojoHandle} handlesArray Any handles to attach. Handles are
154  *   transferred on success and will no longer be valid. May be empty.
155  * @param {MojoWriteMessageFlags} flags Flags.
156  * @return {MojoResult} Result code.
157  */
158 function writeMessage(handle, buffer, handlesArray, flags) { [native code] }
159
160 /**
161  * Reads a message from the message pipe endpoint given by |handle|. See
162  * MojoReadMessage for more information, including return codes.
163  *
164  * @param {MojoHandle} handle The endpoint to read from.
165  * @param {MojoReadMessageFlags} flags Flags.
166  * @return {object} An object of the form {
167  *     result,  // |RESULT_OK| on success, error code otherwise.
168  *     buffer,  // An ArrayBufferView of the message data (only on success).
169  *     handles  // An array of MojoHandles transferred, if any.
170  *   }
171  */
172 function readMessage(handle, flags) { [native code] }
173
174 /**
175  * Creates a data pipe, which is a unidirectional communication channel for
176  * unframed data, with the given options. See MojoCreateDataPipe for more
177  * more information, including return codes.
178  *
179  * @param {MojoCreateDataPipeOptions} optionsDict Options to control the data
180  *   pipe parameters. May be null.
181  * @return {object} An object of the form {
182  *     result,  // |RESULT_OK| on success, error code otherwise.
183  *     producerHandle,  // MojoHandle to use with writeData (only on success).
184  *     consumerHandle,  // MojoHandle to use with readData (only on success).
185  *   }
186  */
187 function createDataPipe(optionsDict) { [native code] }
188
189 /**
190  * Writes the given data to the data pipe producer given by |handle|. See
191  * MojoWriteData for more information, including return codes.
192  *
193  * @param {MojoHandle} handle A producerHandle returned by createDataPipe.
194  * @param {ArrayBufferView} buffer The data to write.
195  * @param {MojoWriteDataFlags} flags Flags.
196  * @return {object} An object of the form {
197  *     result,  // |RESULT_OK| on success, error code otherwise.
198  *     numBytes,  // The number of bytes written.
199  *   }
200  */
201 function writeData(handle, buffer, flags) { [native code] }
202
203 /**
204  * Reads data from the data pipe consumer given by |handle|. May also
205  * be used to discard data. See MojoReadData for more information, including
206  * return codes.
207  *
208  * @param {MojoHandle} handle A consumerHandle returned by createDataPipe.
209  * @param {MojoReadDataFlags} flags Flags.
210  * @return {object} An object of the form {
211  *     result,  // |RESULT_OK| on success, error code otherwise.
212  *     buffer,  // An ArrayBufferView of the data read (only on success).
213  *   }
214  */
215 function readData(handle, flags) { [native code] }