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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 *num_bytes = platform_shared_buffer->GetNumBytes(); | 325 *num_bytes = platform_shared_buffer->GetNumBytes(); |
326 if (read_only) | 326 if (read_only) |
327 *read_only = platform_shared_buffer->IsReadOnly(); | 327 *read_only = platform_shared_buffer->IsReadOnly(); |
328 *shared_memory_handle = platform_shared_buffer->DuplicateSharedMemoryHandle(); | 328 *shared_memory_handle = platform_shared_buffer->DuplicateSharedMemoryHandle(); |
329 | 329 |
330 shm_dispatcher->Close(); | 330 shm_dispatcher->Close(); |
331 return result; | 331 return result; |
332 } | 332 } |
333 | 333 |
334 void Core::RequestShutdown(const base::Closure& callback) { | 334 void Core::RequestShutdown(const base::Closure& callback) { |
335 base::Closure on_shutdown; | 335 GetNodeController()->RequestShutdown(callback); |
336 if (base::ThreadTaskRunnerHandle::IsSet()) { | |
337 on_shutdown = base::Bind(base::IgnoreResult(&base::TaskRunner::PostTask), | |
338 base::ThreadTaskRunnerHandle::Get(), | |
339 FROM_HERE, callback); | |
340 } else { | |
341 on_shutdown = callback; | |
342 } | |
343 GetNodeController()->RequestShutdown(on_shutdown); | |
344 } | 336 } |
345 | 337 |
346 ScopedMessagePipeHandle Core::CreateMessagePipe( | 338 ScopedMessagePipeHandle Core::CreateMessagePipe( |
347 ScopedPlatformHandle platform_handle) { | 339 ScopedPlatformHandle platform_handle) { |
348 #if defined(OS_NACL) | 340 #if defined(OS_NACL) |
349 NOTREACHED(); | 341 NOTREACHED(); |
350 return ScopedMessagePipeHandle(); | 342 return ScopedMessagePipeHandle(); |
351 #else | 343 #else |
352 ports::PortRef port0, port1; | 344 ports::PortRef port0, port1; |
353 GetNodeController()->node()->CreatePortPair(&port0, &port1); | 345 GetNodeController()->node()->CreatePortPair(&port0, &port1); |
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1195 std::unique_ptr<NodeController> node_controller) { | 1187 std::unique_ptr<NodeController> node_controller) { |
1196 // 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 |
1197 // running, and we know the NodeController will observe its eventual | 1189 // running, and we know the NodeController will observe its eventual |
1198 // destruction. This tells the NodeController to delete itself when that | 1190 // destruction. This tells the NodeController to delete itself when that |
1199 // happens. | 1191 // happens. |
1200 node_controller.release()->DestroyOnIOThreadShutdown(); | 1192 node_controller.release()->DestroyOnIOThreadShutdown(); |
1201 } | 1193 } |
1202 | 1194 |
1203 } // namespace edk | 1195 } // namespace edk |
1204 } // namespace mojo | 1196 } // namespace mojo |
OLD | NEW |