Index: third_party/mojo/src/mojo/edk/system/connection_manager_unittest.cc |
diff --git a/third_party/mojo/src/mojo/edk/system/connection_manager_unittest.cc b/third_party/mojo/src/mojo/edk/system/connection_manager_unittest.cc |
index f1939a0e56503902428044f60b8371ae7bfac0c9..fea0920738f55622b4b83357b740c6a8d3c36cfb 100644 |
--- a/third_party/mojo/src/mojo/edk/system/connection_manager_unittest.cc |
+++ b/third_party/mojo/src/mojo/edk/system/connection_manager_unittest.cc |
@@ -17,6 +17,7 @@ |
#include "base/threading/thread_checker.h" |
#include "mojo/edk/embedder/master_process_delegate.h" |
#include "mojo/edk/embedder/platform_channel_pair.h" |
+#include "mojo/edk/embedder/simple_platform_support.h" |
#include "mojo/edk/embedder/slave_process_delegate.h" |
#include "mojo/edk/system/master_connection_manager.h" |
#include "mojo/edk/system/slave_connection_manager.h" |
@@ -63,10 +64,10 @@ bool IsValidSlaveProcessIdentifier(ProcessIdentifier process_identifier) { |
process_identifier != kMasterProcessIdentifier; |
} |
-class TestSlaveInfo : public embedder::SlaveInfo { |
+class TestSlaveInfo { |
public: |
explicit TestSlaveInfo(const std::string& name) : name_(name) {} |
- ~TestSlaveInfo() override { CHECK(thread_checker_.CalledOnValidThread()); } |
+ ~TestSlaveInfo() { CHECK(thread_checker_.CalledOnValidThread()); } |
const std::string& name() const { return name_; } |
@@ -85,7 +86,7 @@ void ConnectSlave(MasterConnectionManager* master, |
SlaveConnectionManager* slave, |
const std::string& slave_name) { |
embedder::PlatformChannelPair platform_channel_pair; |
- master->AddSlave(make_scoped_ptr(new TestSlaveInfo(slave_name)), |
+ master->AddSlave(new TestSlaveInfo(slave_name), |
platform_channel_pair.PassServerHandle()); |
slave->Init(base::MessageLoop::current()->task_runner(), |
slave_process_delegate, platform_channel_pair.PassClientHandle()); |
@@ -113,14 +114,16 @@ class MockMasterProcessDelegate : public embedder::MasterProcessDelegate { |
} |
// |embedder::MasterProcessDelegate| implementation: |
- void OnSlaveDisconnect(scoped_ptr<embedder::SlaveInfo> slave_info) override { |
+ void OnShutdownComplete() override { NOTREACHED(); } |
+ |
+ void OnSlaveDisconnect(embedder::SlaveInfo slave_info) override { |
CHECK(thread_checker_.CalledOnValidThread()); |
on_slave_disconnect_calls_++; |
last_slave_disconnect_name_ = |
- static_cast<TestSlaveInfo*>(slave_info.get())->name(); |
+ static_cast<TestSlaveInfo*>(slave_info)->name(); |
DVLOG(1) << "Disconnected from slave process " |
<< last_slave_disconnect_name_; |
- slave_info.reset(); |
+ delete static_cast<TestSlaveInfo*>(slave_info); |
if (current_run_loop_) |
current_run_loop_->Quit(); |
@@ -155,6 +158,8 @@ class MockSlaveProcessDelegate : public embedder::SlaveProcessDelegate { |
} |
// |embedder::SlaveProcessDelegate| implementation: |
+ void OnShutdownComplete() override { NOTREACHED(); } |
+ |
void OnMasterDisconnect() override { |
CHECK(thread_checker_.CalledOnValidThread()); |
on_master_disconnect_calls_++; |
@@ -178,12 +183,15 @@ class ConnectionManagerTest : public testing::Test { |
ConnectionManagerTest() {} |
~ConnectionManagerTest() override {} |
+ embedder::PlatformSupport* platform_support() { return &platform_support_; } |
+ |
base::MessageLoop& message_loop() { return message_loop_; } |
MockMasterProcessDelegate& master_process_delegate() { |
return master_process_delegate_; |
} |
private: |
+ embedder::SimplePlatformSupport platform_support_; |
base::MessageLoop message_loop_; |
MockMasterProcessDelegate master_process_delegate_; |
@@ -203,7 +211,8 @@ TEST_F(ConnectionManagerTest, BasicConnectSlaves) { |
SlaveConnectionManager slave2; |
ConnectSlave(&master, &slave2_process_delegate, &slave2, "slave2"); |
- ConnectionIdentifier connection_id = ConnectionIdentifier::Generate(); |
+ ConnectionIdentifier connection_id = |
+ ConnectionIdentifier::Generate(platform_support()); |
EXPECT_TRUE(slave1.AllowConnect(connection_id)); |
EXPECT_TRUE(slave2.AllowConnect(connection_id)); |
@@ -291,7 +300,8 @@ TEST_F(ConnectionManagerTest, SlaveCancelConnect) { |
SlaveConnectionManager slave2; |
ConnectSlave(&master, &slave2_process_delegate, &slave2, "slave2"); |
- ConnectionIdentifier connection_id = ConnectionIdentifier::Generate(); |
+ ConnectionIdentifier connection_id = |
+ ConnectionIdentifier::Generate(platform_support()); |
EXPECT_TRUE(slave1.AllowConnect(connection_id)); |
EXPECT_TRUE(slave2.AllowConnect(connection_id)); |
@@ -321,7 +331,8 @@ TEST_F(ConnectionManagerTest, ErrorRemovePending) { |
SlaveConnectionManager slave2; |
ConnectSlave(&master, &slave2_process_delegate, &slave2, "slave2"); |
- ConnectionIdentifier connection_id = ConnectionIdentifier::Generate(); |
+ ConnectionIdentifier connection_id = |
+ ConnectionIdentifier::Generate(platform_support()); |
EXPECT_TRUE(slave1.AllowConnect(connection_id)); |
EXPECT_TRUE(slave2.AllowConnect(connection_id)); |
@@ -352,7 +363,8 @@ TEST_F(ConnectionManagerTest, ConnectSlaveToSelf) { |
SlaveConnectionManager slave; |
ConnectSlave(&master, &slave_process_delegate, &slave, "slave"); |
- ConnectionIdentifier connection_id = ConnectionIdentifier::Generate(); |
+ ConnectionIdentifier connection_id = |
+ ConnectionIdentifier::Generate(platform_support()); |
EXPECT_TRUE(slave.AllowConnect(connection_id)); |
EXPECT_TRUE(slave.AllowConnect(connection_id)); |
@@ -388,7 +400,8 @@ TEST_F(ConnectionManagerTest, ConnectSlavesTwice) { |
SlaveConnectionManager slave2; |
ConnectSlave(&master, &slave2_process_delegate, &slave2, "slave2"); |
- ConnectionIdentifier connection_id = ConnectionIdentifier::Generate(); |
+ ConnectionIdentifier connection_id = |
+ ConnectionIdentifier::Generate(platform_support()); |
EXPECT_TRUE(slave1.AllowConnect(connection_id)); |
EXPECT_TRUE(slave2.AllowConnect(connection_id)); |
@@ -407,7 +420,7 @@ TEST_F(ConnectionManagerTest, ConnectSlavesTwice) { |
// tracking and is prone to races -- especially if we want slaves to be able |
// to tear down no-longer-needed connections.) But the slaves should be able |
// to do the tracking themselves (using the peer process identifiers). |
- connection_id = ConnectionIdentifier::Generate(); |
+ connection_id = ConnectionIdentifier::Generate(platform_support()); |
EXPECT_TRUE(slave1.AllowConnect(connection_id)); |
EXPECT_TRUE(slave2.AllowConnect(connection_id)); |
@@ -436,7 +449,8 @@ TEST_F(ConnectionManagerTest, ConnectMasterToSlave) { |
SlaveConnectionManager slave; |
ConnectSlave(&master, &slave_process_delegate, &slave, "slave"); |
- ConnectionIdentifier connection_id = ConnectionIdentifier::Generate(); |
+ ConnectionIdentifier connection_id = |
+ ConnectionIdentifier::Generate(platform_support()); |
EXPECT_TRUE(master.AllowConnect(connection_id)); |
EXPECT_TRUE(slave.AllowConnect(connection_id)); |
@@ -463,7 +477,8 @@ TEST_F(ConnectionManagerTest, ConnectMasterToSelf) { |
master.Init(base::MessageLoop::current()->task_runner(), |
&master_process_delegate()); |
- ConnectionIdentifier connection_id = ConnectionIdentifier::Generate(); |
+ ConnectionIdentifier connection_id = |
+ ConnectionIdentifier::Generate(platform_support()); |
EXPECT_TRUE(master.AllowConnect(connection_id)); |
EXPECT_TRUE(master.AllowConnect(connection_id)); |
@@ -494,7 +509,8 @@ TEST_F(ConnectionManagerTest, MasterCancelConnect) { |
SlaveConnectionManager slave; |
ConnectSlave(&master, &slave_process_delegate, &slave, "slave"); |
- ConnectionIdentifier connection_id = ConnectionIdentifier::Generate(); |
+ ConnectionIdentifier connection_id = |
+ ConnectionIdentifier::Generate(platform_support()); |
EXPECT_TRUE(master.AllowConnect(connection_id)); |
EXPECT_TRUE(slave.AllowConnect(connection_id)); |
@@ -517,7 +533,7 @@ TEST_F(ConnectionManagerTest, AddSlaveThenImmediateShutdown) { |
MockSlaveProcessDelegate slave_process_delegate; |
SlaveConnectionManager slave; |
embedder::PlatformChannelPair platform_channel_pair; |
- master.AddSlave(make_scoped_ptr(new TestSlaveInfo("slave")), |
+ master.AddSlave(new TestSlaveInfo("slave"), |
platform_channel_pair.PassServerHandle()); |
master.Shutdown(); |
// Since we never initialized |slave|, we don't have to shut it down. |