diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-10 04:19:48 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-10 04:19:48 +0000 |
commit | 871406c10cdc641bc481d152228b52027e3d1653 (patch) | |
tree | 14ef2fb38024b734e43950bc47da0ab8d92773fb | |
parent | 978857644f798a06075130b211b1780edde7a601 (diff) | |
download | chromium_src-871406c10cdc641bc481d152228b52027e3d1653.zip chromium_src-871406c10cdc641bc481d152228b52027e3d1653.tar.gz chromium_src-871406c10cdc641bc481d152228b52027e3d1653.tar.bz2 |
Clarify the ownership of the dispatcher when we create it. Delete it if
initialization fails (up until now, init can't fail, so this didn't end up
being a real leak).
Review URL: http://codereview.chromium.org/6821019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81054 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/ppapi_plugin/ppapi_thread.cc | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/content/ppapi_plugin/ppapi_thread.cc b/content/ppapi_plugin/ppapi_thread.cc index b67e578..ecec2dd 100644 --- a/content/ppapi_plugin/ppapi_thread.cc +++ b/content/ppapi_plugin/ppapi_thread.cc @@ -109,14 +109,16 @@ void PpapiThread::OnMsgCreateChannel(base::ProcessHandle host_process_handle, bool PpapiThread::SetupRendererChannel(base::ProcessHandle host_process_handle, int renderer_id, IPC::ChannelHandle* handle) { - PluginProcessDispatcher* dispatcher = new PluginProcessDispatcher( - host_process_handle, get_plugin_interface_); + PluginProcessDispatcher* dispatcher(new PluginProcessDispatcher( + host_process_handle, get_plugin_interface_)); IPC::ChannelHandle plugin_handle; plugin_handle.name = StringPrintf("%d.r%d", base::GetCurrentProcId(), renderer_id); - if (!dispatcher->InitWithChannel(this, plugin_handle, false)) + if (!dispatcher->InitWithChannel(this, plugin_handle, false)) { + delete dispatcher; return false; + } handle->name = plugin_handle.name; #if defined(OS_POSIX) @@ -125,6 +127,8 @@ bool PpapiThread::SetupRendererChannel(base::ProcessHandle host_process_handle, true); #endif + // From here, the dispatcher will manage its own lifetime according to the + // lifetime of the attached channel. return true; } |