diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-05 05:07:00 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-05 05:07:00 +0000 |
commit | 4c83eee8ce0dea29a99ab9d9123d1eb1f98ee4bb (patch) | |
tree | 1fc768a836aaea1879f2131a52a350eb92398a95 | |
parent | 432e3ef8559be8971a0750249230ee1772c334c0 (diff) | |
download | chromium_src-4c83eee8ce0dea29a99ab9d9123d1eb1f98ee4bb.zip chromium_src-4c83eee8ce0dea29a99ab9d9123d1eb1f98ee4bb.tar.gz chromium_src-4c83eee8ce0dea29a99ab9d9123d1eb1f98ee4bb.tar.bz2 |
Media Galleries: Omit ById in various method names, since all operations are now by id.
Review URL: https://codereview.chromium.org/437313002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287461 0039d316-1c4b-4281-b951-d872f2087c98
10 files changed, 80 insertions, 86 deletions
diff --git a/chrome/browser/media_galleries/linux/mtp_device_delegate_impl_linux.cc b/chrome/browser/media_galleries/linux/mtp_device_delegate_impl_linux.cc index 674c5c3..82bf26c 100644 --- a/chrome/browser/media_galleries/linux/mtp_device_delegate_impl_linux.cc +++ b/chrome/browser/media_galleries/linux/mtp_device_delegate_impl_linux.cc @@ -101,7 +101,7 @@ void ReadDirectoryOnUIThread( GetDeviceTaskHelperForStorage(storage_name); if (!task_helper) return; - task_helper->ReadDirectoryById(dir_id, success_callback, error_callback); + task_helper->ReadDirectory(dir_id, success_callback, error_callback); } // Gets the |file_path| details. @@ -123,7 +123,7 @@ void GetFileInfoOnUIThread( GetDeviceTaskHelperForStorage(storage_name); if (!task_helper) return; - task_helper->GetFileInfoById(file_id, success_callback, error_callback); + task_helper->GetFileInfo(file_id, success_callback, error_callback); } // Copies the contents of |device_file_path| to |snapshot_file_path|. diff --git a/chrome/browser/media_galleries/linux/mtp_device_task_helper.cc b/chrome/browser/media_galleries/linux/mtp_device_task_helper.cc index 80fa851..0282c8a 100644 --- a/chrome/browser/media_galleries/linux/mtp_device_task_helper.cc +++ b/chrome/browser/media_galleries/linux/mtp_device_task_helper.cc @@ -75,7 +75,7 @@ void MTPDeviceTaskHelper::OpenStorage(const std::string& storage_name, callback)); } -void MTPDeviceTaskHelper::GetFileInfoById( +void MTPDeviceTaskHelper::GetFileInfo( uint32 file_id, const GetFileInfoSuccessCallback& success_callback, const ErrorCallback& error_callback) { @@ -83,7 +83,7 @@ void MTPDeviceTaskHelper::GetFileInfoById( if (device_handle_.empty()) return HandleDeviceError(error_callback, base::File::FILE_ERROR_FAILED); - GetMediaTransferProtocolManager()->GetFileInfoById( + GetMediaTransferProtocolManager()->GetFileInfo( device_handle_, file_id, base::Bind(&MTPDeviceTaskHelper::OnGetFileInfo, weak_ptr_factory_.GetWeakPtr(), @@ -91,7 +91,7 @@ void MTPDeviceTaskHelper::GetFileInfoById( error_callback)); } -void MTPDeviceTaskHelper::ReadDirectoryById( +void MTPDeviceTaskHelper::ReadDirectory( uint32 dir_id, const ReadDirectorySuccessCallback& success_callback, const ErrorCallback& error_callback) { @@ -99,9 +99,9 @@ void MTPDeviceTaskHelper::ReadDirectoryById( if (device_handle_.empty()) return HandleDeviceError(error_callback, base::File::FILE_ERROR_FAILED); - GetMediaTransferProtocolManager()->ReadDirectoryById( + GetMediaTransferProtocolManager()->ReadDirectory( device_handle_, dir_id, - base::Bind(&MTPDeviceTaskHelper::OnDidReadDirectoryById, + base::Bind(&MTPDeviceTaskHelper::OnDidReadDirectory, weak_ptr_factory_.GetWeakPtr(), success_callback, error_callback)); @@ -130,7 +130,7 @@ void MTPDeviceTaskHelper::ReadBytes( base::File::FILE_ERROR_FAILED); } - GetMediaTransferProtocolManager()->GetFileInfoById( + GetMediaTransferProtocolManager()->GetFileInfo( device_handle_, request.file_id, base::Bind(&MTPDeviceTaskHelper::OnGetFileInfoToReadBytes, weak_ptr_factory_.GetWeakPtr(), request)); @@ -172,7 +172,7 @@ void MTPDeviceTaskHelper::OnGetFileInfo( base::Bind(success_callback, FileInfoFromMTPFileEntry(file_entry))); } -void MTPDeviceTaskHelper::OnDidReadDirectoryById( +void MTPDeviceTaskHelper::OnDidReadDirectory( const ReadDirectorySuccessCallback& success_callback, const ErrorCallback& error_callback, const std::vector<MtpFileEntry>& file_entries, @@ -237,7 +237,7 @@ void MTPDeviceTaskHelper::OnGetFileInfoToReadBytes( base::checked_cast<uint32>(request.buf_len), base::saturated_cast<uint32>(file_info.size - request.offset)); - GetMediaTransferProtocolManager()->ReadFileChunkById( + GetMediaTransferProtocolManager()->ReadFileChunk( device_handle_, request.file_id, base::checked_cast<uint32>(request.offset), diff --git a/chrome/browser/media_galleries/linux/mtp_device_task_helper.h b/chrome/browser/media_galleries/linux/mtp_device_task_helper.h index ffe8afb..f24251e 100644 --- a/chrome/browser/media_galleries/linux/mtp_device_task_helper.h +++ b/chrome/browser/media_galleries/linux/mtp_device_task_helper.h @@ -50,8 +50,7 @@ class MTPDeviceTaskHelper { void OpenStorage(const std::string& storage_name, const OpenStorageCallback& callback); - // Dispatches the GetFileInfoById request to the - // MediaTransferProtocolManager. + // Dispatches the GetFileInfo request to the MediaTransferProtocolManager. // // |file_id| specifies the id of the file whose details are requested. // @@ -60,10 +59,9 @@ class MTPDeviceTaskHelper { // // If there is an error, |error_callback| is invoked on the IO thread to // notify the caller about the file error. - void GetFileInfoById( - uint32 file_id, - const GetFileInfoSuccessCallback& success_callback, - const ErrorCallback& error_callback); + void GetFileInfo(uint32 file_id, + const GetFileInfoSuccessCallback& success_callback, + const ErrorCallback& error_callback); // Dispatches the read directory request to the MediaTransferProtocolManager. // @@ -77,9 +75,9 @@ class MTPDeviceTaskHelper { // // If there is an error, |error_callback| is invoked on the IO thread to // notify the caller about the file error. - void ReadDirectoryById(uint32 dir_id, - const ReadDirectorySuccessCallback& success_callback, - const ErrorCallback& error_callback); + void ReadDirectory(uint32 dir_id, + const ReadDirectorySuccessCallback& success_callback, + const ErrorCallback& error_callback); // Forwards the WriteDataIntoSnapshotFile request to the MTPReadFileWorker // object. @@ -126,7 +124,7 @@ class MTPDeviceTaskHelper { const MtpFileEntry& file_entry, bool error) const; - // Query callback for ReadDirectoryById(). + // Query callback for ReadDirectory(). // // If there is no error, |error| is set to false, |file_entries| has the // directory file entries and |success_callback| is invoked on the IO thread @@ -134,12 +132,11 @@ class MTPDeviceTaskHelper { // // If there is an error, |error| is set to true, |file_entries| is empty // and |error_callback| is invoked on the IO thread to notify the caller. - void OnDidReadDirectoryById( - const ReadDirectorySuccessCallback& success_callback, - const ErrorCallback& error_callback, - const std::vector<MtpFileEntry>& file_entries, - bool has_more, - bool error) const; + void OnDidReadDirectory(const ReadDirectorySuccessCallback& success_callback, + const ErrorCallback& error_callback, + const std::vector<MtpFileEntry>& file_entries, + bool has_more, + bool error) const; // Intermediate step to finish a ReadBytes request. void OnGetFileInfoToReadBytes( diff --git a/chrome/browser/media_galleries/linux/mtp_read_file_worker.cc b/chrome/browser/media_galleries/linux/mtp_read_file_worker.cc index e00a6c0b..4ab454b 100644 --- a/chrome/browser/media_galleries/linux/mtp_read_file_worker.cc +++ b/chrome/browser/media_galleries/linux/mtp_read_file_worker.cc @@ -66,7 +66,7 @@ void MTPReadFileWorker::ReadDataChunkFromDeviceFile( device::MediaTransferProtocolManager* mtp_device_manager = StorageMonitor::GetInstance()->media_transfer_protocol_manager(); - mtp_device_manager->ReadFileChunkById( + mtp_device_manager->ReadFileChunk( device_handle_, snapshot_file_details_ptr->file_id(), snapshot_file_details_ptr->bytes_written(), diff --git a/components/storage_monitor/test_media_transfer_protocol_manager_linux.cc b/components/storage_monitor/test_media_transfer_protocol_manager_linux.cc index 5b64375..42736db 100644 --- a/components/storage_monitor/test_media_transfer_protocol_manager_linux.cc +++ b/components/storage_monitor/test_media_transfer_protocol_manager_linux.cc @@ -41,7 +41,7 @@ void TestMediaTransferProtocolManagerLinux::CloseStorage( callback.Run(true); } -void TestMediaTransferProtocolManagerLinux::ReadDirectoryById( +void TestMediaTransferProtocolManagerLinux::ReadDirectory( const std::string& storage_handle, uint32 file_id, const ReadDirectoryCallback& callback) { @@ -50,7 +50,7 @@ void TestMediaTransferProtocolManagerLinux::ReadDirectoryById( true /* error */); } -void TestMediaTransferProtocolManagerLinux::ReadFileChunkById( +void TestMediaTransferProtocolManagerLinux::ReadFileChunk( const std::string& storage_handle, uint32 file_id, uint32 offset, @@ -59,7 +59,7 @@ void TestMediaTransferProtocolManagerLinux::ReadFileChunkById( callback.Run(std::string(), true); } -void TestMediaTransferProtocolManagerLinux::GetFileInfoById( +void TestMediaTransferProtocolManagerLinux::GetFileInfo( const std::string& storage_handle, uint32 file_id, const GetFileInfoCallback& callback) { diff --git a/components/storage_monitor/test_media_transfer_protocol_manager_linux.h b/components/storage_monitor/test_media_transfer_protocol_manager_linux.h index 9f1d93b..eae125a 100644 --- a/components/storage_monitor/test_media_transfer_protocol_manager_linux.h +++ b/components/storage_monitor/test_media_transfer_protocol_manager_linux.h @@ -28,18 +28,17 @@ class TestMediaTransferProtocolManagerLinux const OpenStorageCallback& callback) OVERRIDE; virtual void CloseStorage(const std::string& storage_handle, const CloseStorageCallback& callback) OVERRIDE; - virtual void ReadDirectoryById( - const std::string& storage_handle, - uint32 file_id, - const ReadDirectoryCallback& callback) OVERRIDE; - virtual void ReadFileChunkById(const std::string& storage_handle, - uint32 file_id, - uint32 offset, - uint32 count, - const ReadFileCallback& callback) OVERRIDE; - virtual void GetFileInfoById(const std::string& storage_handle, - uint32 file_id, - const GetFileInfoCallback& callback) OVERRIDE; + virtual void ReadDirectory(const std::string& storage_handle, + uint32 file_id, + const ReadDirectoryCallback& callback) OVERRIDE; + virtual void ReadFileChunk(const std::string& storage_handle, + uint32 file_id, + uint32 offset, + uint32 count, + const ReadFileCallback& callback) OVERRIDE; + virtual void GetFileInfo(const std::string& storage_handle, + uint32 file_id, + const GetFileInfoCallback& callback) OVERRIDE; DISALLOW_COPY_AND_ASSIGN(TestMediaTransferProtocolManagerLinux); }; diff --git a/device/media_transfer_protocol/media_transfer_protocol_daemon_client.cc b/device/media_transfer_protocol/media_transfer_protocol_daemon_client.cc index f4e855c..5639169 100644 --- a/device/media_transfer_protocol/media_transfer_protocol_daemon_client.cc +++ b/device/media_transfer_protocol/media_transfer_protocol_daemon_client.cc @@ -151,15 +151,14 @@ class MediaTransferProtocolDaemonClientImpl } // MediaTransferProtocolDaemonClient override. - virtual void ReadFileChunkById(const std::string& handle, - uint32 file_id, - uint32 offset, - uint32 bytes_to_read, - const ReadFileCallback& callback, - const ErrorCallback& error_callback) OVERRIDE { + virtual void ReadFileChunk(const std::string& handle, + uint32 file_id, + uint32 offset, + uint32 bytes_to_read, + const ReadFileCallback& callback, + const ErrorCallback& error_callback) OVERRIDE { DCHECK_LE(bytes_to_read, kMaxChunkSize); - dbus::MethodCall method_call(mtpd::kMtpdInterface, - mtpd::kReadFileChunkById); + dbus::MethodCall method_call(mtpd::kMtpdInterface, mtpd::kReadFileChunk); dbus::MessageWriter writer(&method_call); writer.AppendString(handle); writer.AppendUint32(file_id); @@ -331,7 +330,7 @@ class MediaTransferProtocolDaemonClientImpl callback.Run(file_entries); } - // Handles the result of ReadFileChunkById and calls |callback| or + // Handles the result of ReadFileChunk and calls |callback| or // |error_callback|. void OnReadFile(const ReadFileCallback& callback, const ErrorCallback& error_callback, diff --git a/device/media_transfer_protocol/media_transfer_protocol_daemon_client.h b/device/media_transfer_protocol/media_transfer_protocol_daemon_client.h index 2ea92d8..b051e6c 100644 --- a/device/media_transfer_protocol/media_transfer_protocol_daemon_client.h +++ b/device/media_transfer_protocol/media_transfer_protocol_daemon_client.h @@ -125,17 +125,17 @@ class MediaTransferProtocolDaemonClient { const GetFileInfoCallback& callback, const ErrorCallback& error_callback) = 0; - // TODO(thestig): Rename to ReadFileChunk. - // Calls ReadFilePathById method. |callback| is called after the method call + // Calls ReadFileChunk method. |callback| is called after the method call // succeeds, otherwise, |error_callback| is called. // |file_id| is a MTP-device specific id for a file. + // |offset| is the offset into the file. // |bytes_to_read| cannot exceed 1 MiB. - virtual void ReadFileChunkById(const std::string& handle, - uint32 file_id, - uint32 offset, - uint32 bytes_to_read, - const ReadFileCallback& callback, - const ErrorCallback& error_callback) = 0; + virtual void ReadFileChunk(const std::string& handle, + uint32 file_id, + uint32 offset, + uint32 bytes_to_read, + const ReadFileCallback& callback, + const ErrorCallback& error_callback) = 0; // Registers given callback for events. Should only be called once. // |storage_event_handler| is called when a mtp storage attach or detach diff --git a/device/media_transfer_protocol/media_transfer_protocol_manager.cc b/device/media_transfer_protocol/media_transfer_protocol_manager.cc index 8bff2d8..e923975 100644 --- a/device/media_transfer_protocol/media_transfer_protocol_manager.cc +++ b/device/media_transfer_protocol/media_transfer_protocol_manager.cc @@ -160,10 +160,9 @@ class MediaTransferProtocolManagerImpl : public MediaTransferProtocolManager { } // MediaTransferProtocolManager override. - virtual void ReadDirectoryById( - const std::string& storage_handle, - uint32 file_id, - const ReadDirectoryCallback& callback) OVERRIDE { + virtual void ReadDirectory(const std::string& storage_handle, + uint32 file_id, + const ReadDirectoryCallback& callback) OVERRIDE { DCHECK(thread_checker_.CalledOnValidThread()); if (!ContainsKey(handles_, storage_handle) || !mtp_client_) { callback.Run(std::vector<MtpFileEntry>(), @@ -183,18 +182,18 @@ class MediaTransferProtocolManagerImpl : public MediaTransferProtocolManager { } // MediaTransferProtocolManager override. - virtual void ReadFileChunkById(const std::string& storage_handle, - uint32 file_id, - uint32 offset, - uint32 count, - const ReadFileCallback& callback) OVERRIDE { + virtual void ReadFileChunk(const std::string& storage_handle, + uint32 file_id, + uint32 offset, + uint32 count, + const ReadFileCallback& callback) OVERRIDE { DCHECK(thread_checker_.CalledOnValidThread()); if (!ContainsKey(handles_, storage_handle) || !mtp_client_) { callback.Run(std::string(), true); return; } read_file_callbacks_.push(callback); - mtp_client_->ReadFileChunkById( + mtp_client_->ReadFileChunk( storage_handle, file_id, offset, count, base::Bind(&MediaTransferProtocolManagerImpl::OnReadFile, weak_ptr_factory_.GetWeakPtr()), @@ -202,9 +201,9 @@ class MediaTransferProtocolManagerImpl : public MediaTransferProtocolManager { weak_ptr_factory_.GetWeakPtr())); } - virtual void GetFileInfoById(const std::string& storage_handle, - uint32 file_id, - const GetFileInfoCallback& callback) OVERRIDE { + virtual void GetFileInfo(const std::string& storage_handle, + uint32 file_id, + const GetFileInfoCallback& callback) OVERRIDE { DCHECK(thread_checker_.CalledOnValidThread()); if (!ContainsKey(handles_, storage_handle) || !mtp_client_) { callback.Run(MtpFileEntry(), true); diff --git a/device/media_transfer_protocol/media_transfer_protocol_manager.h b/device/media_transfer_protocol/media_transfer_protocol_manager.h index 92c3d3d..7ff89e9 100644 --- a/device/media_transfer_protocol/media_transfer_protocol_manager.h +++ b/device/media_transfer_protocol/media_transfer_protocol_manager.h @@ -39,7 +39,7 @@ class MediaTransferProtocolManager { // The argument is true if there was an error. typedef base::Callback<void(bool error)> CloseStorageCallback; - // A callback to handle the result of ReadDirectoryById. + // A callback to handle the result of ReadDirectory. // The first argument is a vector of file entries. // The second argument is true if there are more file entries. // The third argument is true if there was an error. @@ -47,13 +47,13 @@ class MediaTransferProtocolManager { bool has_more, bool error)> ReadDirectoryCallback; - // A callback to handle the result of ReadFileChunkById. + // A callback to handle the result of ReadFileChunk. // The first argument is a string containing the file data. // The second argument is true if there was an error. typedef base::Callback<void(const std::string& data, bool error)> ReadFileCallback; - // A callback to handle the result of GetFileInfoById. + // A callback to handle the result of GetFileInfo. // The first argument is a file entry. // The second argument is true if there was an error. typedef base::Callback<void(const MtpFileEntry& file_entry, @@ -97,23 +97,23 @@ class MediaTransferProtocolManager { // Reads directory entries from |file_id| on |storage_handle| and runs // |callback|. - virtual void ReadDirectoryById(const std::string& storage_handle, - uint32 file_id, - const ReadDirectoryCallback& callback) = 0; + virtual void ReadDirectory(const std::string& storage_handle, + uint32 file_id, + const ReadDirectoryCallback& callback) = 0; // Reads file data from |file_id| on |storage_handle| and runs |callback|. // Reads |count| bytes of data starting at |offset|. - virtual void ReadFileChunkById(const std::string& storage_handle, - uint32 file_id, - uint32 offset, - uint32 count, - const ReadFileCallback& callback) = 0; + virtual void ReadFileChunk(const std::string& storage_handle, + uint32 file_id, + uint32 offset, + uint32 count, + const ReadFileCallback& callback) = 0; // Gets the file metadata for |file_id| on |storage_handle| and runs // |callback|. - virtual void GetFileInfoById(const std::string& storage_handle, - uint32 file_id, - const GetFileInfoCallback& callback) = 0; + virtual void GetFileInfo(const std::string& storage_handle, + uint32 file_id, + const GetFileInfoCallback& callback) = 0; // Creates and returns the global MediaTransferProtocolManager instance. // On Linux, |task_runner| specifies the task runner to process asynchronous |