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" |
| 11 #include "mojo/edk/system/handle.h" |
11 #include "mojo/edk/system/platform_handle_dispatcher.h" | 12 #include "mojo/edk/system/platform_handle_dispatcher.h" |
12 #include "mojo/edk/util/ref_ptr.h" | 13 #include "mojo/edk/util/ref_ptr.h" |
13 | 14 |
14 using mojo::platform::ScopedPlatformHandle; | 15 using mojo::platform::ScopedPlatformHandle; |
15 using mojo::util::RefPtr; | 16 using mojo::util::RefPtr; |
16 | 17 |
17 namespace mojo { | 18 namespace mojo { |
18 namespace embedder { | 19 namespace embedder { |
19 | 20 |
20 namespace internal { | 21 namespace internal { |
(...skipping 26 matching lines...) Expand all Loading... |
47 | 48 |
48 MojoResult CreatePlatformHandleWrapper( | 49 MojoResult CreatePlatformHandleWrapper( |
49 ScopedPlatformHandle platform_handle, | 50 ScopedPlatformHandle platform_handle, |
50 MojoHandle* platform_handle_wrapper_handle) { | 51 MojoHandle* platform_handle_wrapper_handle) { |
51 DCHECK(platform_handle_wrapper_handle); | 52 DCHECK(platform_handle_wrapper_handle); |
52 | 53 |
53 auto dispatcher = | 54 auto dispatcher = |
54 system::PlatformHandleDispatcher::Create(platform_handle.Pass()); | 55 system::PlatformHandleDispatcher::Create(platform_handle.Pass()); |
55 | 56 |
56 DCHECK(internal::g_core); | 57 DCHECK(internal::g_core); |
57 MojoHandle h = internal::g_core->AddDispatcher(dispatcher.get()); | 58 MojoHandle h = internal::g_core->AddHandle( |
| 59 system::Handle(dispatcher.Clone(), |
| 60 system::PlatformHandleDispatcher::kDefaultHandleRights)); |
58 if (h == MOJO_HANDLE_INVALID) { | 61 if (h == MOJO_HANDLE_INVALID) { |
59 LOG(ERROR) << "Handle table full"; | 62 LOG(ERROR) << "Handle table full"; |
60 dispatcher->Close(); | 63 dispatcher->Close(); |
61 return MOJO_RESULT_RESOURCE_EXHAUSTED; | 64 return MOJO_RESULT_RESOURCE_EXHAUSTED; |
62 } | 65 } |
63 | 66 |
64 *platform_handle_wrapper_handle = h; | 67 *platform_handle_wrapper_handle = h; |
65 return MOJO_RESULT_OK; | 68 return MOJO_RESULT_OK; |
66 } | 69 } |
67 | 70 |
(...skipping 12 matching lines...) Expand all Loading... |
80 return MOJO_RESULT_INVALID_ARGUMENT; | 83 return MOJO_RESULT_INVALID_ARGUMENT; |
81 | 84 |
82 *platform_handle = | 85 *platform_handle = |
83 static_cast<system::PlatformHandleDispatcher*>(dispatcher.get()) | 86 static_cast<system::PlatformHandleDispatcher*>(dispatcher.get()) |
84 ->PassPlatformHandle(); | 87 ->PassPlatformHandle(); |
85 return MOJO_RESULT_OK; | 88 return MOJO_RESULT_OK; |
86 } | 89 } |
87 | 90 |
88 } // namespace embedder | 91 } // namespace embedder |
89 } // namespace mojo | 92 } // namespace mojo |
OLD | NEW |