Skip to content

Commit

Permalink
Rename TaskRunner::RunsTasksOnCurrentThread() in //net
Browse files Browse the repository at this point in the history
renamed TaskRunner::RunsTasksOnCurrentThread() to
TaskRunner::RunsTasksInCurrentSequence() in //net

BUG=665062
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.android:android_cronet_tester

Review-Url: https://codereview.chromium.org/2894863002
Cr-Commit-Position: refs/heads/master@{#476185}
  • Loading branch information
peary2 authored and Commit Bot committed Jun 1, 2017
1 parent 5cb31a1 commit aeac778
Show file tree
Hide file tree
Showing 26 changed files with 289 additions and 285 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ void UINetworkQualityEstimatorService::Shutdown() {
(void)deleted;
}
if (prefs_manager_) {
prefs_manager_->ShutdownOnPrefThread();
prefs_manager_->ShutdownOnPrefSequence();
bool deleted = content::BrowserThread::DeleteSoon(
content::BrowserThread::IO, FROM_HERE, prefs_manager_.release());
DCHECK(deleted);
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/profiles/profile_impl_io_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ ProfileImplIOData::Handle::~Handle() {
}

if (io_data_->http_server_properties_manager_)
io_data_->http_server_properties_manager_->ShutdownOnPrefThread();
io_data_->http_server_properties_manager_->ShutdownOnPrefSequence();

// io_data_->data_reduction_proxy_io_data() might be NULL if Init() was
// never called.
Expand Down Expand Up @@ -472,7 +472,7 @@ void ProfileImplIOData::InitializeInternal(
ApplyProfileParamsToContext(main_context);

if (lazy_params_->http_server_properties_manager) {
lazy_params_->http_server_properties_manager->InitializeOnNetworkThread();
lazy_params_->http_server_properties_manager->InitializeOnNetworkSequence();
main_context_storage->set_http_server_properties(
std::move(lazy_params_->http_server_properties_manager));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,9 @@ CronetURLRequestContextAdapter::~CronetURLRequestContextAdapter() {
DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread());

if (http_server_properties_manager_)
http_server_properties_manager_->ShutdownOnPrefThread();
http_server_properties_manager_->ShutdownOnPrefSequence();
if (network_qualities_prefs_manager_)
network_qualities_prefs_manager_->ShutdownOnPrefThread();
network_qualities_prefs_manager_->ShutdownOnPrefSequence();
if (pref_service_)
pref_service_->CommitPendingWrite();
if (network_quality_estimator_) {
Expand Down Expand Up @@ -660,7 +660,7 @@ void CronetURLRequestContextAdapter::InitializeOnNetworkThread(
http_server_properties_manager(new net::HttpServerPropertiesManager(
new PrefServiceAdapter(pref_service_.get()),
base::ThreadTaskRunnerHandle::Get(), GetNetworkTaskRunner()));
http_server_properties_manager->InitializeOnNetworkThread();
http_server_properties_manager->InitializeOnNetworkSequence();
http_server_properties_manager_ = http_server_properties_manager.get();
context_builder.SetHttpServerProperties(
std::move(http_server_properties_manager));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
ChromeBrowserStateImplIOData::Handle::~Handle() {
DCHECK_CURRENTLY_ON(web::WebThread::UI);
if (io_data_->http_server_properties_manager_)
io_data_->http_server_properties_manager_->ShutdownOnPrefThread();
io_data_->http_server_properties_manager_->ShutdownOnPrefSequence();

io_data_->ShutdownOnUIThread(GetAllContextGetters());
}
Expand Down Expand Up @@ -215,7 +215,7 @@
ApplyProfileParamsToContext(main_context);

if (http_server_properties_manager_)
http_server_properties_manager_->InitializeOnNetworkThread();
http_server_properties_manager_->InitializeOnNetworkSequence();

main_context->set_transport_security_state(transport_security_state());

Expand Down
16 changes: 8 additions & 8 deletions net/base/directory_lister.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void DirectoryLister::Start() {
}

void DirectoryLister::Cancel() {
core_->CancelOnOriginThread();
core_->CancelOnOriginSequence();
}

DirectoryLister::Core::Core(const base::FilePath& dir,
Expand All @@ -103,8 +103,8 @@ DirectoryLister::Core::Core(const base::FilePath& dir,

DirectoryLister::Core::~Core() {}

void DirectoryLister::Core::CancelOnOriginThread() {
DCHECK(origin_task_runner_->RunsTasksOnCurrentThread());
void DirectoryLister::Core::CancelOnOriginSequence() {
DCHECK(origin_task_runner_->RunsTasksInCurrentSequence());

base::subtle::NoBarrier_Store(&cancelled_, 1);
// Core must not call into |lister_| after cancellation, as the |lister_| may
Expand All @@ -118,7 +118,7 @@ void DirectoryLister::Core::Start() {

if (!base::DirectoryExists(dir_)) {
origin_task_runner_->PostTask(
FROM_HERE, base::Bind(&Core::DoneOnOriginThread, this,
FROM_HERE, base::Bind(&Core::DoneOnOriginSequence, this,
base::Passed(std::move(directory_list)),
ERR_FILE_NOT_FOUND));
return;
Expand All @@ -137,7 +137,7 @@ void DirectoryLister::Core::Start() {
base::FilePath path;
while (!(path = file_enum.Next()).empty()) {
// Abort on cancellation. This is purely for performance reasons.
// Correctness guarantees are made by checks in DoneOnOriginThread.
// Correctness guarantees are made by checks in DoneOnOriginSequence.
if (IsCancelled())
return;

Expand Down Expand Up @@ -166,18 +166,18 @@ void DirectoryLister::Core::Start() {
SortData(directory_list.get(), type_);

origin_task_runner_->PostTask(
FROM_HERE, base::Bind(&Core::DoneOnOriginThread, this,
FROM_HERE, base::Bind(&Core::DoneOnOriginSequence, this,
base::Passed(std::move(directory_list)), OK));
}

bool DirectoryLister::Core::IsCancelled() const {
return !!base::subtle::NoBarrier_Load(&cancelled_);
}

void DirectoryLister::Core::DoneOnOriginThread(
void DirectoryLister::Core::DoneOnOriginSequence(
std::unique_ptr<DirectoryList> directory_list,
int error) const {
DCHECK(origin_task_runner_->RunsTasksOnCurrentThread());
DCHECK(origin_task_runner_->RunsTasksInCurrentSequence());

// Need to check if the operation was before first callback.
if (IsCancelled())
Expand Down
10 changes: 5 additions & 5 deletions net/base/directory_lister.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ class NET_EXPORT DirectoryLister {
// refcounted, it's destroyed when the final reference is released, which may
// happen on either thread.
//
// It's kept alive during the calls to Start() and DoneOnOriginThread() by the
// reference owned by the callback itself.
// It's kept alive during the calls to Start() and DoneOnOriginSequence() by
// the reference owned by the callback itself.
class Core : public base::RefCountedThreadSafe<Core> {
public:
Core(const base::FilePath& dir, ListingType type, DirectoryLister* lister);
Expand All @@ -94,7 +94,7 @@ class NET_EXPORT DirectoryLister {
void Start();

// Must be called on the origin thread.
void CancelOnOriginThread();
void CancelOnOriginSequence();

private:
friend class base::RefCountedThreadSafe<Core>;
Expand All @@ -106,8 +106,8 @@ class NET_EXPORT DirectoryLister {
bool IsCancelled() const;

// Called on origin thread.
void DoneOnOriginThread(std::unique_ptr<DirectoryList> directory_list,
int error) const;
void DoneOnOriginSequence(std::unique_ptr<DirectoryList> directory_list,
int error) const;

const base::FilePath dir_;
const ListingType type_;
Expand Down
8 changes: 4 additions & 4 deletions net/cert/cert_database_mac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ class CertDatabase::Notifier {
base::Unretained(this)));
}

// Should be called from the |task_runner_|'s thread. Use Shutdown()
// to shutdown on arbitrary threads.
// Should be called from the |task_runner_|'s sequence. Use Shutdown()
// to shutdown on arbitrary sequence.
~Notifier() {
DCHECK(called_shutdown_);
// Only unregister from the same thread where registration was performed.
if (registered_ && task_runner_->RunsTasksOnCurrentThread())
// Only unregister from the same sequence where registration was performed.
if (registered_ && task_runner_->RunsTasksInCurrentSequence())
SecKeychainRemoveCallback(&Notifier::KeychainCallback);
}

Expand Down
24 changes: 12 additions & 12 deletions net/cert_net/cert_net_fetcher_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class RequestCore : public base::RefCountedThreadSafe<RequestCore> {
task_runner_(std::move(task_runner)) {}

void AttachedToJob(Job* job) {
DCHECK(task_runner_->RunsTasksOnCurrentThread());
DCHECK(task_runner_->RunsTasksInCurrentSequence());
DCHECK(!job_);
// Requests should not be attached to jobs after they have been signalled
// with a cancellation error (which happens via either Cancel() or
Expand All @@ -217,7 +217,7 @@ class RequestCore : public base::RefCountedThreadSafe<RequestCore> {
void OnJobCompleted(Job* job,
Error error,
const std::vector<uint8_t>& response_body) {
DCHECK(task_runner_->RunsTasksOnCurrentThread());
DCHECK(task_runner_->RunsTasksInCurrentSequence());

DCHECK_EQ(job_, job);
job_ = nullptr;
Expand All @@ -237,7 +237,7 @@ class RequestCore : public base::RefCountedThreadSafe<RequestCore> {

// Should only be called once.
void WaitForResult(Error* error, std::vector<uint8_t>* bytes) {
DCHECK(!task_runner_->RunsTasksOnCurrentThread());
DCHECK(!task_runner_->RunsTasksInCurrentSequence());

completion_event_.Wait();
*bytes = std::move(bytes_);
Expand Down Expand Up @@ -384,7 +384,7 @@ class Job : public URLRequest::Delegate {
};

void RequestCore::CancelJob() {
if (!task_runner_->RunsTasksOnCurrentThread()) {
if (!task_runner_->RunsTasksInCurrentSequence()) {
task_runner_->PostTask(FROM_HERE,
base::Bind(&RequestCore::CancelJob, this));
return;
Expand Down Expand Up @@ -711,7 +711,7 @@ class CertNetFetcherImpl : public CertNetFetcher {
: task_runner_(base::ThreadTaskRunnerHandle::Get()), context_(context) {}

void Shutdown() override {
DCHECK(task_runner_->RunsTasksOnCurrentThread());
DCHECK(task_runner_->RunsTasksInCurrentSequence());
if (impl_) {
impl_->Shutdown();
impl_.reset();
Expand Down Expand Up @@ -769,9 +769,9 @@ class CertNetFetcherImpl : public CertNetFetcher {
DCHECK(!context_);
}

void DoFetchOnNetworkThread(std::unique_ptr<RequestParams> request_params,
scoped_refptr<RequestCore> request) {
DCHECK(task_runner_->RunsTasksOnCurrentThread());
void DoFetchOnNetworkSequence(std::unique_ptr<RequestParams> request_params,
scoped_refptr<RequestCore> request) {
DCHECK(task_runner_->RunsTasksInCurrentSequence());

if (!context_) {
// The fetcher might have been shutdown between when this task was posted
Expand All @@ -792,13 +792,13 @@ class CertNetFetcherImpl : public CertNetFetcher {
std::unique_ptr<RequestParams> request_params) {
scoped_refptr<RequestCore> request_core = new RequestCore(task_runner_);

// If the fetcher has already been shutdown, DoFetchOnNetworkThread will
// If the fetcher has already been shutdown, DoFetchOnNetworkSequence will
// signal the request with an error. However, if the fetcher shuts down
// before DoFetchOnNetworkThread runs and PostTask still returns true, then
// the request will hang (that is, WaitForResult will not return).
// before DoFetchOnNetworkSequence runs and PostTask still returns true,
// then the request will hang (that is, WaitForResult will not return).
if (!task_runner_->PostTask(
FROM_HERE,
base::Bind(&CertNetFetcherImpl::DoFetchOnNetworkThread, this,
base::Bind(&CertNetFetcherImpl::DoFetchOnNetworkSequence, this,
base::Passed(&request_params), request_core))) {
request_core->SignalImmediateError();
}
Expand Down
4 changes: 2 additions & 2 deletions net/disk_cache/blockfile/backend_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ BackendImpl::~BackendImpl() {
background_queue_.DropPendingIO();
}

if (background_queue_.BackgroundIsCurrentThread()) {
// Unit tests may use the same thread for everything.
if (background_queue_.BackgroundIsCurrentSequence()) {
// Unit tests may use the same sequence for everything.
CleanupCache();
} else {
background_queue_.background_thread()->PostTask(
Expand Down
6 changes: 3 additions & 3 deletions net/disk_cache/blockfile/in_flight_backend_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ class InFlightBackendIO : public InFlightIO {
return background_thread_;
}

// Returns true if the current thread is the background thread.
bool BackgroundIsCurrentThread() {
return background_thread_->RunsTasksOnCurrentThread();
// Returns true if the current sequence is the background thread.
bool BackgroundIsCurrentSequence() {
return background_thread_->RunsTasksInCurrentSequence();
}

base::WeakPtr<InFlightBackendIO> GetWeakPtr();
Expand Down
6 changes: 3 additions & 3 deletions net/disk_cache/blockfile/in_flight_io.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ void InFlightIO::DropPendingIO() {
}
}

// Runs on a background thread.
// Runs in a background sequence.
void InFlightIO::OnIOComplete(BackgroundIO* operation) {
#if DCHECK_IS_ON()
if (callback_task_runner_->RunsTasksOnCurrentThread()) {
if (callback_task_runner_->RunsTasksInCurrentSequence()) {
DCHECK(single_thread_ || !running_);
single_thread_ = true;
}
Expand Down Expand Up @@ -109,7 +109,7 @@ void InFlightIO::InvokeCallback(BackgroundIO* operation, bool cancel_task) {

// Runs on the primary thread.
void InFlightIO::OnOperationPosted(BackgroundIO* operation) {
DCHECK(callback_task_runner_->RunsTasksOnCurrentThread());
DCHECK(callback_task_runner_->RunsTasksInCurrentSequence());
io_list_.insert(make_scoped_refptr(operation));
}

Expand Down
14 changes: 7 additions & 7 deletions net/extras/sqlite/sqlite_channel_id_store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ void SQLiteChannelIDStore::Backend::Load(
void SQLiteChannelIDStore::Backend::LoadInBackground(
std::vector<std::unique_ptr<DefaultChannelIDStore::ChannelID>>*
channel_ids) {
DCHECK(background_task_runner_->RunsTasksOnCurrentThread());
DCHECK(background_task_runner_->RunsTasksInCurrentSequence());

// This method should be called only once per instance.
DCHECK(!db_.get());
Expand Down Expand Up @@ -428,7 +428,7 @@ bool SQLiteChannelIDStore::Backend::EnsureDatabaseVersion() {
void SQLiteChannelIDStore::Backend::DatabaseErrorCallback(
int error,
sql::Statement* stmt) {
DCHECK(background_task_runner_->RunsTasksOnCurrentThread());
DCHECK(background_task_runner_->RunsTasksInCurrentSequence());

if (!sql::IsErrorCatastrophic(error))
return;
Expand All @@ -448,7 +448,7 @@ void SQLiteChannelIDStore::Backend::DatabaseErrorCallback(
}

void SQLiteChannelIDStore::Backend::KillDatabase() {
DCHECK(background_task_runner_->RunsTasksOnCurrentThread());
DCHECK(background_task_runner_->RunsTasksInCurrentSequence());

if (db_) {
// This Backend will now be in-memory only. In a future run the database
Expand Down Expand Up @@ -521,7 +521,7 @@ void SQLiteChannelIDStore::Backend::BatchOperation(

void SQLiteChannelIDStore::Backend::PrunePendingOperationsForDeletes(
const std::list<std::string>& server_identifiers) {
DCHECK(background_task_runner_->RunsTasksOnCurrentThread());
DCHECK(background_task_runner_->RunsTasksInCurrentSequence());
base::AutoLock locked(lock_);

for (PendingOperationsList::iterator it = pending_.begin();
Expand All @@ -547,7 +547,7 @@ void SQLiteChannelIDStore::Backend::Flush() {
}

void SQLiteChannelIDStore::Backend::Commit() {
DCHECK(background_task_runner_->RunsTasksOnCurrentThread());
DCHECK(background_task_runner_->RunsTasksInCurrentSequence());

PendingOperationsList ops;
{
Expand Down Expand Up @@ -620,15 +620,15 @@ void SQLiteChannelIDStore::Backend::Close() {
}

void SQLiteChannelIDStore::Backend::InternalBackgroundClose() {
DCHECK(background_task_runner_->RunsTasksOnCurrentThread());
DCHECK(background_task_runner_->RunsTasksInCurrentSequence());
// Commit any pending operations
Commit();
db_.reset();
}

void SQLiteChannelIDStore::Backend::BackgroundDeleteAllInList(
const std::list<std::string>& server_identifiers) {
DCHECK(background_task_runner_->RunsTasksOnCurrentThread());
DCHECK(background_task_runner_->RunsTasksInCurrentSequence());

if (!db_.get())
return;
Expand Down
Loading

0 comments on commit aeac778

Please sign in to comment.