| Index: mojo/edk/system/master_connection_manager.cc
|
| diff --git a/mojo/edk/system/master_connection_manager.cc b/mojo/edk/system/master_connection_manager.cc
|
| index 86bf07199d340b9c471f056a406dea9636951230..afd7f073c70f511e9eac98a21ea8626c000914fa 100644
|
| --- a/mojo/edk/system/master_connection_manager.cc
|
| +++ b/mojo/edk/system/master_connection_manager.cc
|
| @@ -252,11 +252,20 @@ void MasterConnectionManager::Init(
|
|
|
| void MasterConnectionManager::AddSlave(
|
| embedder::SlaveInfo slave_info,
|
| - embedder::ScopedPlatformHandle platform_handle) {
|
| + embedder::ScopedPlatformHandle platform_handle,
|
| + ProcessIdentifier* slave_process_identifier) {
|
| // We don't really care if |slave_info| is non-null or not.
|
| DCHECK(platform_handle.is_valid());
|
| + DCHECK(slave_process_identifier);
|
| AssertNotOnPrivateThread();
|
|
|
| + {
|
| + base::AutoLock locker(lock_);
|
| + CHECK_NE(next_process_identifier_, kMasterProcessIdentifier);
|
| + *slave_process_identifier = next_process_identifier_;
|
| + next_process_identifier_++;
|
| + }
|
| +
|
| // We have to wait for the task to be executed, in case someone calls
|
| // |AddSlave()| followed immediately by |Shutdown()|.
|
| base::WaitableEvent event(false, false);
|
| @@ -264,10 +273,32 @@ void MasterConnectionManager::AddSlave(
|
| FROM_HERE,
|
| base::Bind(&MasterConnectionManager::AddSlaveOnPrivateThread,
|
| base::Unretained(this), base::Unretained(slave_info),
|
| - base::Passed(&platform_handle), base::Unretained(&event)));
|
| + base::Passed(&platform_handle), *slave_process_identifier,
|
| + base::Unretained(&event)));
|
| event.Wait();
|
| }
|
|
|
| +bool MasterConnectionManager::AddSlaveAndBootstrap(
|
| + embedder::SlaveInfo slave_info,
|
| + embedder::ScopedPlatformHandle platform_handle,
|
| + const ConnectionIdentifier& connection_id,
|
| + ProcessIdentifier* slave_process_identifier) {
|
| + AddSlave(slave_info, platform_handle.Pass(), slave_process_identifier);
|
| +
|
| + base::AutoLock locker(lock_);
|
| +
|
| + auto it = pending_connections_.find(connection_id);
|
| + if (it != pending_connections_.end())
|
| + return false;
|
| +
|
| + PendingConnectionInfo* info =
|
| + new PendingConnectionInfo(kMasterProcessIdentifier);
|
| + info->state = PendingConnectionInfo::AWAITING_CONNECTS_FROM_BOTH;
|
| + info->second = *slave_process_identifier;
|
| + pending_connections_[connection_id] = info;
|
| + return true;
|
| +}
|
| +
|
| void MasterConnectionManager::Shutdown() {
|
| AssertNotOnPrivateThread();
|
| DCHECK(master_process_delegate_);
|
| @@ -494,23 +525,20 @@ void MasterConnectionManager::ShutdownOnPrivateThread() {
|
| void MasterConnectionManager::AddSlaveOnPrivateThread(
|
| embedder::SlaveInfo slave_info,
|
| embedder::ScopedPlatformHandle platform_handle,
|
| + ProcessIdentifier slave_process_identifier,
|
| base::WaitableEvent* event) {
|
| DCHECK(platform_handle.is_valid());
|
| DCHECK(event);
|
| AssertOnPrivateThread();
|
|
|
| - CHECK_NE(next_process_identifier_, kMasterProcessIdentifier);
|
| - ProcessIdentifier process_identifier = next_process_identifier_;
|
| - next_process_identifier_++;
|
| -
|
| - scoped_ptr<Helper> helper(
|
| - new Helper(this, process_identifier, slave_info, platform_handle.Pass()));
|
| + scoped_ptr<Helper> helper(new Helper(this, slave_process_identifier,
|
| + slave_info, platform_handle.Pass()));
|
| helper->Init();
|
|
|
| - DCHECK(helpers_.find(process_identifier) == helpers_.end());
|
| - helpers_[process_identifier] = helper.release();
|
| + DCHECK(helpers_.find(slave_process_identifier) == helpers_.end());
|
| + helpers_[slave_process_identifier] = helper.release();
|
|
|
| - DVLOG(1) << "Added process identifier " << process_identifier;
|
| + DVLOG(1) << "Added slave process identifier " << slave_process_identifier;
|
| event->Signal();
|
| }
|
|
|
|
|