diff options
author | dtapuska <dtapuska@chromium.org> | 2015-05-01 06:58:25 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-01 14:26:21 +0000 |
commit | dafcf89b36898f4f4afc010824879290b9e51e3a (patch) | |
tree | 37abdef8dfe04288c9401a0baf04be28f9118ab4 /extensions/browser/updater | |
parent | f75b259d8c304678fe77867b9ca01e9a9e6a202a (diff) | |
download | chromium_src-dafcf89b36898f4f4afc010824879290b9e51e3a.zip chromium_src-dafcf89b36898f4f4afc010824879290b9e51e3a.tar.gz chromium_src-dafcf89b36898f4f4afc010824879290b9e51e3a.tar.bz2 |
Adjust URLFetcher::Create API so that object is returned as scoped_ptr.
Most interfaces were storing the object in a scoped_ptr already. This
adjusts the API so that it is a little clearer of the ownership
transfer.
A number of clients put the URLFetcher in a table and do memory
management on it themselves; this is likely templatable code
for a future CL. The scope of this CL was to change the API but
no control flow changes. Making this change found one memory leak;
(http://crbug.com/482459) has been addressed separately.
BUG=371201
TESTS=net_unittests google_api_unittests
TBR=jochen@chromium.org, thakis@chromium.org, oshima@chromium.org, armansito@chromium.org, reillyg@chromium.org, rogerta@chromium.org, stuartmorgan@chromium.org, wez@chromium.org, pavely@chromium.org, rouslan@chromium.org
Review URL: https://codereview.chromium.org/1117703002
Cr-Commit-Position: refs/heads/master@{#327901}
Diffstat (limited to 'extensions/browser/updater')
-rw-r--r-- | extensions/browser/updater/extension_downloader.cc | 12 | ||||
-rw-r--r-- | extensions/browser/updater/update_service_browsertest.cc | 17 |
2 files changed, 14 insertions, 15 deletions
diff --git a/extensions/browser/updater/extension_downloader.cc b/extensions/browser/updater/extension_downloader.cc index e1e61f8..87958ae 100644 --- a/extensions/browser/updater/extension_downloader.cc +++ b/extensions/browser/updater/extension_downloader.cc @@ -473,11 +473,9 @@ void ExtensionDownloader::CreateManifestFetcher() { << " for " << id_list; } - manifest_fetcher_.reset( - net::URLFetcher::Create(kManifestFetcherId, - manifests_queue_.active_request()->full_url(), - net::URLFetcher::GET, - this)); + manifest_fetcher_ = net::URLFetcher::Create( + kManifestFetcherId, manifests_queue_.active_request()->full_url(), + net::URLFetcher::GET, this); manifest_fetcher_->SetRequestContext(request_context_.get()); manifest_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES | @@ -762,8 +760,8 @@ void ExtensionDownloader::CacheInstallDone( void ExtensionDownloader::CreateExtensionFetcher() { const ExtensionFetch* fetch = extensions_queue_.active_request(); - extension_fetcher_.reset(net::URLFetcher::Create( - kExtensionFetcherId, fetch->url, net::URLFetcher::GET, this)); + extension_fetcher_ = net::URLFetcher::Create(kExtensionFetcherId, fetch->url, + net::URLFetcher::GET, this); extension_fetcher_->SetRequestContext(request_context_.get()); extension_fetcher_->SetAutomaticallyRetryOnNetworkChanges(3); diff --git a/extensions/browser/updater/update_service_browsertest.cc b/extensions/browser/updater/update_service_browsertest.cc index c4ff0ef..bd9a55e 100644 --- a/extensions/browser/updater/update_service_browsertest.cc +++ b/extensions/browser/updater/update_service_browsertest.cc @@ -105,7 +105,7 @@ class FakeUpdateURLFetcherFactory : public net::URLFetcherFactory { } // net::URLFetcherFactory: - net::URLFetcher* CreateURLFetcher( + scoped_ptr<net::URLFetcher> CreateURLFetcher( int id, const GURL& url, net::URLFetcher::RequestType request_type, @@ -122,7 +122,7 @@ class FakeUpdateURLFetcherFactory : public net::URLFetcherFactory { } private: - net::URLFetcher* CreateUpdateManifestFetcher( + scoped_ptr<net::URLFetcher> CreateUpdateManifestFetcher( const GURL& url, net::URLFetcherDelegate* delegate) { // If we have a fake CRX for the ID, return a fake update blob for it. @@ -138,13 +138,14 @@ class FakeUpdateURLFetcherFactory : public net::URLFetcherFactory { else response = CreateFakeUpdateResponse(extension_id, iter->second.size()); } - return new net::FakeURLFetcher(url, delegate, response.first, - response.second, - net::URLRequestStatus::SUCCESS); + return scoped_ptr<net::URLFetcher>( + new net::FakeURLFetcher(url, delegate, response.first, response.second, + net::URLRequestStatus::SUCCESS)); } - net::URLFetcher* CreateCrxFetcher(const GURL& url, - net::URLFetcherDelegate* delegate) { + scoped_ptr<net::URLFetcher> CreateCrxFetcher( + const GURL& url, + net::URLFetcherDelegate* delegate) { FakeResponse response; std::string extension_id = url.path().substr(1, 32); const auto& iter = fake_extensions_.find(extension_id); @@ -156,7 +157,7 @@ class FakeUpdateURLFetcherFactory : public net::URLFetcherFactory { new net::FakeURLFetcher(url, delegate, response.first, response.second, net::URLRequestStatus::SUCCESS); fetcher->SetResponseFilePath(base::FilePath::FromUTF8Unsafe(url.path())); - return fetcher; + return scoped_ptr<net::URLFetcher>(fetcher); } std::map<std::string, std::string> fake_extensions_; |