Commit 3a3f50f6 authored by Xida Chen's avatar Xida Chen Committed by Chromium LUCI CQ

[Code health] Convert CreateSnapshotFileSuccessCallback to RepeatingCallback

It seems that this needs to be a RepeatingCallback instead of
a OnceCallback. Because at the:
chrome/browser/media_galleries/win/snapshot_file_details.h,
this callback is used by SnapshotRequestInfo which is then owned
by SnapshotFileDetails. The SnapshotFileDetails need to have
const access to the SnapshotRequestInfo and hence the callback
cannot be a OnceCallback.

This is a code health CL, no behaviour change is expected.

Bug: 1152278
Change-Id: Ia5eb65521cf100c38b47ae288daa41e2e432e897
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2595928
Commit-Queue: Xida Chen <xidachen@chromium.org>
Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#838185}
parent cde1ea27
...@@ -1338,8 +1338,9 @@ void MTPDeviceDelegateImplLinux::WriteDataIntoSnapshotFile( ...@@ -1338,8 +1338,9 @@ void MTPDeviceDelegateImplLinux::WriteDataIntoSnapshotFile(
SnapshotRequestInfo request_info( SnapshotRequestInfo request_info(
current_snapshot_request_info_->file_id, current_snapshot_request_info_->file_id,
current_snapshot_request_info_->snapshot_file_path, current_snapshot_request_info_->snapshot_file_path,
base::Bind(&MTPDeviceDelegateImplLinux::OnDidWriteDataIntoSnapshotFile, base::BindRepeating(
weak_ptr_factory_.GetWeakPtr()), &MTPDeviceDelegateImplLinux::OnDidWriteDataIntoSnapshotFile,
weak_ptr_factory_.GetWeakPtr()),
base::BindRepeating( base::BindRepeating(
&MTPDeviceDelegateImplLinux::OnWriteDataIntoSnapshotFileError, &MTPDeviceDelegateImplLinux::OnWriteDataIntoSnapshotFileError,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
...@@ -1677,7 +1678,7 @@ void MTPDeviceDelegateImplLinux::OnDidCreateTemporaryFileToCopyFileLocal( ...@@ -1677,7 +1678,7 @@ void MTPDeviceDelegateImplLinux::OnDidCreateTemporaryFileToCopyFileLocal(
CreateSnapshotFile( CreateSnapshotFile(
source_file_path, temporary_file_path, source_file_path, temporary_file_path,
base::Bind( base::BindRepeating(
&MTPDeviceDelegateImplLinux::OnDidCreateSnapshotFileOfCopyFileLocal, &MTPDeviceDelegateImplLinux::OnDidCreateSnapshotFileOfCopyFileLocal,
weak_ptr_factory_.GetWeakPtr(), device_file_path, progress_callback, weak_ptr_factory_.GetWeakPtr(), device_file_path, progress_callback,
success_callback, error_callback), success_callback, error_callback),
......
...@@ -222,9 +222,9 @@ void OnSnapshotFileCreatedRunTask( ...@@ -222,9 +222,9 @@ void OnSnapshotFileCreatedRunTask(
delegate->CreateSnapshotFile( delegate->CreateSnapshotFile(
url.path(), // device file path url.path(), // device file path
snapshot_file_path, snapshot_file_path,
base::Bind(&OnDidCreateSnapshotFile, copyable_callback, base::BindRepeating(&OnDidCreateSnapshotFile, copyable_callback,
base::RetainedRef(context->task_runner()), base::RetainedRef(context->task_runner()),
validate_media_files), validate_media_files),
base::BindRepeating(&OnCreateSnapshotFileError, copyable_callback)); base::BindRepeating(&OnCreateSnapshotFileError, copyable_callback));
} }
......
...@@ -46,9 +46,12 @@ class MTPDeviceAsyncDelegate { ...@@ -46,9 +46,12 @@ class MTPDeviceAsyncDelegate {
typedef base::RepeatingCallback<void(base::File::Error error)> ErrorCallback; typedef base::RepeatingCallback<void(base::File::Error error)> ErrorCallback;
// A callback to be called when CreateSnapshotFile method call succeeds. // A callback to be called when CreateSnapshotFile method call succeeds.
typedef base::Callback< // TODO: consider make this a OnceCallback. Right now it is repeating because
void(const base::File::Info& file_info, // it is used in SnapshotRequestInfo, which is owned by SnapshotFileDetails,
const base::FilePath& local_path)> CreateSnapshotFileSuccessCallback; // and SnapshotFileDetails needs const access to SnapshotRequestInfo.
typedef base::RepeatingCallback<void(const base::File::Info& file_info,
const base::FilePath& local_path)>
CreateSnapshotFileSuccessCallback;
// A callback to be called when ReadBytes method call succeeds. // A callback to be called when ReadBytes method call succeeds.
typedef base::Callback< typedef base::Callback<
......
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