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 /components/update_client | |
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 'components/update_client')
-rw-r--r-- | components/update_client/request_sender.cc | 4 | ||||
-rw-r--r-- | components/update_client/url_fetcher_downloader.cc | 3 | ||||
-rw-r--r-- | components/update_client/utils.cc | 6 | ||||
-rw-r--r-- | components/update_client/utils.h | 3 |
4 files changed, 8 insertions, 8 deletions
diff --git a/components/update_client/request_sender.cc b/components/update_client/request_sender.cc index 726c2fa..6b89ca7 100644 --- a/components/update_client/request_sender.cc +++ b/components/update_client/request_sender.cc @@ -46,8 +46,8 @@ void RequestSender::SendInternal() { DCHECK(cur_url_->is_valid()); DCHECK(thread_checker_.CalledOnValidThread()); - url_fetcher_.reset(SendProtocolRequest(*cur_url_, request_string_, this, - config_.RequestContext())); + url_fetcher_ = SendProtocolRequest(*cur_url_, request_string_, this, + config_.RequestContext()); } void RequestSender::OnURLFetchComplete(const net::URLFetcher* source) { diff --git a/components/update_client/url_fetcher_downloader.cc b/components/update_client/url_fetcher_downloader.cc index fd7f3da..4edc1c4 100644 --- a/components/update_client/url_fetcher_downloader.cc +++ b/components/update_client/url_fetcher_downloader.cc @@ -33,8 +33,7 @@ UrlFetcherDownloader::~UrlFetcherDownloader() { void UrlFetcherDownloader::DoStartDownload(const GURL& url) { DCHECK(thread_checker_.CalledOnValidThread()); - url_fetcher_.reset( - net::URLFetcher::Create(0, url, net::URLFetcher::GET, this)); + url_fetcher_ = net::URLFetcher::Create(0, url, net::URLFetcher::GET, this); url_fetcher_->SetRequestContext(context_getter_); url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES | diff --git a/components/update_client/utils.cc b/components/update_client/utils.cc index 47bb437..11e8060 100644 --- a/components/update_client/utils.cc +++ b/components/update_client/utils.cc @@ -115,13 +115,13 @@ std::string BuildProtocolRequest(const std::string& browser_version, return request; } -net::URLFetcher* SendProtocolRequest( +scoped_ptr<net::URLFetcher> SendProtocolRequest( const GURL& url, const std::string& protocol_request, net::URLFetcherDelegate* url_fetcher_delegate, net::URLRequestContextGetter* url_request_context_getter) { - net::URLFetcher* url_fetcher(net::URLFetcher::Create( - 0, url, net::URLFetcher::POST, url_fetcher_delegate)); + scoped_ptr<net::URLFetcher> url_fetcher = net::URLFetcher::Create( + 0, url, net::URLFetcher::POST, url_fetcher_delegate); url_fetcher->SetUploadData("application/xml", protocol_request); url_fetcher->SetRequestContext(url_request_context_getter); diff --git a/components/update_client/utils.h b/components/update_client/utils.h index 297eb97..b109764 100644 --- a/components/update_client/utils.h +++ b/components/update_client/utils.h @@ -6,6 +6,7 @@ #define COMPONENTS_UPDATE_CLIENT_UTILS_H_ #include <string> +#include <base/memory/scoped_ptr.h> class GURL; @@ -55,7 +56,7 @@ std::string BuildProtocolRequest(const std::string& browser_version, // Sends a protocol request to the the service endpoint specified by |url|. // The body of the request is provided by |protocol_request| and it is // expected to contain XML data. The caller owns the returned object. -net::URLFetcher* SendProtocolRequest( +scoped_ptr<net::URLFetcher> SendProtocolRequest( const GURL& url, const std::string& protocol_request, net::URLFetcherDelegate* url_fetcher_delegate, |