OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "mojo/edk/js/core.h" | 5 #include "mojo/edk/js/core.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "gin/arguments.h" | 9 #include "gin/arguments.h" |
10 #include "gin/array_buffer.h" | 10 #include "gin/array_buffer.h" |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 } // namespace | 240 } // namespace |
241 | 241 |
242 const char Core::kModuleName[] = "mojo/public/js/core"; | 242 const char Core::kModuleName[] = "mojo/public/js/core"; |
243 | 243 |
244 v8::Local<v8::Value> Core::GetModule(v8::Isolate* isolate) { | 244 v8::Local<v8::Value> Core::GetModule(v8::Isolate* isolate) { |
245 gin::PerIsolateData* data = gin::PerIsolateData::From(isolate); | 245 gin::PerIsolateData* data = gin::PerIsolateData::From(isolate); |
246 v8::Local<v8::ObjectTemplate> templ = data->GetObjectTemplate( | 246 v8::Local<v8::ObjectTemplate> templ = data->GetObjectTemplate( |
247 &g_wrapper_info); | 247 &g_wrapper_info); |
248 | 248 |
249 if (templ.IsEmpty()) { | 249 if (templ.IsEmpty()) { |
250 templ = gin::ObjectTemplateBuilder(isolate) | 250 templ = |
251 // TODO(mpcomplete): Should these just be methods on the JS Handle | 251 gin::ObjectTemplateBuilder(isolate) |
252 // object? | 252 // TODO(mpcomplete): Should these just be methods on the JS Handle |
253 .SetMethod("close", CloseHandle) | 253 // object? |
254 .SetMethod("wait", WaitHandle) | 254 .SetMethod("close", CloseHandle) |
255 .SetMethod("waitMany", WaitMany) | 255 .SetMethod("wait", WaitHandle) |
256 .SetMethod("createMessagePipe", CreateMessagePipe) | 256 .SetMethod("waitMany", WaitMany) |
257 .SetMethod("writeMessage", WriteMessage) | 257 .SetMethod("createMessagePipe", CreateMessagePipe) |
258 .SetMethod("readMessage", ReadMessage) | 258 .SetMethod("writeMessage", WriteMessage) |
259 .SetMethod("createDataPipe", CreateDataPipe) | 259 .SetMethod("readMessage", ReadMessage) |
260 .SetMethod("writeData", WriteData) | 260 .SetMethod("createDataPipe", CreateDataPipe) |
261 .SetMethod("readData", ReadData) | 261 .SetMethod("writeData", WriteData) |
262 .SetMethod("drainData", DoDrainData) | 262 .SetMethod("readData", ReadData) |
| 263 .SetMethod("drainData", DoDrainData) |
263 | 264 |
264 .SetValue("RESULT_OK", MOJO_RESULT_OK) | 265 .SetValue("RESULT_OK", MOJO_RESULT_OK) |
265 .SetValue("RESULT_CANCELLED", MOJO_RESULT_CANCELLED) | 266 .SetValue("RESULT_CANCELLED", MOJO_RESULT_CANCELLED) |
266 .SetValue("RESULT_UNKNOWN", MOJO_RESULT_UNKNOWN) | 267 .SetValue("RESULT_UNKNOWN", MOJO_RESULT_UNKNOWN) |
267 .SetValue("RESULT_INVALID_ARGUMENT", MOJO_RESULT_INVALID_ARGUMENT) | 268 .SetValue("RESULT_INVALID_ARGUMENT", MOJO_RESULT_INVALID_ARGUMENT) |
268 .SetValue("RESULT_DEADLINE_EXCEEDED", MOJO_RESULT_DEADLINE_EXCEEDED) | 269 .SetValue("RESULT_DEADLINE_EXCEEDED", MOJO_RESULT_DEADLINE_EXCEEDED) |
269 .SetValue("RESULT_NOT_FOUND", MOJO_RESULT_NOT_FOUND) | 270 .SetValue("RESULT_NOT_FOUND", MOJO_RESULT_NOT_FOUND) |
270 .SetValue("RESULT_ALREADY_EXISTS", MOJO_RESULT_ALREADY_EXISTS) | 271 .SetValue("RESULT_ALREADY_EXISTS", MOJO_RESULT_ALREADY_EXISTS) |
271 .SetValue("RESULT_PERMISSION_DENIED", MOJO_RESULT_PERMISSION_DENIED) | 272 .SetValue("RESULT_PERMISSION_DENIED", MOJO_RESULT_PERMISSION_DENIED) |
272 .SetValue("RESULT_RESOURCE_EXHAUSTED", MOJO_RESULT_RESOURCE_EXHAUSTED) | 273 .SetValue("RESULT_RESOURCE_EXHAUSTED", |
273 .SetValue("RESULT_FAILED_PRECONDITION", MOJO_RESULT_FAILED_PRECONDITION) | 274 MOJO_RESULT_RESOURCE_EXHAUSTED) |
274 .SetValue("RESULT_ABORTED", MOJO_RESULT_ABORTED) | 275 .SetValue("RESULT_FAILED_PRECONDITION", |
275 .SetValue("RESULT_OUT_OF_RANGE", MOJO_RESULT_OUT_OF_RANGE) | 276 MOJO_RESULT_FAILED_PRECONDITION) |
276 .SetValue("RESULT_UNIMPLEMENTED", MOJO_RESULT_UNIMPLEMENTED) | 277 .SetValue("RESULT_ABORTED", MOJO_RESULT_ABORTED) |
277 .SetValue("RESULT_INTERNAL", MOJO_RESULT_INTERNAL) | 278 .SetValue("RESULT_OUT_OF_RANGE", MOJO_RESULT_OUT_OF_RANGE) |
278 .SetValue("RESULT_UNAVAILABLE", MOJO_RESULT_UNAVAILABLE) | 279 .SetValue("RESULT_UNIMPLEMENTED", MOJO_RESULT_UNIMPLEMENTED) |
279 .SetValue("RESULT_DATA_LOSS", MOJO_RESULT_DATA_LOSS) | 280 .SetValue("RESULT_INTERNAL", MOJO_RESULT_INTERNAL) |
280 .SetValue("RESULT_BUSY", MOJO_RESULT_BUSY) | 281 .SetValue("RESULT_UNAVAILABLE", MOJO_RESULT_UNAVAILABLE) |
281 .SetValue("RESULT_SHOULD_WAIT", MOJO_RESULT_SHOULD_WAIT) | 282 .SetValue("RESULT_DATA_LOSS", MOJO_RESULT_DATA_LOSS) |
| 283 .SetValue("RESULT_BUSY", MOJO_RESULT_BUSY) |
| 284 .SetValue("RESULT_SHOULD_WAIT", MOJO_RESULT_SHOULD_WAIT) |
282 | 285 |
283 .SetValue("DEADLINE_INDEFINITE", MOJO_DEADLINE_INDEFINITE) | 286 .SetValue("DEADLINE_INDEFINITE", MOJO_DEADLINE_INDEFINITE) |
284 | 287 |
285 .SetValue("HANDLE_SIGNAL_NONE", MOJO_HANDLE_SIGNAL_NONE) | 288 .SetValue("HANDLE_SIGNAL_NONE", MOJO_HANDLE_SIGNAL_NONE) |
286 .SetValue("HANDLE_SIGNAL_READABLE", MOJO_HANDLE_SIGNAL_READABLE) | 289 .SetValue("HANDLE_SIGNAL_READABLE", MOJO_HANDLE_SIGNAL_READABLE) |
287 .SetValue("HANDLE_SIGNAL_WRITABLE", MOJO_HANDLE_SIGNAL_WRITABLE) | 290 .SetValue("HANDLE_SIGNAL_WRITABLE", MOJO_HANDLE_SIGNAL_WRITABLE) |
288 | 291 |
289 .SetValue("CREATE_MESSAGE_PIPE_OPTIONS_FLAG_NONE", | 292 .SetValue("CREATE_MESSAGE_PIPE_OPTIONS_FLAG_NONE", |
290 MOJO_CREATE_MESSAGE_PIPE_OPTIONS_FLAG_NONE) | 293 MOJO_CREATE_MESSAGE_PIPE_OPTIONS_FLAG_NONE) |
291 | 294 |
292 .SetValue("WRITE_MESSAGE_FLAG_NONE", MOJO_WRITE_MESSAGE_FLAG_NONE) | 295 .SetValue("WRITE_MESSAGE_FLAG_NONE", MOJO_WRITE_MESSAGE_FLAG_NONE) |
293 | 296 |
294 .SetValue("READ_MESSAGE_FLAG_NONE", MOJO_READ_MESSAGE_FLAG_NONE) | 297 .SetValue("READ_MESSAGE_FLAG_NONE", MOJO_READ_MESSAGE_FLAG_NONE) |
295 .SetValue("READ_MESSAGE_FLAG_MAY_DISCARD", | 298 .SetValue("READ_MESSAGE_FLAG_MAY_DISCARD", |
296 MOJO_READ_MESSAGE_FLAG_MAY_DISCARD) | 299 MOJO_READ_MESSAGE_FLAG_MAY_DISCARD) |
297 | 300 |
298 .SetValue("CREATE_DATA_PIPE_OPTIONS_FLAG_NONE", | 301 .SetValue("CREATE_DATA_PIPE_OPTIONS_FLAG_NONE", |
299 MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE) | 302 MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE) |
300 .SetValue("CREATE_DATA_PIPE_OPTIONS_FLAG_MAY_DISCARD", | 303 .SetValue("CREATE_DATA_PIPE_OPTIONS_FLAG_MAY_DISCARD", |
301 MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_MAY_DISCARD) | 304 MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_MAY_DISCARD) |
302 | 305 |
303 .SetValue("WRITE_DATA_FLAG_NONE", MOJO_WRITE_DATA_FLAG_NONE) | 306 .SetValue("WRITE_DATA_FLAG_NONE", MOJO_WRITE_DATA_FLAG_NONE) |
304 .SetValue("WRITE_DATA_FLAG_ALL_OR_NONE", | 307 .SetValue("WRITE_DATA_FLAG_ALL_OR_NONE", |
305 MOJO_WRITE_DATA_FLAG_ALL_OR_NONE) | 308 MOJO_WRITE_DATA_FLAG_ALL_OR_NONE) |
306 | 309 |
307 .SetValue("READ_DATA_FLAG_NONE", MOJO_READ_DATA_FLAG_NONE) | 310 .SetValue("READ_DATA_FLAG_NONE", MOJO_READ_DATA_FLAG_NONE) |
308 .SetValue("READ_DATA_FLAG_ALL_OR_NONE", | 311 .SetValue("READ_DATA_FLAG_ALL_OR_NONE", |
309 MOJO_READ_DATA_FLAG_ALL_OR_NONE) | 312 MOJO_READ_DATA_FLAG_ALL_OR_NONE) |
310 .SetValue("READ_DATA_FLAG_DISCARD", MOJO_READ_DATA_FLAG_DISCARD) | 313 .SetValue("READ_DATA_FLAG_DISCARD", MOJO_READ_DATA_FLAG_DISCARD) |
311 .SetValue("READ_DATA_FLAG_QUERY", MOJO_READ_DATA_FLAG_QUERY) | 314 .SetValue("READ_DATA_FLAG_QUERY", MOJO_READ_DATA_FLAG_QUERY) |
312 .Build(); | 315 .SetValue("READ_DATA_FLAG_PEEK", MOJO_READ_DATA_FLAG_PEEK) |
| 316 .Build(); |
313 | 317 |
314 data->SetObjectTemplate(&g_wrapper_info, templ); | 318 data->SetObjectTemplate(&g_wrapper_info, templ); |
315 } | 319 } |
316 | 320 |
317 return templ->NewInstance(); | 321 return templ->NewInstance(); |
318 } | 322 } |
319 | 323 |
320 } // namespace js | 324 } // namespace js |
321 } // namespace mojo | 325 } // namespace mojo |
OLD | NEW |