From 636b47441b3d992678b53a5a8f4fd8ea1c79a6ca Mon Sep 17 00:00:00 2001 From: "jar@chromium.org" Date: Mon, 9 Aug 2010 19:06:33 +0000 Subject: (repair leak) Protect instance after commiting to use network The code was incorrectly protecting an instance of Preconnect before deciding it would actually perform the async network calls, and need the instance to stay alive for a callback. The leak was caused when we exited the function, did not make the asnyc call, but still incref'ed the instance expecting a callback to come and decref it. BUG=51133 r=wtc Review URL: http://codereview.chromium.org/3086023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55435 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/net/preconnect.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chrome/browser/net/preconnect.cc b/chrome/browser/net/preconnect.cc index 3872d2a..a20f3c3 100644 --- a/chrome/browser/net/preconnect.cc +++ b/chrome/browser/net/preconnect.cc @@ -76,8 +76,6 @@ void Preconnect::Connect(const GURL& url) { return; } - AddRef(); // Stay alive until socket is available. - URLRequestContext* context = getter->GetURLRequestContext(); if (preconnect_despite_proxy_) { @@ -100,8 +98,10 @@ void Preconnect::Connect(const GURL& url) { } } + // We are now commited to doing the async preconnection call. UMA_HISTOGRAM_ENUMERATION("Net.PreconnectMotivation", motivation_, UrlInfo::MAX_MOTIVATED); + AddRef(); // Stay alive until socket is available. net::HttpTransactionFactory* factory = context->http_transaction_factory(); net::HttpNetworkSession* session = factory->GetSession(); -- cgit v1.1