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

Side by Side Diff: mojo/edk/js/core.cc

Issue 2741033003: Mojo EDK: Introduce MojoQueryHandleSignalsState API (Closed)
Patch Set: fix stupid bad DCHECK Created 3 years, 9 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
« no previous file with comments | « mojo/edk/embedder/entrypoints.cc ('k') | mojo/edk/system/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 17 matching lines...) Expand all
28 28
29 namespace { 29 namespace {
30 30
31 MojoResult CloseHandle(gin::Handle<HandleWrapper> handle) { 31 MojoResult CloseHandle(gin::Handle<HandleWrapper> handle) {
32 if (!handle->get().is_valid()) 32 if (!handle->get().is_valid())
33 return MOJO_RESULT_INVALID_ARGUMENT; 33 return MOJO_RESULT_INVALID_ARGUMENT;
34 handle->Close(); 34 handle->Close();
35 return MOJO_RESULT_OK; 35 return MOJO_RESULT_OK;
36 } 36 }
37 37
38 gin::Dictionary QueryHandleSignalsState(const gin::Arguments& args,
39 mojo::Handle handle) {
40 gin::Dictionary dictionary = gin::Dictionary::CreateEmpty(args.isolate());
41 if (!handle.is_valid()) {
42 dictionary.Set("result", MOJO_RESULT_INVALID_ARGUMENT);
43 } else {
44 HandleSignalsState state = handle.QuerySignalsState();
45 dictionary.Set("result", MOJO_RESULT_OK);
46 dictionary.Set("satisfiedSignals", state.satisfied_signals);
47 dictionary.Set("satisfiableSignals", state.satisfiable_signals);
48 }
49 return dictionary;
50 }
51
38 gin::Dictionary WaitHandle(const gin::Arguments& args, 52 gin::Dictionary WaitHandle(const gin::Arguments& args,
39 mojo::Handle handle, 53 mojo::Handle handle,
40 MojoHandleSignals signals, 54 MojoHandleSignals signals,
41 MojoDeadline deadline) { 55 MojoDeadline deadline) {
42 v8::Isolate* isolate = args.isolate(); 56 v8::Isolate* isolate = args.isolate();
43 gin::Dictionary dictionary = gin::Dictionary::CreateEmpty(isolate); 57 gin::Dictionary dictionary = gin::Dictionary::CreateEmpty(isolate);
44 58
45 MojoHandleSignalsState signals_state; 59 MojoHandleSignalsState signals_state;
46 MojoResult result = mojo::Wait(handle, signals, deadline, &signals_state); 60 MojoResult result = mojo::Wait(handle, signals, deadline, &signals_state);
47 dictionary.Set("result", result); 61 dictionary.Set("result", result);
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 gin::PerIsolateData* data = gin::PerIsolateData::From(isolate); 395 gin::PerIsolateData* data = gin::PerIsolateData::From(isolate);
382 v8::Local<v8::ObjectTemplate> templ = data->GetObjectTemplate( 396 v8::Local<v8::ObjectTemplate> templ = data->GetObjectTemplate(
383 &g_wrapper_info); 397 &g_wrapper_info);
384 398
385 if (templ.IsEmpty()) { 399 if (templ.IsEmpty()) {
386 templ = 400 templ =
387 gin::ObjectTemplateBuilder(isolate) 401 gin::ObjectTemplateBuilder(isolate)
388 // TODO(mpcomplete): Should these just be methods on the JS Handle 402 // TODO(mpcomplete): Should these just be methods on the JS Handle
389 // object? 403 // object?
390 .SetMethod("close", CloseHandle) 404 .SetMethod("close", CloseHandle)
405 .SetMethod("queryHandleSignalsState", QueryHandleSignalsState)
391 .SetMethod("wait", WaitHandle) 406 .SetMethod("wait", WaitHandle)
392 .SetMethod("waitMany", WaitMany) 407 .SetMethod("waitMany", WaitMany)
393 .SetMethod("createMessagePipe", CreateMessagePipe) 408 .SetMethod("createMessagePipe", CreateMessagePipe)
394 .SetMethod("writeMessage", WriteMessage) 409 .SetMethod("writeMessage", WriteMessage)
395 .SetMethod("readMessage", ReadMessage) 410 .SetMethod("readMessage", ReadMessage)
396 .SetMethod("createDataPipe", CreateDataPipe) 411 .SetMethod("createDataPipe", CreateDataPipe)
397 .SetMethod("writeData", WriteData) 412 .SetMethod("writeData", WriteData)
398 .SetMethod("readData", ReadData) 413 .SetMethod("readData", ReadData)
399 .SetMethod("drainData", DoDrainData) 414 .SetMethod("drainData", DoDrainData)
400 .SetMethod("isHandle", IsHandle) 415 .SetMethod("isHandle", IsHandle)
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 483
469 data->SetObjectTemplate(&g_wrapper_info, templ); 484 data->SetObjectTemplate(&g_wrapper_info, templ);
470 } 485 }
471 486
472 return templ->NewInstance(); 487 return templ->NewInstance();
473 } 488 }
474 489
475 } // namespace js 490 } // namespace js
476 } // namespace edk 491 } // namespace edk
477 } // namespace mojo 492 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/embedder/entrypoints.cc ('k') | mojo/edk/system/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698