OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/system/core.h" | 5 #include "mojo/edk/system/core.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 DCHECK(dispatcher); | 370 DCHECK(dispatcher); |
371 | 371 |
372 std::unique_ptr<AsyncWaiter> waiter = | 372 std::unique_ptr<AsyncWaiter> waiter = |
373 base::WrapUnique(new AsyncWaiter(callback)); | 373 base::WrapUnique(new AsyncWaiter(callback)); |
374 MojoResult rv = dispatcher->AddAwakable(waiter.get(), signals, 0, nullptr); | 374 MojoResult rv = dispatcher->AddAwakable(waiter.get(), signals, 0, nullptr); |
375 if (rv == MOJO_RESULT_OK) | 375 if (rv == MOJO_RESULT_OK) |
376 ignore_result(waiter.release()); | 376 ignore_result(waiter.release()); |
377 return rv; | 377 return rv; |
378 } | 378 } |
379 | 379 |
| 380 MojoResult Core::SetProperty(MojoPropertyType type, const void* value) { |
| 381 base::AutoLock locker(property_lock_); |
| 382 switch (type) { |
| 383 case MOJO_PROPERTY_TYPE_SYNC_CALL_ALLOWED: |
| 384 property_sync_call_allowed_ = *static_cast<const bool*>(value); |
| 385 return MOJO_RESULT_OK; |
| 386 default: |
| 387 return MOJO_RESULT_INVALID_ARGUMENT; |
| 388 } |
| 389 } |
| 390 |
380 MojoTimeTicks Core::GetTimeTicksNow() { | 391 MojoTimeTicks Core::GetTimeTicksNow() { |
381 return base::TimeTicks::Now().ToInternalValue(); | 392 return base::TimeTicks::Now().ToInternalValue(); |
382 } | 393 } |
383 | 394 |
384 MojoResult Core::Close(MojoHandle handle) { | 395 MojoResult Core::Close(MojoHandle handle) { |
385 RequestContext request_context; | 396 RequestContext request_context; |
386 scoped_refptr<Dispatcher> dispatcher; | 397 scoped_refptr<Dispatcher> dispatcher; |
387 { | 398 { |
388 base::AutoLock lock(handles_lock_); | 399 base::AutoLock lock(handles_lock_); |
389 MojoResult rv = handles_.GetAndRemoveDispatcher(handle, &dispatcher); | 400 MojoResult rv = handles_.GetAndRemoveDispatcher(handle, &dispatcher); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 | 530 |
520 MojoResult Core::GetMessageBuffer(MojoMessageHandle message, void** buffer) { | 531 MojoResult Core::GetMessageBuffer(MojoMessageHandle message, void** buffer) { |
521 if (!message) | 532 if (!message) |
522 return MOJO_RESULT_INVALID_ARGUMENT; | 533 return MOJO_RESULT_INVALID_ARGUMENT; |
523 | 534 |
524 *buffer = reinterpret_cast<MessageForTransit*>(message)->mutable_bytes(); | 535 *buffer = reinterpret_cast<MessageForTransit*>(message)->mutable_bytes(); |
525 | 536 |
526 return MOJO_RESULT_OK; | 537 return MOJO_RESULT_OK; |
527 } | 538 } |
528 | 539 |
| 540 MojoResult Core::GetProperty(MojoPropertyType type, void* value) { |
| 541 base::AutoLock locker(property_lock_); |
| 542 switch (type) { |
| 543 case MOJO_PROPERTY_TYPE_SYNC_CALL_ALLOWED: |
| 544 *static_cast<bool*>(value) = property_sync_call_allowed_; |
| 545 return MOJO_RESULT_OK; |
| 546 default: |
| 547 return MOJO_RESULT_INVALID_ARGUMENT; |
| 548 } |
| 549 } |
| 550 |
529 MojoResult Core::CreateWaitSet(MojoHandle* wait_set_handle) { | 551 MojoResult Core::CreateWaitSet(MojoHandle* wait_set_handle) { |
530 RequestContext request_context; | 552 RequestContext request_context; |
531 if (!wait_set_handle) | 553 if (!wait_set_handle) |
532 return MOJO_RESULT_INVALID_ARGUMENT; | 554 return MOJO_RESULT_INVALID_ARGUMENT; |
533 | 555 |
534 scoped_refptr<WaitSetDispatcher> dispatcher = new WaitSetDispatcher(); | 556 scoped_refptr<WaitSetDispatcher> dispatcher = new WaitSetDispatcher(); |
535 MojoHandle h = AddDispatcher(dispatcher); | 557 MojoHandle h = AddDispatcher(dispatcher); |
536 if (h == MOJO_HANDLE_INVALID) { | 558 if (h == MOJO_HANDLE_INVALID) { |
537 LOG(ERROR) << "Handle table full"; | 559 LOG(ERROR) << "Handle table full"; |
538 dispatcher->Close(); | 560 dispatcher->Close(); |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1165 std::unique_ptr<NodeController> node_controller) { | 1187 std::unique_ptr<NodeController> node_controller) { |
1166 // It's OK to leak this reference. At this point we know the IO loop is still | 1188 // It's OK to leak this reference. At this point we know the IO loop is still |
1167 // running, and we know the NodeController will observe its eventual | 1189 // running, and we know the NodeController will observe its eventual |
1168 // destruction. This tells the NodeController to delete itself when that | 1190 // destruction. This tells the NodeController to delete itself when that |
1169 // happens. | 1191 // happens. |
1170 node_controller.release()->DestroyOnIOThreadShutdown(); | 1192 node_controller.release()->DestroyOnIOThreadShutdown(); |
1171 } | 1193 } |
1172 | 1194 |
1173 } // namespace edk | 1195 } // namespace edk |
1174 } // namespace mojo | 1196 } // namespace mojo |
OLD | NEW |