summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authordmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-13 00:32:02 +0000
committerdmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-13 00:32:02 +0000
commit844a3728e33f41b5a1162be6d62390d45444b3e6 (patch)
treec1c8e9b924b23d4dd73bd9b1464b83cd435db208 /remoting
parent37d0f6a1bb4f9775d53fa44a81e03fc1dafe6272 (diff)
downloadchromium_src-844a3728e33f41b5a1162be6d62390d45444b3e6.zip
chromium_src-844a3728e33f41b5a1162be6d62390d45444b3e6.tar.gz
chromium_src-844a3728e33f41b5a1162be6d62390d45444b3e6.tar.bz2
Fix up memory leak in remoting host tests.
Adds comments about some of the ownership issues. BUG=75020 TEST=BUILD Review URL: http://codereview.chromium.org/7016025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85226 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r--remoting/host/chromoting_host.h4
-rw-r--r--remoting/host/chromoting_host_unittest.cc19
-rw-r--r--remoting/host/client_session.h2
3 files changed, 15 insertions, 10 deletions
diff --git a/remoting/host/chromoting_host.h b/remoting/host/chromoting_host.h
index 99f1fd7..3404c64 100644
--- a/remoting/host/chromoting_host.h
+++ b/remoting/host/chromoting_host.h
@@ -69,6 +69,8 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>,
public:
// Factory methods that must be used to create ChromotingHost instances.
// Default capturer and input stub are used if it is not specified.
+ // Returned instance takes ownership of |access_verifier| and |environment|,
+ // and adds a reference to |config|. It does NOT take ownership of |context|.
static ChromotingHost* Create(ChromotingHostContext* context,
MutableHostConfig* config,
AccessVerifier* access_verifier);
@@ -128,6 +130,8 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>,
typedef std::vector<scoped_refptr<HostStatusObserver> > StatusObserverList;
typedef std::vector<scoped_refptr<ClientSession> > ClientList;
+ // Takes ownership of |access_verifier| and |environment|, and adds a
+ // reference to |config|. Does NOT take ownership of |context|.
ChromotingHost(ChromotingHostContext* context,
MutableHostConfig* config,
DesktopEnvironment* environment,
diff --git a/remoting/host/chromoting_host_unittest.cc b/remoting/host/chromoting_host_unittest.cc
index 450267a..9da2a55 100644
--- a/remoting/host/chromoting_host_unittest.cc
+++ b/remoting/host/chromoting_host_unittest.cc
@@ -82,10 +82,7 @@ class ChromotingHostTest : public testing::Test {
.Times(AnyNumber());
Capturer* capturer = new CapturerFake();
- host_stub_ = new MockHostStub();
- host_stub2_ = new MockHostStub();
event_executor_ = new MockEventExecutor();
- event_executor2_ = new MockEventExecutor();
curtain_ = new MockCurtain();
DesktopEnvironment* desktop =
new DesktopEnvironment(capturer, event_executor_, curtain_);
@@ -97,9 +94,9 @@ class ChromotingHostTest : public testing::Test {
credentials_.set_username("user");
credentials_.set_credential("password");
connection_ = new MockConnectionToClient(
- &message_loop_, &handler_, host_stub_, event_executor_);
+ &message_loop_, &handler_, &host_stub_, event_executor_);
connection2_ = new MockConnectionToClient(
- &message_loop_, &handler_, host_stub2_, event_executor2_);
+ &message_loop_, &handler_, &host_stub2_, &event_executor2_);
session_ = new MockSession();
session2_ = new MockSession();
session_config_.reset(SessionConfig::CreateDefault());
@@ -199,16 +196,18 @@ class ChromotingHostTest : public testing::Test {
scoped_ptr<SessionConfig> session_config_;
MockVideoStub video_stub_;
MockClientStub client_stub_;
- MockHostStub* host_stub_;
- MockEventExecutor* event_executor_;
- MockCurtain* curtain_;
+ MockHostStub host_stub_;
scoped_refptr<MockConnectionToClient> connection2_;
scoped_refptr<MockSession> session2_;
scoped_ptr<SessionConfig> session_config2_;
MockVideoStub video_stub2_;
MockClientStub client_stub2_;
- MockHostStub* host_stub2_;
- MockEventExecutor* event_executor2_;
+ MockHostStub host_stub2_;
+ MockEventExecutor event_executor2_;
+
+ // Owned by |host_|.
+ MockEventExecutor* event_executor_;
+ MockCurtain* curtain_;
};
TEST_F(ChromotingHostTest, StartAndShutdown) {
diff --git a/remoting/host/client_session.h b/remoting/host/client_session.h
index 131cc70..e21d7bc 100644
--- a/remoting/host/client_session.h
+++ b/remoting/host/client_session.h
@@ -34,6 +34,8 @@ class ClientSession : public protocol::HostStub,
scoped_refptr<protocol::ConnectionToClient> client) = 0;
};
+ // Takes ownership of |user_authenticator|. Does not take ownership of
+ // |event_handler| or |input_stub|.
ClientSession(EventHandler* event_handler,
UserAuthenticator* user_authenticator,
scoped_refptr<protocol::ConnectionToClient> connection,