| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/mojo_test_base.h" | 5 #include "mojo/edk/test/mojo_test_base.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "mojo/edk/embedder/embedder.h" | 10 #include "mojo/edk/embedder/embedder.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 MojoTestBase::~MojoTestBase() {} | 42 MojoTestBase::~MojoTestBase() {} |
| 43 | 43 |
| 44 MojoTestBase::ClientController& MojoTestBase::StartClient( | 44 MojoTestBase::ClientController& MojoTestBase::StartClient( |
| 45 const std::string& client_name) { | 45 const std::string& client_name) { |
| 46 clients_.push_back(base::WrapUnique(new ClientController(client_name, this))); | 46 clients_.push_back(base::WrapUnique(new ClientController(client_name, this))); |
| 47 return *clients_.back(); | 47 return *clients_.back(); |
| 48 } | 48 } |
| 49 | 49 |
| 50 MojoTestBase::ClientController::ClientController(const std::string& client_name, | 50 MojoTestBase::ClientController::ClientController(const std::string& client_name, |
| 51 MojoTestBase* test) | 51 MojoTestBase* test) { |
| 52 : test_(test) { | |
| 53 #if !defined(OS_IOS) | 52 #if !defined(OS_IOS) |
| 54 #if defined(OS_MACOSX) | 53 #if defined(OS_MACOSX) |
| 55 // This lock needs to be held while launching the child because the Mach port | 54 // This lock needs to be held while launching the child because the Mach port |
| 56 // broker only allows task ports to be received from known child processes. | 55 // broker only allows task ports to be received from known child processes. |
| 57 // However, it can only know the child process's pid after the child has | 56 // However, it can only know the child process's pid after the child has |
| 58 // launched. To prevent a race where the child process sends its task port | 57 // launched. To prevent a race where the child process sends its task port |
| 59 // before the pid has been registered, the lock needs to be held over both | 58 // before the pid has been registered, the lock needs to be held over both |
| 60 // launch and child pid registration. | 59 // launch and child pid registration. |
| 61 base::AutoLock lock(g_mach_broker->GetLock()); | 60 base::AutoLock lock(g_mach_broker->GetLock()); |
| 62 #endif | 61 #endif |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 MOJO_WRITE_DATA_FLAG_ALL_OR_NONE), | 298 MOJO_WRITE_DATA_FLAG_ALL_OR_NONE), |
| 300 MOJO_RESULT_OK); | 299 MOJO_RESULT_OK); |
| 301 CHECK_EQ(num_bytes, static_cast<uint32_t>(size)); | 300 CHECK_EQ(num_bytes, static_cast<uint32_t>(size)); |
| 302 | 301 |
| 303 return std::string(buffer.data(), buffer.size()); | 302 return std::string(buffer.data(), buffer.size()); |
| 304 } | 303 } |
| 305 | 304 |
| 306 } // namespace test | 305 } // namespace test |
| 307 } // namespace edk | 306 } // namespace edk |
| 308 } // namespace mojo | 307 } // namespace mojo |
| OLD | NEW |