diff options
Diffstat (limited to 'chrome/browser/chromeos/drive/file_system')
24 files changed, 87 insertions, 91 deletions
diff --git a/chrome/browser/chromeos/drive/file_system/copy_operation.cc b/chrome/browser/chromeos/drive/file_system/copy_operation.cc index 39b959a..e6b58f1 100644 --- a/chrome/browser/chromeos/drive/file_system/copy_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/copy_operation.cc @@ -17,11 +17,8 @@ #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" #include "chrome/browser/chromeos/drive/resource_metadata.h" #include "chrome/browser/drive/drive_api_util.h" -#include "content/public/browser/browser_thread.h" #include "google_apis/drive/drive_api_parser.h" -using content::BrowserThread; - namespace drive { namespace file_system { @@ -288,18 +285,17 @@ CopyOperation::CopyOperation(base::SequencedTaskRunner* blocking_task_runner, delegate, metadata)), weak_ptr_factory_(this) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); } CopyOperation::~CopyOperation() { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); } void CopyOperation::Copy(const base::FilePath& src_file_path, const base::FilePath& dest_file_path, bool preserve_last_modified, const FileOperationCallback& callback) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); CopyParams* params = new CopyParams; @@ -328,7 +324,7 @@ void CopyOperation::CopyAfterTryToCopyLocally( const bool* directory_changed, const bool* should_copy_on_server, FileError error) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!params->callback.is_null()); for (const auto& id : *updated_local_ids) { @@ -366,7 +362,7 @@ void CopyOperation::CopyAfterTryToCopyLocally( void CopyOperation::CopyAfterParentSync(const CopyParams& params, FileError error) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!params.callback.is_null()); if (error != FILE_ERROR_OK) { @@ -391,7 +387,7 @@ void CopyOperation::CopyAfterParentSync(const CopyParams& params, void CopyOperation::CopyAfterGetParentResourceId(const CopyParams& params, const ResourceEntry* parent, FileError error) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!params.callback.is_null()); if (error != FILE_ERROR_OK) { @@ -420,7 +416,7 @@ void CopyOperation::TransferFileFromLocalToRemote( const base::FilePath& local_src_path, const base::FilePath& remote_dest_path, const FileOperationCallback& callback) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); std::string* gdoc_resource_id = new std::string; @@ -446,7 +442,7 @@ void CopyOperation::TransferFileFromLocalToRemoteAfterPrepare( std::string* gdoc_resource_id, ResourceEntry* parent_entry, FileError error) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); if (error != FILE_ERROR_OK) { @@ -483,7 +479,7 @@ void CopyOperation::TransferFileFromLocalToRemoteAfterPrepare( void CopyOperation::TransferJsonGdocFileAfterLocalWork( TransferJsonGdocParams* params, FileError error) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); if (error != FILE_ERROR_OK) { params->callback.Run(error); @@ -541,7 +537,7 @@ void CopyOperation::CopyResourceOnServer( const std::string& new_title, const base::Time& last_modified, const FileOperationCallback& callback) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); scheduler_->CopyResource( @@ -555,7 +551,7 @@ void CopyOperation::UpdateAfterServerSideOperation( const FileOperationCallback& callback, google_apis::DriveApiErrorCode status, scoped_ptr<google_apis::FileResource> entry) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); FileError error = GDataToFileError(status); @@ -589,7 +585,7 @@ void CopyOperation::UpdateAfterLocalStateUpdate( base::FilePath* file_path, const ResourceEntry* entry, FileError error) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); if (error == FILE_ERROR_OK) { @@ -604,7 +600,7 @@ void CopyOperation::ScheduleTransferRegularFile( const base::FilePath& local_src_path, const base::FilePath& remote_dest_path, const FileOperationCallback& callback) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); create_file_operation_->CreateFile( @@ -621,7 +617,7 @@ void CopyOperation::ScheduleTransferRegularFileAfterCreate( const base::FilePath& remote_dest_path, const FileOperationCallback& callback, FileError error) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); if (error != FILE_ERROR_OK) { @@ -656,7 +652,7 @@ void CopyOperation::ScheduleTransferRegularFileAfterUpdateLocalState( const ResourceEntry* entry, std::string* local_id, FileError error) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); if (error == FILE_ERROR_OK) { diff --git a/chrome/browser/chromeos/drive/file_system/copy_operation.h b/chrome/browser/chromeos/drive/file_system/copy_operation.h index 6a3833d..af3bbdc 100644 --- a/chrome/browser/chromeos/drive/file_system/copy_operation.h +++ b/chrome/browser/chromeos/drive/file_system/copy_operation.h @@ -12,6 +12,7 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" +#include "base/threading/thread_checker.h" #include "chrome/browser/chromeos/drive/file_errors.h" #include "google_apis/drive/drive_api_error_codes.h" @@ -166,6 +167,8 @@ class CopyOperation { // Uploading a new file is internally implemented by creating a dirty file. scoped_ptr<CreateFileOperation> create_file_operation_; + base::ThreadChecker thread_checker_; + // Note: This should remain the last member so it'll be destroyed and // invalidate the weak pointers before any other members are destroyed. base::WeakPtrFactory<CopyOperation> weak_ptr_factory_; diff --git a/chrome/browser/chromeos/drive/file_system/create_directory_operation.cc b/chrome/browser/chromeos/drive/file_system/create_directory_operation.cc index 28d36b9..1901c4c 100644 --- a/chrome/browser/chromeos/drive/file_system/create_directory_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/create_directory_operation.cc @@ -10,9 +10,6 @@ #include "chrome/browser/chromeos/drive/file_system_util.h" #include "chrome/browser/chromeos/drive/job_scheduler.h" #include "chrome/browser/chromeos/drive/resource_metadata.h" -#include "content/public/browser/browser_thread.h" - -using content::BrowserThread; namespace drive { namespace file_system { @@ -130,11 +127,10 @@ CreateDirectoryOperation::CreateDirectoryOperation( delegate_(delegate), metadata_(metadata), weak_ptr_factory_(this) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); } CreateDirectoryOperation::~CreateDirectoryOperation() { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); } void CreateDirectoryOperation::CreateDirectory( @@ -142,7 +138,7 @@ void CreateDirectoryOperation::CreateDirectory( bool is_exclusive, bool is_recursive, const FileOperationCallback& callback) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); std::set<std::string>* updated_local_ids = new std::set<std::string>; @@ -170,7 +166,7 @@ void CreateDirectoryOperation::CreateDirectoryAfterUpdateLocalState( const std::set<std::string>* updated_local_ids, const FileChange* changed_files, FileError error) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); for (const auto& id : *updated_local_ids) { diff --git a/chrome/browser/chromeos/drive/file_system/create_directory_operation.h b/chrome/browser/chromeos/drive/file_system/create_directory_operation.h index f77a599..4b3055b 100644 --- a/chrome/browser/chromeos/drive/file_system/create_directory_operation.h +++ b/chrome/browser/chromeos/drive/file_system/create_directory_operation.h @@ -10,6 +10,7 @@ #include "base/basictypes.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" +#include "base/threading/thread_checker.h" #include "chrome/browser/chromeos/drive/file_errors.h" namespace base { @@ -64,6 +65,8 @@ class CreateDirectoryOperation { OperationDelegate* delegate_; internal::ResourceMetadata* metadata_; + base::ThreadChecker thread_checker_; + // Note: This should remain the last member so it'll be destroyed and // invalidate the weak pointers before any other members are destroyed. base::WeakPtrFactory<CreateDirectoryOperation> weak_ptr_factory_; diff --git a/chrome/browser/chromeos/drive/file_system/create_file_operation.cc b/chrome/browser/chromeos/drive/file_system/create_file_operation.cc index afbc20c..12e57aa 100644 --- a/chrome/browser/chromeos/drive/file_system/create_file_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/create_file_operation.cc @@ -12,11 +12,8 @@ #include "chrome/browser/chromeos/drive/file_system/operation_delegate.h" #include "chrome/browser/chromeos/drive/job_scheduler.h" #include "chrome/browser/chromeos/drive/resource_metadata.h" -#include "content/public/browser/browser_thread.h" #include "net/base/mime_util.h" -using content::BrowserThread; - namespace drive { namespace file_system { @@ -78,18 +75,17 @@ CreateFileOperation::CreateFileOperation( delegate_(delegate), metadata_(metadata), weak_ptr_factory_(this) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); } CreateFileOperation::~CreateFileOperation() { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); } void CreateFileOperation::CreateFile(const base::FilePath& file_path, bool is_exclusive, const std::string& mime_type, const FileOperationCallback& callback) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); ResourceEntry* entry = new ResourceEntry; @@ -115,7 +111,7 @@ void CreateFileOperation::CreateFileAfterUpdateLocalState( bool is_exclusive, ResourceEntry* entry, FileError error) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); if (error == FILE_ERROR_EXISTS) { diff --git a/chrome/browser/chromeos/drive/file_system/create_file_operation.h b/chrome/browser/chromeos/drive/file_system/create_file_operation.h index d515ac7..6c2b627 100644 --- a/chrome/browser/chromeos/drive/file_system/create_file_operation.h +++ b/chrome/browser/chromeos/drive/file_system/create_file_operation.h @@ -8,6 +8,7 @@ #include "base/basictypes.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" +#include "base/threading/thread_checker.h" #include "chrome/browser/chromeos/drive/file_errors.h" namespace base { @@ -61,6 +62,8 @@ class CreateFileOperation { OperationDelegate* delegate_; internal::ResourceMetadata* metadata_; + base::ThreadChecker thread_checker_; + // Note: This should remain the last member so it'll be destroyed and // invalidate the weak pointers before any other members are destroyed. base::WeakPtrFactory<CreateFileOperation> weak_ptr_factory_; diff --git a/chrome/browser/chromeos/drive/file_system/download_operation.cc b/chrome/browser/chromeos/drive/file_system/download_operation.cc index 1aeb5e7..d3dde19 100644 --- a/chrome/browser/chromeos/drive/file_system/download_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/download_operation.cc @@ -17,11 +17,8 @@ #include "chrome/browser/chromeos/drive/file_system_util.h" #include "chrome/browser/chromeos/drive/job_scheduler.h" #include "chrome/browser/chromeos/drive/resource_metadata.h" -#include "content/public/browser/browser_thread.h" #include "google_apis/drive/drive_api_error_codes.h" -using content::BrowserThread; - namespace drive { namespace file_system { namespace { @@ -360,7 +357,7 @@ base::Closure DownloadOperation::EnsureFileDownloadedByLocalId( const GetFileContentInitializedCallback& initialized_callback, const google_apis::GetContentCallback& get_content_callback, const GetFileCallback& completion_callback) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!completion_callback.is_null()); CheckPreconditionForEnsureFileDownloadedParams params; @@ -401,7 +398,7 @@ base::Closure DownloadOperation::EnsureFileDownloadedByPath( const GetFileContentInitializedCallback& initialized_callback, const google_apis::GetContentCallback& get_content_callback, const GetFileCallback& completion_callback) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!completion_callback.is_null()); CheckPreconditionForEnsureFileDownloadedParams params; @@ -442,7 +439,7 @@ void DownloadOperation::EnsureFileDownloadedAfterCheckPreCondition( base::FilePath* cache_file_path, base::FilePath* temp_download_file_path, FileError error) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(params); DCHECK(drive_file_path); DCHECK(cache_file_path); @@ -489,7 +486,7 @@ void DownloadOperation::EnsureFileDownloadedAfterDownloadFile( scoped_ptr<DownloadParams> params, google_apis::DriveApiErrorCode gdata_error, const base::FilePath& downloaded_file_path) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DownloadParams* params_ptr = params.get(); ResourceEntry* entry_after_update = new ResourceEntry; @@ -519,7 +516,7 @@ void DownloadOperation::EnsureFileDownloadedAfterUpdateLocalState( scoped_ptr<ResourceEntry> entry_after_update, base::FilePath* cache_file_path, FileError error) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); if (error != FILE_ERROR_OK) { params->OnError(error); diff --git a/chrome/browser/chromeos/drive/file_system/download_operation.h b/chrome/browser/chromeos/drive/file_system/download_operation.h index 9dcd52d..2ad4018 100644 --- a/chrome/browser/chromeos/drive/file_system/download_operation.h +++ b/chrome/browser/chromeos/drive/file_system/download_operation.h @@ -7,6 +7,7 @@ #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" +#include "base/threading/thread_checker.h" #include "chrome/browser/chromeos/drive/file_errors.h" #include "chrome/browser/chromeos/drive/file_system_interface.h" #include "chrome/browser/chromeos/drive/job_list.h" @@ -118,6 +119,8 @@ class DownloadOperation { internal::FileCache* cache_; const base::FilePath temporary_file_directory_; + base::ThreadChecker thread_checker_; + // Note: This should remain the last member so it'll be destroyed and // invalidate its weak pointers before any other members are destroyed. base::WeakPtrFactory<DownloadOperation> weak_ptr_factory_; diff --git a/chrome/browser/chromeos/drive/file_system/get_file_for_saving_operation.cc b/chrome/browser/chromeos/drive/file_system/get_file_for_saving_operation.cc index ea85f58..12f2898 100644 --- a/chrome/browser/chromeos/drive/file_system/get_file_for_saving_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/get_file_for_saving_operation.cc @@ -16,8 +16,6 @@ #include "chrome/browser/drive/event_logger.h" #include "content/public/browser/browser_thread.h" -using content::BrowserThread; - namespace drive { namespace file_system { @@ -69,7 +67,7 @@ GetFileForSavingOperation::~GetFileForSavingOperation() { void GetFileForSavingOperation::GetFileForSaving( const base::FilePath& file_path, const GetFileCallback& callback) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); create_file_operation_->CreateFile( @@ -86,7 +84,7 @@ void GetFileForSavingOperation::GetFileForSavingAfterCreate( const base::FilePath& file_path, const GetFileCallback& callback, FileError error) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); if (error != FILE_ERROR_OK) { @@ -109,7 +107,7 @@ void GetFileForSavingOperation::GetFileForSavingAfterDownload( FileError error, const base::FilePath& cache_path, scoped_ptr<ResourceEntry> entry) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); if (error != FILE_ERROR_OK) { @@ -144,7 +142,7 @@ void GetFileForSavingOperation::GetFileForSavingAfterOpenForWrite( scoped_ptr<ResourceEntry> entry, scoped_ptr<base::ScopedClosureRunner>* file_closer, FileError error) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); if (error != FILE_ERROR_OK) { @@ -171,7 +169,7 @@ void GetFileForSavingOperation::GetFileForSavingAfterWatch( const base::FilePath& cache_path, scoped_ptr<ResourceEntry> entry, bool success) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); logger_->Log(logging::LOG_INFO, "Started watching modification to %s [%s].", diff --git a/chrome/browser/chromeos/drive/file_system/get_file_for_saving_operation.h b/chrome/browser/chromeos/drive/file_system/get_file_for_saving_operation.h index 749c5f0..fc63db1 100644 --- a/chrome/browser/chromeos/drive/file_system/get_file_for_saving_operation.h +++ b/chrome/browser/chromeos/drive/file_system/get_file_for_saving_operation.h @@ -9,6 +9,7 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" +#include "base/threading/thread_checker.h" #include "chrome/browser/chromeos/drive/file_errors.h" #include "chrome/browser/chromeos/drive/file_system_interface.h" @@ -94,6 +95,8 @@ class GetFileForSavingOperation { internal::ResourceMetadata* metadata_; internal::FileCache* cache_; + base::ThreadChecker thread_checker_; + // Note: This should remain the last member so it'll be destroyed and // invalidate the weak pointers before any other members are destroyed. base::WeakPtrFactory<GetFileForSavingOperation> weak_ptr_factory_; diff --git a/chrome/browser/chromeos/drive/file_system/move_operation.cc b/chrome/browser/chromeos/drive/file_system/move_operation.cc index 402ee53..9d9391b 100644 --- a/chrome/browser/chromeos/drive/file_system/move_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/move_operation.cc @@ -10,9 +10,6 @@ #include "chrome/browser/chromeos/drive/file_system/operation_delegate.h" #include "chrome/browser/chromeos/drive/job_scheduler.h" #include "chrome/browser/chromeos/drive/resource_metadata.h" -#include "content/public/browser/browser_thread.h" - -using content::BrowserThread; namespace drive { namespace file_system { @@ -74,17 +71,16 @@ MoveOperation::MoveOperation(base::SequencedTaskRunner* blocking_task_runner, delegate_(delegate), metadata_(metadata), weak_ptr_factory_(this) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); } MoveOperation::~MoveOperation() { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); } void MoveOperation::Move(const base::FilePath& src_file_path, const base::FilePath& dest_file_path, const FileOperationCallback& callback) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); FileChange* changed_files = new FileChange; @@ -110,7 +106,7 @@ void MoveOperation::MoveAfterUpdateLocalState( const FileChange* changed_files, const std::string* local_id, FileError error) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); if (error == FILE_ERROR_OK) { // Notify the change of directory. delegate_->OnFileChangedByOperation(*changed_files); diff --git a/chrome/browser/chromeos/drive/file_system/move_operation.h b/chrome/browser/chromeos/drive/file_system/move_operation.h index 5bea0e6..7b41933 100644 --- a/chrome/browser/chromeos/drive/file_system/move_operation.h +++ b/chrome/browser/chromeos/drive/file_system/move_operation.h @@ -11,6 +11,7 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" +#include "base/threading/thread_checker.h" #include "chrome/browser/chromeos/drive/file_errors.h" #include "google_apis/drive/drive_api_error_codes.h" @@ -64,6 +65,8 @@ class MoveOperation { OperationDelegate* delegate_; internal::ResourceMetadata* metadata_; + base::ThreadChecker thread_checker_; + // Note: This should remain the last member so it'll be destroyed and // invalidate the weak pointers before any other members are destroyed. base::WeakPtrFactory<MoveOperation> weak_ptr_factory_; diff --git a/chrome/browser/chromeos/drive/file_system/open_file_operation.cc b/chrome/browser/chromeos/drive/file_system/open_file_operation.cc index d8aa4a0..ee779ec 100644 --- a/chrome/browser/chromeos/drive/file_system/open_file_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/open_file_operation.cc @@ -18,9 +18,6 @@ #include "chrome/browser/chromeos/drive/file_system/download_operation.h" #include "chrome/browser/chromeos/drive/file_system/operation_delegate.h" #include "chrome/browser/chromeos/drive/job_scheduler.h" -#include "content/public/browser/browser_thread.h" - -using content::BrowserThread; namespace drive { namespace file_system { @@ -50,7 +47,7 @@ void OpenFileOperation::OpenFile(const base::FilePath& file_path, OpenMode open_mode, const std::string& mime_type, const OpenFileCallback& callback) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); switch (open_mode) { @@ -83,7 +80,7 @@ void OpenFileOperation::OpenFileAfterCreateFile( const base::FilePath& file_path, const OpenFileCallback& callback, FileError error) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); if (error != FILE_ERROR_OK) { @@ -106,7 +103,7 @@ void OpenFileOperation::OpenFileAfterFileDownloaded( FileError error, const base::FilePath& local_file_path, scoped_ptr<ResourceEntry> entry) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); if (error == FILE_ERROR_OK) { @@ -145,7 +142,7 @@ void OpenFileOperation::OpenFileAfterOpenForWrite( const OpenFileCallback& callback, scoped_ptr<base::ScopedClosureRunner>* file_closer, FileError error) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); if (error != FILE_ERROR_OK) { @@ -164,7 +161,7 @@ void OpenFileOperation::OpenFileAfterOpenForWrite( void OpenFileOperation::CloseFile( const std::string& local_id, scoped_ptr<base::ScopedClosureRunner> file_closer) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_GT(open_files_[local_id], 0); if (--open_files_[local_id] == 0) { diff --git a/chrome/browser/chromeos/drive/file_system/open_file_operation.h b/chrome/browser/chromeos/drive/file_system/open_file_operation.h index 953130b..02795b6 100644 --- a/chrome/browser/chromeos/drive/file_system/open_file_operation.h +++ b/chrome/browser/chromeos/drive/file_system/open_file_operation.h @@ -11,6 +11,7 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" +#include "base/threading/thread_checker.h" #include "chrome/browser/chromeos/drive/file_errors.h" #include "chrome/browser/chromeos/drive/file_system_interface.h" @@ -94,6 +95,8 @@ class OpenFileOperation { // the file is opened. std::map<std::string, int> open_files_; + base::ThreadChecker thread_checker_; + // Note: This should remain the last member so it'll be destroyed and // invalidate its weak pointers before any other members are destroyed. base::WeakPtrFactory<OpenFileOperation> weak_ptr_factory_; diff --git a/chrome/browser/chromeos/drive/file_system/remove_operation.cc b/chrome/browser/chromeos/drive/file_system/remove_operation.cc index c3f7a1e..d3d58d9 100644 --- a/chrome/browser/chromeos/drive/file_system/remove_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/remove_operation.cc @@ -12,9 +12,6 @@ #include "chrome/browser/chromeos/drive/file_system_util.h" #include "chrome/browser/chromeos/drive/job_scheduler.h" #include "chrome/browser/chromeos/drive/resource_metadata.h" -#include "content/public/browser/browser_thread.h" - -using content::BrowserThread; namespace drive { namespace file_system { @@ -70,17 +67,16 @@ RemoveOperation::RemoveOperation( metadata_(metadata), cache_(cache), weak_ptr_factory_(this) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); } RemoveOperation::~RemoveOperation() { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); } void RemoveOperation::Remove(const base::FilePath& path, bool is_recursive, const FileOperationCallback& callback) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); std::string* local_id = new std::string; @@ -111,7 +107,7 @@ void RemoveOperation::RemoveAfterUpdateLocalState( const ResourceEntry* entry, const base::FilePath* changed_path, FileError error) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); if (!changed_path->empty()) { diff --git a/chrome/browser/chromeos/drive/file_system/remove_operation.h b/chrome/browser/chromeos/drive/file_system/remove_operation.h index 215e6a3..c8cc6f3 100644 --- a/chrome/browser/chromeos/drive/file_system/remove_operation.h +++ b/chrome/browser/chromeos/drive/file_system/remove_operation.h @@ -9,6 +9,7 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" +#include "base/threading/thread_checker.h" #include "chrome/browser/chromeos/drive/file_errors.h" #include "google_apis/drive/drive_api_error_codes.h" @@ -62,6 +63,8 @@ class RemoveOperation { internal::ResourceMetadata* metadata_; internal::FileCache* cache_; + base::ThreadChecker thread_checker_; + // Note: This should remain the last member so it'll be destroyed and // invalidate the weak pointers before any other members are destroyed. base::WeakPtrFactory<RemoveOperation> weak_ptr_factory_; diff --git a/chrome/browser/chromeos/drive/file_system/search_operation.cc b/chrome/browser/chromeos/drive/file_system/search_operation.cc index 8b32317..182cb6f 100644 --- a/chrome/browser/chromeos/drive/file_system/search_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/search_operation.cc @@ -17,12 +17,9 @@ #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" #include "chrome/browser/chromeos/drive/resource_metadata.h" #include "chrome/browser/drive/drive_api_util.h" -#include "content/public/browser/browser_thread.h" #include "google_apis/drive/drive_api_parser.h" #include "url/gurl.h" -using content::BrowserThread; - namespace drive { namespace file_system { namespace { @@ -98,7 +95,7 @@ SearchOperation::~SearchOperation() { void SearchOperation::Search(const std::string& search_query, const GURL& next_link, const SearchCallback& callback) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); if (next_link.is_empty()) { @@ -120,7 +117,7 @@ void SearchOperation::SearchAfterGetFileList( const SearchCallback& callback, google_apis::DriveApiErrorCode gdata_error, scoped_ptr<google_apis::FileList> file_list) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); FileError error = GDataToFileError(gdata_error); @@ -167,7 +164,7 @@ void SearchOperation::SearchAfterResolveSearchResult( const GURL& next_link, scoped_ptr<std::vector<SearchResultInfo> > result, FileError error) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); DCHECK(result); diff --git a/chrome/browser/chromeos/drive/file_system/search_operation.h b/chrome/browser/chromeos/drive/file_system/search_operation.h index aa2e5f7..709371d 100644 --- a/chrome/browser/chromeos/drive/file_system/search_operation.h +++ b/chrome/browser/chromeos/drive/file_system/search_operation.h @@ -9,6 +9,7 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" +#include "base/threading/thread_checker.h" #include "chrome/browser/chromeos/drive/file_errors.h" #include "chrome/browser/chromeos/drive/file_system_interface.h" #include "google_apis/drive/drive_api_error_codes.h" @@ -71,6 +72,8 @@ class SearchOperation { internal::ResourceMetadata* metadata_; internal::LoaderController* loader_controller_; + base::ThreadChecker thread_checker_; + // Note: This should remain the last member so it'll be destroyed and // invalidate the weak pointers before any other members are destroyed. base::WeakPtrFactory<SearchOperation> weak_ptr_factory_; diff --git a/chrome/browser/chromeos/drive/file_system/set_property_operation.cc b/chrome/browser/chromeos/drive/file_system/set_property_operation.cc index 111f9b7..509ba2a 100644 --- a/chrome/browser/chromeos/drive/file_system/set_property_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/set_property_operation.cc @@ -12,9 +12,6 @@ #include "chrome/browser/chromeos/drive/file_system/operation_delegate.h" #include "chrome/browser/chromeos/drive/job_scheduler.h" #include "chrome/browser/chromeos/drive/resource_metadata.h" -#include "content/public/browser/browser_thread.h" - -using content::BrowserThread; namespace drive { namespace file_system { @@ -90,7 +87,7 @@ void SetPropertyOperation::SetProperty( const std::string& key, const std::string& value, const FileOperationCallback& callback) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); ResourceEntry* entry = new ResourceEntry; @@ -106,7 +103,7 @@ void SetPropertyOperation::SetPropertyAfterUpdateLocalState( const FileOperationCallback& callback, const ResourceEntry* entry, FileError result) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); if (result == FILE_ERROR_OK) { diff --git a/chrome/browser/chromeos/drive/file_system/set_property_operation.h b/chrome/browser/chromeos/drive/file_system/set_property_operation.h index 5d5634f..6a93a16 100644 --- a/chrome/browser/chromeos/drive/file_system/set_property_operation.h +++ b/chrome/browser/chromeos/drive/file_system/set_property_operation.h @@ -10,6 +10,7 @@ #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" +#include "base/threading/thread_checker.h" #include "chrome/browser/chromeos/drive/file_errors.h" #include "google_apis/drive/drive_api_requests.h" @@ -55,6 +56,8 @@ class SetPropertyOperation { OperationDelegate* delegate_; internal::ResourceMetadata* metadata_; + base::ThreadChecker thread_checker_; + // Note: This should remain the last member so it'll be destroyed and // invalidate the weak pointers before any other members are destroyed. base::WeakPtrFactory<SetPropertyOperation> weak_ptr_factory_; diff --git a/chrome/browser/chromeos/drive/file_system/touch_operation.cc b/chrome/browser/chromeos/drive/file_system/touch_operation.cc index 217bd92..47dd5aa 100644 --- a/chrome/browser/chromeos/drive/file_system/touch_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/touch_operation.cc @@ -13,9 +13,6 @@ #include "chrome/browser/chromeos/drive/file_system/operation_delegate.h" #include "chrome/browser/chromeos/drive/job_scheduler.h" #include "chrome/browser/chromeos/drive/resource_metadata.h" -#include "content/public/browser/browser_thread.h" - -using content::BrowserThread; namespace drive { namespace file_system { @@ -60,7 +57,7 @@ void TouchOperation::TouchFile(const base::FilePath& file_path, const base::Time& last_access_time, const base::Time& last_modified_time, const FileOperationCallback& callback) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); ResourceEntry* entry = new ResourceEntry; @@ -78,7 +75,7 @@ void TouchOperation::TouchFileAfterUpdateLocalState( const FileOperationCallback& callback, const ResourceEntry* entry, FileError error) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); FileChange changed_files; diff --git a/chrome/browser/chromeos/drive/file_system/touch_operation.h b/chrome/browser/chromeos/drive/file_system/touch_operation.h index 15d6849..fe2ebc2 100644 --- a/chrome/browser/chromeos/drive/file_system/touch_operation.h +++ b/chrome/browser/chromeos/drive/file_system/touch_operation.h @@ -8,6 +8,7 @@ #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" +#include "base/threading/thread_checker.h" #include "chrome/browser/chromeos/drive/file_errors.h" namespace base { @@ -53,6 +54,8 @@ class TouchOperation { OperationDelegate* delegate_; internal::ResourceMetadata* metadata_; + base::ThreadChecker thread_checker_; + // Note: This should remain the last member so it'll be destroyed and // invalidate the weak pointers before any other members are destroyed. base::WeakPtrFactory<TouchOperation> weak_ptr_factory_; diff --git a/chrome/browser/chromeos/drive/file_system/truncate_operation.cc b/chrome/browser/chromeos/drive/file_system/truncate_operation.cc index 0c0edaf..ff1307e 100644 --- a/chrome/browser/chromeos/drive/file_system/truncate_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/truncate_operation.cc @@ -18,9 +18,6 @@ #include "chrome/browser/chromeos/drive/file_system/download_operation.h" #include "chrome/browser/chromeos/drive/file_system/operation_delegate.h" #include "chrome/browser/chromeos/drive/job_scheduler.h" -#include "content/public/browser/browser_thread.h" - -using content::BrowserThread; namespace drive { namespace file_system { @@ -80,7 +77,7 @@ TruncateOperation::~TruncateOperation() { void TruncateOperation::Truncate(const base::FilePath& file_path, int64 length, const FileOperationCallback& callback) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); if (length < 0) { @@ -107,7 +104,7 @@ void TruncateOperation::TruncateAfterEnsureFileDownloadedByPath( FileError error, const base::FilePath& local_file_path, scoped_ptr<ResourceEntry> entry) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); if (error != FILE_ERROR_OK) { @@ -136,7 +133,7 @@ void TruncateOperation::TruncateAfterTruncateOnBlockingPool( const std::string& local_id, const FileOperationCallback& callback, FileError error) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!callback.is_null()); delegate_->OnEntryUpdatedByOperation(ClientContext(USER_INITIATED), local_id); diff --git a/chrome/browser/chromeos/drive/file_system/truncate_operation.h b/chrome/browser/chromeos/drive/file_system/truncate_operation.h index 0a6d5e7..5067c6b 100644 --- a/chrome/browser/chromeos/drive/file_system/truncate_operation.h +++ b/chrome/browser/chromeos/drive/file_system/truncate_operation.h @@ -9,6 +9,7 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" +#include "base/threading/thread_checker.h" #include "chrome/browser/chromeos/drive/file_errors.h" namespace base { @@ -73,6 +74,8 @@ class TruncateOperation { scoped_ptr<DownloadOperation> download_operation_; + base::ThreadChecker thread_checker_; + // Note: This should remain the last member so it'll be destroyed and // invalidate the weak pointers before any other members are destroyed. base::WeakPtrFactory<TruncateOperation> weak_ptr_factory_; |