Commit 68602138 authored by gab's avatar gab Committed by Commit Bot

Deprecate NonThreadSafe in components/drive in favor of SequenceChecker.

Note to crash team: This CL is a refactor and has no intended behavior change.

This change was scripted by https://crbug.com/676387#c8.

Note-worthy for the reviewer:
 * SequenceChecker enforces thread-safety but not thread-affinity!
   If the classes that were updated are thread-affine (use thread local
   storage or a third-party API that does) they should be migrated to
   ThreadChecker instead.
 * ~NonThreadSafe() used to implcitly check in its destructor
   ~Sequence/ThreadChecker() doesn't by design. To keep this CL a
   no-op, an explicit check was added to the destructor of migrated
   classes.
 * NonThreadSafe used to provide access to subclasses, as such
   the |sequence_checker_| member was made protected rather than
   private where necessary.

BUG=676387
This CL was uploaded by git cl split.

TBR=hashimoto@chromium.org

Review-Url: https://codereview.chromium.org/2907223002
Cr-Commit-Position: refs/heads/master@{#476292}
parent e7178d16
......@@ -189,6 +189,7 @@ BatchRequestConfigurator::BatchRequestConfigurator(
}
BatchRequestConfigurator::~BatchRequestConfigurator() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// The batch requst has not been committed.
if (batch_request_)
cancel_callback_.Run();
......@@ -203,7 +204,7 @@ google_apis::CancelCallback BatchRequestConfigurator::MultipartUploadNewFile(
const UploadNewFileOptions& options,
const google_apis::FileResourceCallback& callback,
const google_apis::ProgressCallback& progress_callback) {
DCHECK(CalledOnValidThread());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(!callback.is_null());
std::unique_ptr<google_apis::BatchableDelegate> delegate(
......@@ -230,7 +231,7 @@ BatchRequestConfigurator::MultipartUploadExistingFile(
const UploadExistingFileOptions& options,
const google_apis::FileResourceCallback& callback,
const google_apis::ProgressCallback& progress_callback) {
DCHECK(CalledOnValidThread());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(!callback.is_null());
std::unique_ptr<google_apis::BatchableDelegate> delegate(
......@@ -250,7 +251,7 @@ BatchRequestConfigurator::MultipartUploadExistingFile(
}
void BatchRequestConfigurator::Commit() {
DCHECK(CalledOnValidThread());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (!batch_request_)
return;
batch_request_->Commit();
......
......@@ -14,6 +14,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/sequence_checker.h"
#include "base/threading/thread_checker.h"
#include "components/drive/service/drive_service_interface.h"
#include "google_apis/drive/auth_service_interface.h"
......@@ -44,8 +45,7 @@ class URLRequestContextGetter;
namespace drive {
// Builder for batch request returned by |DriveAPIService|.
class BatchRequestConfigurator : public BatchRequestConfiguratorInterface,
public base::NonThreadSafe {
class BatchRequestConfigurator : public BatchRequestConfiguratorInterface {
public:
BatchRequestConfigurator(
const base::WeakPtr<google_apis::drive::BatchUploadRequest>&
......@@ -82,6 +82,8 @@ class BatchRequestConfigurator : public BatchRequestConfiguratorInterface,
google_apis::DriveApiUrlGenerator url_generator_;
google_apis::CancelCallback cancel_callback_;
SEQUENCE_CHECKER(sequence_checker_);
DISALLOW_COPY_AND_ASSIGN(BatchRequestConfigurator);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment