| 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 <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 | 631 |
| 632 new_buffer_handle.Put(new_handle); | 632 new_buffer_handle.Put(new_handle); |
| 633 return MOJO_RESULT_OK; | 633 return MOJO_RESULT_OK; |
| 634 } | 634 } |
| 635 | 635 |
| 636 MojoResult Core::GetBufferInformation(MojoHandle buffer_handle, | 636 MojoResult Core::GetBufferInformation(MojoHandle buffer_handle, |
| 637 UserPointer<MojoBufferInformation> info, | 637 UserPointer<MojoBufferInformation> info, |
| 638 uint32_t info_num_bytes) { | 638 uint32_t info_num_bytes) { |
| 639 RefPtr<Dispatcher> dispatcher; | 639 RefPtr<Dispatcher> dispatcher; |
| 640 MojoResult result = | 640 MojoResult result = |
| 641 GetDispatcherAndCheckRights(buffer_handle, MOJO_HANDLE_RIGHT_READ, | 641 GetDispatcherAndCheckRights(buffer_handle, MOJO_HANDLE_RIGHT_GET_OPTIONS, |
| 642 EntrypointClass::BUFFER, &dispatcher); | 642 EntrypointClass::BUFFER, &dispatcher); |
| 643 if (result != MOJO_RESULT_OK) | 643 if (result != MOJO_RESULT_OK) |
| 644 return result; | 644 return result; |
| 645 | 645 |
| 646 return dispatcher->GetBufferInformation(info, info_num_bytes); | 646 return dispatcher->GetBufferInformation(info, info_num_bytes); |
| 647 } | 647 } |
| 648 | 648 |
| 649 MojoResult Core::MapBuffer(MojoHandle buffer_handle, | 649 MojoResult Core::MapBuffer(MojoHandle buffer_handle, |
| 650 uint64_t offset, | 650 uint64_t offset, |
| 651 uint64_t num_bytes, | 651 uint64_t num_bytes, |
| 652 UserPointer<void*> buffer, | 652 UserPointer<void*> buffer, |
| 653 MojoMapBufferFlags flags) { | 653 MojoMapBufferFlags flags) { |
| 654 RefPtr<Dispatcher> dispatcher; | 654 RefPtr<Dispatcher> dispatcher; |
| 655 // TODO(vtl): Is this right? Or should there be a "map" right? Probably I need | 655 // TODO(vtl): Currently we can only map read/write. So both |
| 656 // to rethink rights for buffers. | 656 // |MOJO_HANDLE_RIGHT_MAP_READABLE| and |MOJO_HANDLE_RIGHT_MAP_WRITABLE| are |
| 657 MojoResult result = | 657 // required. |
| 658 GetDispatcherAndCheckRights(buffer_handle, MOJO_HANDLE_RIGHT_WRITE, | 658 MojoResult result = GetDispatcherAndCheckRights( |
| 659 EntrypointClass::BUFFER, &dispatcher); | 659 buffer_handle, |
| 660 MOJO_HANDLE_RIGHT_MAP_READABLE | MOJO_HANDLE_RIGHT_MAP_WRITABLE, |
| 661 EntrypointClass::BUFFER, &dispatcher); |
| 660 if (result != MOJO_RESULT_OK) | 662 if (result != MOJO_RESULT_OK) |
| 661 return result; | 663 return result; |
| 662 | 664 |
| 663 std::unique_ptr<PlatformSharedBufferMapping> mapping; | 665 std::unique_ptr<PlatformSharedBufferMapping> mapping; |
| 664 result = dispatcher->MapBuffer(offset, num_bytes, flags, &mapping); | 666 result = dispatcher->MapBuffer(offset, num_bytes, flags, &mapping); |
| 665 if (result != MOJO_RESULT_OK) | 667 if (result != MOJO_RESULT_OK) |
| 666 return result; | 668 return result; |
| 667 | 669 |
| 668 DCHECK(mapping); | 670 DCHECK(mapping); |
| 669 void* address = mapping->GetBase(); | 671 void* address = mapping->GetBase(); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 if (signals_states) { | 750 if (signals_states) { |
| 749 for (; i < num_handles; i++) | 751 for (; i < num_handles; i++) |
| 750 signals_states[i] = dispatchers[i]->GetHandleSignalsState(); | 752 signals_states[i] = dispatchers[i]->GetHandleSignalsState(); |
| 751 } | 753 } |
| 752 | 754 |
| 753 return result; | 755 return result; |
| 754 } | 756 } |
| 755 | 757 |
| 756 } // namespace system | 758 } // namespace system |
| 757 } // namespace mojo | 759 } // namespace mojo |
| OLD | NEW |