diff options
author | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-20 22:08:11 +0000 |
---|---|---|
committer | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-20 22:08:11 +0000 |
commit | 084683940bef81aeeceb00db74f674422c831ff4 (patch) | |
tree | 20fca58642e6e47590833dbc37f3eed06075a880 | |
parent | bc7076729aacf96b53a25b58a4122b4f810b7802 (diff) | |
download | chromium_src-084683940bef81aeeceb00db74f674422c831ff4.zip chromium_src-084683940bef81aeeceb00db74f674422c831ff4.tar.gz chromium_src-084683940bef81aeeceb00db74f674422c831ff4.tar.bz2 |
Fix unit test memory leak
(found by purify)
TBR=brettw
Review URL: http://codereview.chromium.org/27012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10128 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/renderer_host/mock_render_process_host.cc | 14 | ||||
-rw-r--r-- | chrome/browser/renderer_host/mock_render_process_host.h | 3 |
2 files changed, 13 insertions, 4 deletions
diff --git a/chrome/browser/renderer_host/mock_render_process_host.cc b/chrome/browser/renderer_host/mock_render_process_host.cc index dc33bc1..f6aec46 100644 --- a/chrome/browser/renderer_host/mock_render_process_host.cc +++ b/chrome/browser/renderer_host/mock_render_process_host.cc @@ -5,10 +5,12 @@ #include "chrome/browser/renderer_host/mock_render_process_host.h" MockRenderProcessHost::MockRenderProcessHost(Profile* profile) - : RenderProcessHost(profile) { + : RenderProcessHost(profile), + transport_dib_(NULL) { } MockRenderProcessHost::~MockRenderProcessHost() { + delete transport_dib_; } bool MockRenderProcessHost::Init() { @@ -58,15 +60,19 @@ bool MockRenderProcessHost::Send(IPC::Message* msg) { } TransportDIB* MockRenderProcessHost::GetTransportDIB(TransportDIB::Id dib_id) { + delete transport_dib_; + #if defined(OS_WIN) - return TransportDIB::Map(dib_id.handle); + transport_dib_ = TransportDIB::Map(dib_id.handle); #elif defined(OS_MACOSX) // On Mac, TransportDIBs are always created in the browser, so we cannot map // one from a dib_id. - return TransportDIB::Create(100 * 100 * 4, 0); + transport_dib_ = TransportDIB::Create(100 * 100 * 4, 0); #elif defined(OS_LINUX) - return TransportDIB::Map(dib_id); + transport_dib_ = TransportDIB::Map(dib_id); #endif + + return transport_dib_; } void MockRenderProcessHost::OnMessageReceived(const IPC::Message& msg) { diff --git a/chrome/browser/renderer_host/mock_render_process_host.h b/chrome/browser/renderer_host/mock_render_process_host.h index bfe49ee..9b63653 100644 --- a/chrome/browser/renderer_host/mock_render_process_host.h +++ b/chrome/browser/renderer_host/mock_render_process_host.h @@ -9,6 +9,8 @@ #include "chrome/browser/renderer_host/render_process_host.h" #include "chrome/common/ipc_test_sink.h" +class TransportDIB; + // A mock render process host that has no corresponding renderer process. The // process() refers to the current process, and all IPC messages are sent into // the message sink for inspection by tests. @@ -47,6 +49,7 @@ class MockRenderProcessHost : public RenderProcessHost { private: // Stores IPC messages that would have been sent to the renderer. IPC::TestSink sink_; + TransportDIB* transport_dib_; DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHost); }; |