Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1189)

Unified Diff: mojo/edk/system/master_connection_manager.cc

Issue 1146163002: Revert "Revert multiple commits:" (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: the fix Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/edk/system/master_connection_manager.h ('k') | mojo/edk/test/multiprocess_test_helper.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
« no previous file with comments | « mojo/edk/system/master_connection_manager.h ('k') | mojo/edk/test/multiprocess_test_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698