Skip to content

Commit

Permalink
Use in-class initializers for base::WeakPtrFactory in net/.
Browse files Browse the repository at this point in the history
Generated by: https://chromium-review.googlesource.com/c/chromium/src/+/1689216

Bug: 981415
Change-Id: I8b3e41ce53df33f8fc201e175a65cae3a9e07669
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1691082
Reviewed-by: Eric Roman <eroman@chromium.org>
Commit-Queue: Jeremy Roman <jbroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#675307}
  • Loading branch information
jeremyroman authored and Commit Bot committed Jul 8, 2019
1 parent 2434799 commit d54000b
Show file tree
Hide file tree
Showing 215 changed files with 290 additions and 429 deletions.
3 changes: 1 addition & 2 deletions net/base/chunked_upload_data_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ ChunkedUploadDataStream::ChunkedUploadDataStream(int64_t identifier)
read_index_(0),
read_offset_(0),
all_data_appended_(false),
read_buffer_len_(0),
weak_factory_(this) {}
read_buffer_len_(0) {}

ChunkedUploadDataStream::~ChunkedUploadDataStream() = default;

Expand Down
2 changes: 1 addition & 1 deletion net/base/chunked_upload_data_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class NET_EXPORT ChunkedUploadDataStream : public UploadDataStream {
scoped_refptr<IOBuffer> read_buffer_;
int read_buffer_len_;

base::WeakPtrFactory<ChunkedUploadDataStream> weak_factory_;
base::WeakPtrFactory<ChunkedUploadDataStream> weak_factory_{this};

DISALLOW_COPY_AND_ASSIGN(ChunkedUploadDataStream);
};
Expand Down
3 changes: 1 addition & 2 deletions net/base/elements_upload_data_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ ElementsUploadDataStream::ElementsUploadDataStream(
: UploadDataStream(false, identifier),
element_readers_(std::move(element_readers)),
element_index_(0),
read_error_(OK),
weak_ptr_factory_(this) {}
read_error_(OK) {}

ElementsUploadDataStream::~ElementsUploadDataStream() = default;

Expand Down
2 changes: 1 addition & 1 deletion net/base/elements_upload_data_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class NET_EXPORT ElementsUploadDataStream : public UploadDataStream {
// Set to actual error if read fails, otherwise set to net::OK.
int read_error_;

base::WeakPtrFactory<ElementsUploadDataStream> weak_ptr_factory_;
base::WeakPtrFactory<ElementsUploadDataStream> weak_ptr_factory_{this};

DISALLOW_COPY_AND_ASSIGN(ElementsUploadDataStream);
};
Expand Down
7 changes: 2 additions & 5 deletions net/base/mock_file_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,15 @@ MockFileStream::MockFileStream(
: FileStream(task_runner),
forced_error_(OK),
async_error_(false),
throttled_(false),
weak_factory_(this) {
}
throttled_(false) {}

MockFileStream::MockFileStream(
base::File file,
const scoped_refptr<base::TaskRunner>& task_runner)
: FileStream(std::move(file), task_runner),
forced_error_(OK),
async_error_(false),
throttled_(false),
weak_factory_(this) {}
throttled_(false) {}

MockFileStream::~MockFileStream() = default;

Expand Down
2 changes: 1 addition & 1 deletion net/base/mock_file_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class MockFileStream : public FileStream {
base::OnceClosure throttled_task_;
base::FilePath path_;

base::WeakPtrFactory<MockFileStream> weak_factory_;
base::WeakPtrFactory<MockFileStream> weak_factory_{this};
};

} // namespace testing
Expand Down
6 changes: 2 additions & 4 deletions net/base/upload_file_element_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ UploadFileElementReader::UploadFileElementReader(
content_length_(0),
bytes_remaining_(0),
next_state_(State::IDLE),
init_called_while_operation_pending_(false),
weak_ptr_factory_(this) {
init_called_while_operation_pending_(false) {
DCHECK(file.IsValid());
DCHECK(task_runner_.get());
file_stream_ = std::make_unique<FileStream>(std::move(file), task_runner);
Expand All @@ -59,8 +58,7 @@ UploadFileElementReader::UploadFileElementReader(
content_length_(0),
bytes_remaining_(0),
next_state_(State::IDLE),
init_called_while_operation_pending_(false),
weak_ptr_factory_(this) {
init_called_while_operation_pending_(false) {
DCHECK(task_runner_.get());
}

Expand Down
2 changes: 1 addition & 1 deletion net/base/upload_file_element_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class NET_EXPORT UploadFileElementReader : public UploadElementReader {
// True if Init() was called while an async operation was in progress.
bool init_called_while_operation_pending_;

base::WeakPtrFactory<UploadFileElementReader> weak_ptr_factory_;
base::WeakPtrFactory<UploadFileElementReader> weak_ptr_factory_{this};

DISALLOW_COPY_AND_ASSIGN(UploadFileElementReader);
};
Expand Down
4 changes: 2 additions & 2 deletions net/cert/mock_cert_verifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct MockCertVerifier::Rule {
class MockCertVerifier::MockRequest : public CertVerifier::Request {
public:
MockRequest(CertVerifyResult* result, CompletionOnceCallback callback)
: result_(result), callback_(std::move(callback)), weak_factory_(this) {}
: result_(result), callback_(std::move(callback)) {}

void ReturnResultLater(int rv, const CertVerifyResult& result) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
Expand All @@ -59,7 +59,7 @@ class MockCertVerifier::MockRequest : public CertVerifier::Request {

CertVerifyResult* result_;
CompletionOnceCallback callback_;
base::WeakPtrFactory<MockRequest> weak_factory_;
base::WeakPtrFactory<MockRequest> weak_factory_{this};
};

MockCertVerifier::MockCertVerifier()
Expand Down
5 changes: 2 additions & 3 deletions net/cert/multi_threaded_cert_verifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,7 @@ class CertVerifierJob {
net_log_(NetLogWithSource::Make(net_log,
NetLogSourceType::CERT_VERIFIER_JOB)),
cert_verifier_(cert_verifier),
is_first_job_(false),
weak_ptr_factory_(this) {
is_first_job_(false) {
net_log_.BeginEvent(NetLogEventType::CERT_VERIFIER_JOB,
base::Bind(&NetLogX509CertificateCallback,
base::Unretained(key.certificate().get())));
Expand Down Expand Up @@ -345,7 +344,7 @@ class CertVerifierJob {
MultiThreadedCertVerifier* cert_verifier_; // Non-owned.

bool is_first_job_;
base::WeakPtrFactory<CertVerifierJob> weak_ptr_factory_;
base::WeakPtrFactory<CertVerifierJob> weak_ptr_factory_{this};
};

MultiThreadedCertVerifier::MultiThreadedCertVerifier(
Expand Down
3 changes: 1 addition & 2 deletions net/cert/nss_cert_database.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ NSSCertDatabase::NSSCertDatabase(crypto::ScopedPK11Slot public_slot,
crypto::ScopedPK11Slot private_slot)
: public_slot_(std::move(public_slot)),
private_slot_(std::move(private_slot)),
observer_list_(new base::ObserverListThreadSafe<Observer>),
weak_factory_(this) {
observer_list_(new base::ObserverListThreadSafe<Observer>) {
CHECK(public_slot_);

CertDatabase* cert_db = CertDatabase::GetInstance();
Expand Down
2 changes: 1 addition & 1 deletion net/cert/nss_cert_database.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ class NET_EXPORT NSSCertDatabase {

const scoped_refptr<base::ObserverListThreadSafe<Observer>> observer_list_;

base::WeakPtrFactory<NSSCertDatabase> weak_factory_;
base::WeakPtrFactory<NSSCertDatabase> weak_factory_{this};

DISALLOW_COPY_AND_ASSIGN(NSSCertDatabase);
};
Expand Down
3 changes: 1 addition & 2 deletions net/cookies/cookie_monster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,7 @@ CookieMonster::CookieMonster(scoped_refptr<PersistentCookieStore> store,
store_(std::move(store)),
last_access_threshold_(last_access_threshold),
last_statistic_record_time_(base::Time::Now()),
persist_session_cookies_(false),
weak_ptr_factory_(this) {
persist_session_cookies_(false) {
InitializeHistograms();
cookieable_schemes_.insert(
cookieable_schemes_.begin(), kDefaultCookieableSchemes,
Expand Down
2 changes: 1 addition & 1 deletion net/cookies/cookie_monster.h
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ class NET_EXPORT CookieMonster : public CookieStore {

base::ThreadChecker thread_checker_;

base::WeakPtrFactory<CookieMonster> weak_ptr_factory_;
base::WeakPtrFactory<CookieMonster> weak_ptr_factory_{this};

DISALLOW_COPY_AND_ASSIGN(CookieMonster);
};
Expand Down
6 changes: 2 additions & 4 deletions net/cookies/cookie_monster_change_dispatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ CookieMonsterChangeDispatcher::Subscription::Subscription(
name_key_(std::move(name_key)),
url_(std::move(url)),
callback_(std::move(callback)),
task_runner_(base::ThreadTaskRunnerHandle::Get()),
weak_ptr_factory_(this) {
task_runner_(base::ThreadTaskRunnerHandle::Get()) {
DCHECK(url_.is_valid() || url_.is_empty());
DCHECK_EQ(url_.is_empty(), domain_key_ == kGlobalDomainKey);

Expand Down Expand Up @@ -80,8 +79,7 @@ void CookieMonsterChangeDispatcher::Subscription::DoDispatchChange(
callback_.Run(cookie, change_cause);
}

CookieMonsterChangeDispatcher::CookieMonsterChangeDispatcher()
: weak_ptr_factory_(this) {}
CookieMonsterChangeDispatcher::CookieMonsterChangeDispatcher() {}

CookieMonsterChangeDispatcher::~CookieMonsterChangeDispatcher() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
Expand Down
4 changes: 2 additions & 2 deletions net/cookies/cookie_monster_change_dispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class CookieMonsterChangeDispatcher : public CookieChangeDispatcher {

// Used to cancel delayed calls to DoDispatchChange() when the subscription
// gets destroyed.
base::WeakPtrFactory<Subscription> weak_ptr_factory_;
base::WeakPtrFactory<Subscription> weak_ptr_factory_{this};

DISALLOW_COPY_AND_ASSIGN(Subscription);
};
Expand Down Expand Up @@ -149,7 +149,7 @@ class CookieMonsterChangeDispatcher : public CookieChangeDispatcher {
THREAD_CHECKER(thread_checker_);

// Vends weak pointers to subscriptions.
base::WeakPtrFactory<CookieMonsterChangeDispatcher> weak_ptr_factory_;
base::WeakPtrFactory<CookieMonsterChangeDispatcher> weak_ptr_factory_{this};

DISALLOW_COPY_AND_ASSIGN(CookieMonsterChangeDispatcher);
};
Expand Down
6 changes: 2 additions & 4 deletions net/disk_cache/blockfile/backend_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ BackendImpl::BackendImpl(
consider_evicting_at_op_end_(false),
net_log_(net_log),
done_(base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED),
ptr_factory_(this) {}
base::WaitableEvent::InitialState::NOT_SIGNALED) {}

BackendImpl::BackendImpl(
const base::FilePath& path,
Expand Down Expand Up @@ -202,8 +201,7 @@ BackendImpl::BackendImpl(
consider_evicting_at_op_end_(false),
net_log_(net_log),
done_(base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED),
ptr_factory_(this) {}
base::WaitableEvent::InitialState::NOT_SIGNALED) {}

BackendImpl::~BackendImpl() {
if (user_flags_ & kNoRandom) {
Expand Down
2 changes: 1 addition & 1 deletion net/disk_cache/blockfile/backend_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ class NET_EXPORT_PRIVATE BackendImpl : public Backend {
std::unique_ptr<base::RepeatingTimer> timer_; // Usage timer.
base::WaitableEvent done_; // Signals the end of background work.
scoped_refptr<TraceObject> trace_object_; // Initializes internal tracing.
base::WeakPtrFactory<BackendImpl> ptr_factory_;
base::WeakPtrFactory<BackendImpl> ptr_factory_{this};

DISALLOW_COPY_AND_ASSIGN(BackendImpl);
};
Expand Down
2 changes: 1 addition & 1 deletion net/disk_cache/blockfile/eviction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace disk_cache {

// The real initialization happens during Init(), init_ is the only member that
// has to be initialized here.
Eviction::Eviction() : backend_(nullptr), init_(false), ptr_factory_(this) {}
Eviction::Eviction() : backend_(nullptr), init_(false) {}

Eviction::~Eviction() = default;

Expand Down
2 changes: 1 addition & 1 deletion net/disk_cache/blockfile/eviction.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Eviction {
bool delay_trim_;
bool init_;
bool test_mode_;
base::WeakPtrFactory<Eviction> ptr_factory_;
base::WeakPtrFactory<Eviction> ptr_factory_{this};

DISALLOW_COPY_AND_ASSIGN(Eviction);
};
Expand Down
5 changes: 1 addition & 4 deletions net/disk_cache/blockfile/in_flight_backend_io.cc
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,7 @@ void BackendIO::ExecuteEntryOperation() {
InFlightBackendIO::InFlightBackendIO(
BackendImpl* backend,
const scoped_refptr<base::SingleThreadTaskRunner>& background_thread)
: backend_(backend),
background_thread_(background_thread),
ptr_factory_(this) {
}
: backend_(backend), background_thread_(background_thread) {}

InFlightBackendIO::~InFlightBackendIO() = default;

Expand Down
2 changes: 1 addition & 1 deletion net/disk_cache/blockfile/in_flight_backend_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class InFlightBackendIO : public InFlightIO {
void PostOperation(const base::Location& from_here, BackendIO* operation);
BackendImpl* backend_;
scoped_refptr<base::SingleThreadTaskRunner> background_thread_;
base::WeakPtrFactory<InFlightBackendIO> ptr_factory_;
base::WeakPtrFactory<InFlightBackendIO> ptr_factory_{this};

DISALLOW_COPY_AND_ASSIGN(InFlightBackendIO);
};
Expand Down
3 changes: 1 addition & 2 deletions net/disk_cache/memory/mem_backend_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ MemBackendImpl::MemBackendImpl(net::NetLog* net_log)
net_log_(net_log),
memory_pressure_listener_(
base::BindRepeating(&MemBackendImpl::OnMemoryPressure,
base::Unretained(this))),
weak_factory_(this) {}
base::Unretained(this))) {}

MemBackendImpl::~MemBackendImpl() {
DCHECK(CheckLRUListOrder(lru_list_));
Expand Down
2 changes: 1 addition & 1 deletion net/disk_cache/memory/mem_backend_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class NET_EXPORT_PRIVATE MemBackendImpl final : public Backend {

base::MemoryPressureListener memory_pressure_listener_;

base::WeakPtrFactory<MemBackendImpl> weak_factory_;
base::WeakPtrFactory<MemBackendImpl> weak_factory_{this};

DISALLOW_COPY_AND_ASSIGN(MemBackendImpl);
};
Expand Down
6 changes: 2 additions & 4 deletions net/disk_cache/simple/simple_backend_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -558,9 +558,7 @@ int64_t SimpleBackendImpl::CalculateSizeOfEntriesBetween(
class SimpleBackendImpl::SimpleIterator final : public Iterator {
public:
explicit SimpleIterator(base::WeakPtr<SimpleBackendImpl> backend)
: backend_(backend),
weak_factory_(this) {
}
: backend_(backend) {}

// From Backend::Iterator:
net::Error OpenNextEntry(Entry** next_entry,
Expand Down Expand Up @@ -624,7 +622,7 @@ class SimpleBackendImpl::SimpleIterator final : public Iterator {
private:
base::WeakPtr<SimpleBackendImpl> backend_;
std::unique_ptr<std::vector<uint64_t>> hashes_to_enumerate_;
base::WeakPtrFactory<SimpleIterator> weak_factory_;
base::WeakPtrFactory<SimpleIterator> weak_factory_{this};
};

std::unique_ptr<Backend::Iterator> SimpleBackendImpl::CreateIterator() {
Expand Down
5 changes: 2 additions & 3 deletions net/dns/dns_config_service_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,7 @@ ConfigParsePosixResult ReadDnsConfig(DnsConfig* dns_config) {

class DnsConfigServicePosix::Watcher {
public:
explicit Watcher(DnsConfigServicePosix* service)
: service_(service), weak_factory_(this) {}
explicit Watcher(DnsConfigServicePosix* service) : service_(service) {}
~Watcher() = default;

bool Watch() {
Expand Down Expand Up @@ -294,7 +293,7 @@ class DnsConfigServicePosix::Watcher {
base::FilePathWatcher hosts_watcher_;
#endif // !defined(OS_ANDROID) && !defined(OS_IOS)

base::WeakPtrFactory<Watcher> weak_factory_;
base::WeakPtrFactory<Watcher> weak_factory_{this};

DISALLOW_COPY_AND_ASSIGN(Watcher);
};
Expand Down
4 changes: 2 additions & 2 deletions net/dns/dns_socket_pool_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ namespace {

class DummyObject {
public:
DummyObject() : weak_factory_(this) {}
DummyObject() {}

base::WeakPtr<DummyObject> GetWeakPtr() { return weak_factory_.GetWeakPtr(); }

bool HasWeakPtrs() const { return weak_factory_.HasWeakPtrs(); }

private:
base::WeakPtrFactory<DummyObject> weak_factory_;
base::WeakPtrFactory<DummyObject> weak_factory_{this};

DISALLOW_COPY_AND_ASSIGN(DummyObject);
};
Expand Down
6 changes: 2 additions & 4 deletions net/dns/dns_transaction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,7 @@ class DnsHTTPAttempt : public DnsAttempt, public URLRequest::Delegate {
bool use_post,
URLRequestContext* url_request_context,
RequestPriority request_priority_)
: DnsAttempt(server_index),
query_(std::move(query)),
weak_factory_(this) {
: DnsAttempt(server_index), query_(std::move(query)) {
GURL url;
if (use_post) {
// Set url for a POST request
Expand Down Expand Up @@ -531,7 +529,7 @@ class DnsHTTPAttempt : public DnsAttempt, public URLRequest::Delegate {
std::unique_ptr<URLRequest> request_;
NetLogWithSource net_log_;

base::WeakPtrFactory<DnsHTTPAttempt> weak_factory_;
base::WeakPtrFactory<DnsHTTPAttempt> weak_factory_{this};

DISALLOW_COPY_AND_ASSIGN(DnsHTTPAttempt);
};
Expand Down
5 changes: 2 additions & 3 deletions net/dns/dns_transaction_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,7 @@ class URLRequestMockDohJob : public URLRequestJob, public AsyncSocket {
content_length_(0),
leftover_data_len_(0),
data_provider_(data_provider),
response_modifier_(response_modifier),
weak_factory_(this) {
response_modifier_(response_modifier) {
data_provider_->Initialize(this);
MatchQueryData(request, data_provider);
}
Expand Down Expand Up @@ -559,7 +558,7 @@ class URLRequestMockDohJob : public URLRequestJob, public AsyncSocket {
IOBuffer* pending_buf_;
int pending_buf_size_;

base::WeakPtrFactory<URLRequestMockDohJob> weak_factory_;
base::WeakPtrFactory<URLRequestMockDohJob> weak_factory_{this};

DISALLOW_COPY_AND_ASSIGN(URLRequestMockDohJob);
};
Expand Down
Loading

0 comments on commit d54000b

Please sign in to comment.