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/embedder/embedder.h" | 5 #include "mojo/edk/embedder/embedder.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "mojo/edk/embedder/embedder_internal.h" | 8 #include "mojo/edk/embedder/embedder_internal.h" |
9 #include "mojo/edk/system/configuration.h" | 9 #include "mojo/edk/system/configuration.h" |
10 #include "mojo/edk/system/core.h" | 10 #include "mojo/edk/system/core.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 66 |
67 *platform_handle_wrapper_handle = h; | 67 *platform_handle_wrapper_handle = h; |
68 return MOJO_RESULT_OK; | 68 return MOJO_RESULT_OK; |
69 } | 69 } |
70 | 70 |
71 MojoResult PassWrappedPlatformHandle(MojoHandle platform_handle_wrapper_handle, | 71 MojoResult PassWrappedPlatformHandle(MojoHandle platform_handle_wrapper_handle, |
72 ScopedPlatformHandle* platform_handle) { | 72 ScopedPlatformHandle* platform_handle) { |
73 DCHECK(platform_handle); | 73 DCHECK(platform_handle); |
74 | 74 |
75 DCHECK(internal::g_core); | 75 DCHECK(internal::g_core); |
76 RefPtr<system::Dispatcher> dispatcher; | 76 system::Handle h; |
77 MojoResult result = internal::g_core->GetDispatcher( | 77 MojoResult result = |
78 platform_handle_wrapper_handle, &dispatcher); | 78 internal::g_core->GetHandle(platform_handle_wrapper_handle, &h); |
79 if (result != MOJO_RESULT_OK) | 79 if (result != MOJO_RESULT_OK) |
80 return result; | 80 return result; |
81 | 81 |
82 if (dispatcher->GetType() != system::Dispatcher::Type::PLATFORM_HANDLE) | 82 if (h.dispatcher->GetType() != system::Dispatcher::Type::PLATFORM_HANDLE) |
83 return MOJO_RESULT_INVALID_ARGUMENT; | 83 return MOJO_RESULT_INVALID_ARGUMENT; |
84 | 84 |
| 85 if (!h.has_all_rights(MOJO_HANDLE_RIGHT_READ | MOJO_HANDLE_RIGHT_WRITE)) |
| 86 return MOJO_RESULT_PERMISSION_DENIED; |
| 87 |
85 *platform_handle = | 88 *platform_handle = |
86 static_cast<system::PlatformHandleDispatcher*>(dispatcher.get()) | 89 static_cast<system::PlatformHandleDispatcher*>(h.dispatcher.get()) |
87 ->PassPlatformHandle(); | 90 ->PassPlatformHandle(); |
88 return MOJO_RESULT_OK; | 91 return MOJO_RESULT_OK; |
89 } | 92 } |
90 | 93 |
91 } // namespace embedder | 94 } // namespace embedder |
92 } // namespace mojo | 95 } // namespace mojo |
OLD | NEW |