Skip to content

Commit

Permalink
Change scoped_ptr to std::unique_ptr in //net/url_request.
Browse files Browse the repository at this point in the history
R=eroman
TBR=brettw
BUG=554298

Review URL: https://codereview.chromium.org/1889793008

Cr-Commit-Position: refs/heads/master@{#387762}
  • Loading branch information
danakj authored and Commit bot committed Apr 16, 2016
1 parent fff45c3 commit 8522a25
Show file tree
Hide file tree
Showing 72 changed files with 820 additions and 757 deletions.
1 change: 1 addition & 0 deletions chrome/browser/profile_resetter/brandcode_config_fetcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/timer/timer.h"
#include "net/url_request/url_fetcher_delegate.h"

Expand Down
1 change: 1 addition & 0 deletions components/ntp_snippets/ntp_snippets_fetcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "base/callback.h"
#include "base/callback_list.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/sequenced_task_runner.h"
#include "net/url_request/url_fetcher_delegate.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/string_split.h"
#include "components/policy/core/common/cloud/cloud_policy_constants.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "components/proximity_auth/cryptauth/cryptauth_access_token_fetcher.h"
#include "google_apis/gaia/oauth2_token_service.h"

Expand Down
1 change: 1 addition & 0 deletions components/quirks/quirks_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "base/files/file_path.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/threading/thread_checker.h"
#include "base/timer/timer.h"
#include "net/base/backoff_entry.h"
Expand Down
1 change: 1 addition & 0 deletions components/signin/core/browser/account_fetcher_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "base/containers/scoped_ptr_hash_map.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/threading/non_thread_safe.h"
#include "base/timer/timer.h"
#include "components/keyed_service/core/keyed_service.h"
Expand Down
1 change: 1 addition & 0 deletions components/signin/core/browser/account_info_fetcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_INFO_FETCHER_H_

#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "google_apis/gaia/gaia_auth_consumer.h"
#include "google_apis/gaia/gaia_oauth_client.h"
#include "google_apis/gaia/oauth2_token_service.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define COMPONENTS_SIGNIN_CORE_BROWSER_CHILD_ACCOUNT_INFO_FETCHER_IMPL_H_

#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/threading/thread_checker.h"
#include "base/timer/timer.h"
#include "components/invalidation/public/invalidation_handler.h"
Expand Down
1 change: 1 addition & 0 deletions components/sync_driver/generic_change_processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/threading/non_thread_safe.h"
#include "components/sync_driver/change_processor.h"
Expand Down
1 change: 1 addition & 0 deletions components/sync_driver/glue/sync_backend_registrar.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/synchronization/lock.h"
#include "base/threading/thread.h"
#include "sync/internal_api/public/base/model_type.h"
Expand Down
4 changes: 2 additions & 2 deletions net/url_request/certificate_report_sender.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ CertificateReportSender::~CertificateReportSender() {

void CertificateReportSender::Send(const GURL& report_uri,
const std::string& report) {
scoped_ptr<URLRequest> url_request =
std::unique_ptr<URLRequest> url_request =
request_context_->CreateRequest(report_uri, DEFAULT_PRIORITY, this);

int load_flags =
Expand All @@ -50,7 +50,7 @@ void CertificateReportSender::Send(const GURL& report_uri,

url_request->set_method("POST");

scoped_ptr<UploadElementReader> reader(
std::unique_ptr<UploadElementReader> reader(
UploadOwnedBytesElementReader::CreateWithString(report));
url_request->set_upload(
ElementsUploadDataStream::CreateWithReader(std::move(reader), 0));
Expand Down
2 changes: 1 addition & 1 deletion net/url_request/certificate_report_sender.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
#ifndef NET_URL_REQUEST_CERTIFICATE_REPORT_SENDER_H_
#define NET_URL_REQUEST_CERTIFICATE_REPORT_SENDER_H_

#include <memory>
#include <set>
#include <string>

#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "net/http/transport_security_state.h"
#include "net/url_request/url_request.h"

Expand Down
2 changes: 1 addition & 1 deletion net/url_request/certificate_report_sender_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ TEST_F(CertificateReportSenderTest, PendingRequestGetsDeleted) {

EXPECT_EQ(0u, network_delegate_.num_requests());

scoped_ptr<CertificateReportSender> reporter(new CertificateReportSender(
std::unique_ptr<CertificateReportSender> reporter(new CertificateReportSender(
context(), CertificateReportSender::DO_NOT_SEND_COOKIES));
reporter->Send(url, kDummyReport);
reporter.reset();
Expand Down
5 changes: 3 additions & 2 deletions net/url_request/ftp_protocol_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
#ifndef NET_URL_REQUEST_FTP_PROTOCOL_HANDLER_H_
#define NET_URL_REQUEST_FTP_PROTOCOL_HANDLER_H_

#include <memory>

#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "net/url_request/url_request_job_factory.h"

namespace net {
Expand All @@ -31,7 +32,7 @@ class NET_EXPORT FtpProtocolHandler :
friend class FtpTestURLRequestContext;

FtpTransactionFactory* ftp_transaction_factory_;
scoped_ptr<FtpAuthCache> ftp_auth_cache_;
std::unique_ptr<FtpAuthCache> ftp_auth_cache_;

DISALLOW_COPY_AND_ASSIGN(FtpProtocolHandler);
};
Expand Down
6 changes: 3 additions & 3 deletions net/url_request/sdch_dictionary_fetcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
#ifndef NET_URL_REQUEST_SDCH_DICTIONARY_FETCHER_H_
#define NET_URL_REQUEST_SDCH_DICTIONARY_FETCHER_H_

#include <memory>
#include <string>

#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/threading/non_thread_safe.h"
#include "net/base/sdch_manager.h"
#include "net/url_request/url_fetcher_delegate.h"
Expand Down Expand Up @@ -99,11 +99,11 @@ class NET_EXPORT SdchDictionaryFetcher : public URLRequest::Delegate,
bool in_loop_;

// A queue of URLs that are being used to download dictionaries.
scoped_ptr<UniqueFetchQueue> fetch_queue_;
std::unique_ptr<UniqueFetchQueue> fetch_queue_;

// The request, buffer, and consumer supplied data used for getting
// the current dictionary. All are null when a fetch is not in progress.
scoped_ptr<URLRequest> current_request_;
std::unique_ptr<URLRequest> current_request_;
scoped_refptr<IOBuffer> buffer_;
OnDictionaryFetchedCallback current_callback_;

Expand Down
8 changes: 4 additions & 4 deletions net/url_request/sdch_dictionary_fetcher_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class SpecifiedResponseJobInterceptor : public URLRequestInterceptor {
// SpecifiedResponseJobInterceptor (i.e. until Unregister() is called).
static void RegisterWithFilter(HttpResponseInfo* http_response_info,
const LifecycleCallback& lifecycle_callback) {
scoped_ptr<SpecifiedResponseJobInterceptor> interceptor(
std::unique_ptr<SpecifiedResponseJobInterceptor> interceptor(
new SpecifiedResponseJobInterceptor(http_response_info,
lifecycle_callback));

Expand Down Expand Up @@ -264,9 +264,9 @@ class SdchDictionaryFetcherTest : public ::testing::Test {
// currently used for ensuring that certain loads are marked only-from-cache.
int last_load_flags_seen_;

scoped_ptr<base::RunLoop> run_loop_;
scoped_ptr<TestURLRequestContext> context_;
scoped_ptr<SdchDictionaryFetcher> fetcher_;
std::unique_ptr<base::RunLoop> run_loop_;
std::unique_ptr<TestURLRequestContext> context_;
std::unique_ptr<SdchDictionaryFetcher> fetcher_;
std::vector<DictionaryAdditions> dictionary_additions_;

// The request_time and response_time fields are filled in by the constructor
Expand Down
29 changes: 15 additions & 14 deletions net/url_request/test_url_fetcher_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void TestURLFetcher::SaveResponseToTemporaryFile(
}

void TestURLFetcher::SaveResponseWithWriter(
scoped_ptr<URLFetcherResponseWriter> response_writer) {
std::unique_ptr<URLFetcherResponseWriter> response_writer) {
// In class URLFetcherCore this method is called by all three:
// GetResponseAsString() / SaveResponseToFileAtPath() /
// SaveResponseToTemporaryFile(). But here (in TestURLFetcher), this method
Expand Down Expand Up @@ -331,7 +331,7 @@ TestURLFetcherFactory::TestURLFetcherFactory()

TestURLFetcherFactory::~TestURLFetcherFactory() {}

scoped_ptr<URLFetcher> TestURLFetcherFactory::CreateURLFetcher(
std::unique_ptr<URLFetcher> TestURLFetcherFactory::CreateURLFetcher(
int id,
const GURL& url,
URLFetcher::RequestType request_type,
Expand All @@ -341,7 +341,7 @@ scoped_ptr<URLFetcher> TestURLFetcherFactory::CreateURLFetcher(
fetcher->set_owner(this);
fetcher->SetDelegateForTests(delegate_for_tests_);
fetchers_[id] = fetcher;
return scoped_ptr<URLFetcher>(fetcher);
return std::unique_ptr<URLFetcher>(fetcher);
}

TestURLFetcher* TestURLFetcherFactory::GetFetcherByID(int id) const {
Expand Down Expand Up @@ -427,19 +427,20 @@ FakeURLFetcherFactory::FakeURLFetcherFactory(
default_factory_(default_factory) {
}

scoped_ptr<FakeURLFetcher> FakeURLFetcherFactory::DefaultFakeURLFetcherCreator(
const GURL& url,
URLFetcherDelegate* delegate,
const std::string& response_data,
HttpStatusCode response_code,
URLRequestStatus::Status status) {
return scoped_ptr<FakeURLFetcher>(
std::unique_ptr<FakeURLFetcher>
FakeURLFetcherFactory::DefaultFakeURLFetcherCreator(
const GURL& url,
URLFetcherDelegate* delegate,
const std::string& response_data,
HttpStatusCode response_code,
URLRequestStatus::Status status) {
return std::unique_ptr<FakeURLFetcher>(
new FakeURLFetcher(url, delegate, response_data, response_code, status));
}

FakeURLFetcherFactory::~FakeURLFetcherFactory() {}

scoped_ptr<URLFetcher> FakeURLFetcherFactory::CreateURLFetcher(
std::unique_ptr<URLFetcher> FakeURLFetcherFactory::CreateURLFetcher(
int id,
const GURL& url,
URLFetcher::RequestType request_type,
Expand All @@ -455,7 +456,7 @@ scoped_ptr<URLFetcher> FakeURLFetcherFactory::CreateURLFetcher(
}
}

scoped_ptr<URLFetcher> fake_fetcher =
std::unique_ptr<URLFetcher> fake_fetcher =
creator_.Run(url, d, it->second.response_data, it->second.response_code,
it->second.status);
return fake_fetcher;
Expand All @@ -482,12 +483,12 @@ URLFetcherImplFactory::URLFetcherImplFactory() {}

URLFetcherImplFactory::~URLFetcherImplFactory() {}

scoped_ptr<URLFetcher> URLFetcherImplFactory::CreateURLFetcher(
std::unique_ptr<URLFetcher> URLFetcherImplFactory::CreateURLFetcher(
int id,
const GURL& url,
URLFetcher::RequestType request_type,
URLFetcherDelegate* d) {
return scoped_ptr<URLFetcher>(new URLFetcherImpl(url, request_type, d));
return std::unique_ptr<URLFetcher>(new URLFetcherImpl(url, request_type, d));
}

} // namespace net
40 changes: 22 additions & 18 deletions net/url_request/test_url_fetcher_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

#include <list>
#include <map>
#include <memory>
#include <string>
#include <utility>

#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/files/file_path.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/threading/non_thread_safe.h"
#include "net/http/http_request_headers.h"
Expand Down Expand Up @@ -130,7 +130,7 @@ class TestURLFetcher : public URLFetcher {
void SaveResponseToTemporaryFile(
scoped_refptr<base::SequencedTaskRunner> file_task_runner) override;
void SaveResponseWithWriter(
scoped_ptr<URLFetcherResponseWriter> response_writer) override;
std::unique_ptr<URLFetcherResponseWriter> response_writer) override;
HttpResponseHeaders* GetResponseHeaders() const override;
HostPortPair GetSocketAddress() const override;
bool WasFetchedViaProxy() const override;
Expand Down Expand Up @@ -237,7 +237,7 @@ class TestURLFetcher : public URLFetcher {
HttpRequestHeaders fake_extra_request_headers_;
int fake_max_retries_;
base::TimeDelta fake_backoff_delay_;
scoped_ptr<URLFetcherResponseWriter> response_writer_;
std::unique_ptr<URLFetcherResponseWriter> response_writer_;

DISALLOW_COPY_AND_ASSIGN(TestURLFetcher);
};
Expand All @@ -254,10 +254,11 @@ class TestURLFetcherFactory : public URLFetcherFactory,
TestURLFetcherFactory();
~TestURLFetcherFactory() override;

scoped_ptr<URLFetcher> CreateURLFetcher(int id,
const GURL& url,
URLFetcher::RequestType request_type,
URLFetcherDelegate* d) override;
std::unique_ptr<URLFetcher> CreateURLFetcher(
int id,
const GURL& url,
URLFetcher::RequestType request_type,
URLFetcherDelegate* d) override;
TestURLFetcher* GetFetcherByID(int id) const;
void RemoveFetcherFromMap(int id);
void SetDelegateForTests(TestURLFetcherDelegateForTests* delegate_for_tests);
Expand Down Expand Up @@ -384,12 +385,13 @@ class FakeURLFetcherFactory : public URLFetcherFactory,
// These arguments should by default be used in instantiating FakeURLFetcher
// like so:
// new FakeURLFetcher(url, delegate, response_data, response_code, status)
typedef base::Callback<scoped_ptr<FakeURLFetcher>(
typedef base::Callback<std::unique_ptr<FakeURLFetcher>(
const GURL&,
URLFetcherDelegate*,
const std::string&,
HttpStatusCode,
URLRequestStatus::Status)> FakeURLFetcherCreator;
URLRequestStatus::Status)>
FakeURLFetcherCreator;

// |default_factory|, which can be NULL, is a URLFetcherFactory that
// will be used to construct a URLFetcher in case the URL being created
Expand All @@ -414,10 +416,11 @@ class FakeURLFetcherFactory : public URLFetcherFactory,
// NULL.
// Otherwise, it will return a URLFetcher object which will respond with the
// pre-baked response that the client has set by calling SetFakeResponse().
scoped_ptr<URLFetcher> CreateURLFetcher(int id,
const GURL& url,
URLFetcher::RequestType request_type,
URLFetcherDelegate* d) override;
std::unique_ptr<URLFetcher> CreateURLFetcher(
int id,
const GURL& url,
URLFetcher::RequestType request_type,
URLFetcherDelegate* d) override;

// Sets the fake response for a given URL. The |response_data| may be empty.
// The |response_code| may be any HttpStatusCode. For instance, HTTP_OK will
Expand Down Expand Up @@ -447,7 +450,7 @@ class FakeURLFetcherFactory : public URLFetcherFactory,
FakeResponseMap fake_responses_;
URLFetcherFactory* const default_factory_;

static scoped_ptr<FakeURLFetcher> DefaultFakeURLFetcherCreator(
static std::unique_ptr<FakeURLFetcher> DefaultFakeURLFetcherCreator(
const GURL& url,
URLFetcherDelegate* delegate,
const std::string& response_data,
Expand All @@ -466,10 +469,11 @@ class URLFetcherImplFactory : public URLFetcherFactory {
~URLFetcherImplFactory() override;

// This method will create a real URLFetcher.
scoped_ptr<URLFetcher> CreateURLFetcher(int id,
const GURL& url,
URLFetcher::RequestType request_type,
URLFetcherDelegate* d) override;
std::unique_ptr<URLFetcher> CreateURLFetcher(
int id,
const GURL& url,
URLFetcher::RequestType request_type,
URLFetcherDelegate* d) override;
};

} // namespace net
Expand Down
2 changes: 1 addition & 1 deletion net/url_request/test_url_request_interceptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class TestURLRequestInterceptor::Delegate : public URLRequestInterceptor {

void Register() {
URLRequestFilter::GetInstance()->AddHostnameInterceptor(
scheme_, hostname_, scoped_ptr<URLRequestInterceptor>(this));
scheme_, hostname_, std::unique_ptr<URLRequestInterceptor>(this));
}

static void Unregister(const std::string& scheme,
Expand Down
Loading

0 comments on commit 8522a25

Please sign in to comment.