Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/test/scoped_ipc_support.h" | 5 #include "mojo/edk/test/scoped_ipc_support.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "mojo/edk/embedder/embedder.h" | 10 #include "mojo/edk/embedder/embedder.h" |
| 11 | 11 |
| 12 namespace mojo { | 12 namespace mojo { |
| 13 namespace edk { | 13 namespace edk { |
| 14 namespace test { | 14 namespace test { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 base::TaskRunner* g_io_task_runner = nullptr; | 17 base::TaskRunner* g_io_task_runner = nullptr; |
| 18 } | 18 } |
| 19 | 19 |
| 20 base::TaskRunner* GetIoTaskRunner() { | 20 base::TaskRunner* GetIoTaskRunner() { |
| 21 return g_io_task_runner; | 21 return g_io_task_runner; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace internal { | |
| 25 | |
| 26 ScopedIPCSupportHelper::ScopedIPCSupportHelper() { | |
| 27 } | |
| 28 | |
| 29 ScopedIPCSupportHelper::~ScopedIPCSupportHelper() { | |
| 30 ShutdownIPCSupport(); | |
| 31 run_loop_.Run(); | |
| 32 } | |
| 33 | |
| 34 void ScopedIPCSupportHelper::Init( | |
| 35 ProcessDelegate* process_delegate, | |
| 36 scoped_refptr<base::TaskRunner> io_thread_task_runner) { | |
| 37 io_thread_task_runner_ = io_thread_task_runner; | |
| 38 InitIPCSupport(process_delegate, io_thread_task_runner_); | |
| 39 } | |
| 40 | |
| 41 void ScopedIPCSupportHelper::OnShutdownCompleteImpl() { | |
| 42 run_loop_.Quit(); | |
| 43 } | |
| 44 | |
| 45 } // namespace internal | |
| 46 | |
| 47 ScopedIPCSupport::ScopedIPCSupport( | 24 ScopedIPCSupport::ScopedIPCSupport( |
| 48 scoped_refptr<base::TaskRunner> io_thread_task_runner) { | 25 scoped_refptr<base::TaskRunner> io_thread_task_runner) { |
| 49 g_io_task_runner = io_thread_task_runner.get(); | 26 g_io_task_runner = io_thread_task_runner.get(); |
| 50 helper_.Init(this, std::move(io_thread_task_runner)); | 27 InitIPCSupport(this, io_thread_task_runner); |
| 51 } | 28 } |
| 52 | 29 |
| 53 ScopedIPCSupport::~ScopedIPCSupport() { | 30 ScopedIPCSupport::~ScopedIPCSupport() { |
| 31 base::RunLoop run_loop; | |
| 32 quit_closure = run_loop.QuitClosure(); | |
| 33 ShutdownIPCSupport(); | |
| 34 run_loop.Run(); | |
| 54 } | 35 } |
| 55 | 36 |
| 56 void ScopedIPCSupport::OnShutdownComplete() { | 37 void ScopedIPCSupport::OnShutdownComplete() { |
| 57 helper_.OnShutdownCompleteImpl(); | 38 DCHECK(!quit_closure.is_null()); |
| 39 quit_closure.Run(); | |
|
yzshen1
2016/11/20 06:07:35
(My understanding of the embedder API is purely fr
| |
| 58 } | 40 } |
| 59 | 41 |
| 60 } // namespace test | 42 } // namespace test |
| 61 } // namespace edk | 43 } // namespace edk |
| 62 } // namespace mojo | 44 } // namespace mojo |
| OLD | NEW |