Skip to content

Commit

Permalink
Use default keyword for (con|de)structors in storage/browser/file_system
Browse files Browse the repository at this point in the history
Also migrates a few uses of the deprecated DISALLOW_COPY_AND_ASSIGN
macro.

Change-Id: I4ea0533c5c5c6e1c073b452649748177f50ca1d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2950929
Commit-Queue: Victor Costan <pwnall@chromium.org>
Reviewed-by: Victor Costan <pwnall@chromium.org>
Reviewed-by: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#892449}
  • Loading branch information
a-sully authored and Chromium LUCI CQ committed Jun 15, 2021
1 parent 8f10b00 commit 9de3358
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 50 deletions.
10 changes: 4 additions & 6 deletions storage/browser/file_system/async_file_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "base/callback_forward.h"
#include "base/component_export.h"
#include "base/files/file.h"
#include "base/macros.h"
#include "components/services/filesystem/public/mojom/types.mojom.h"
#include "storage/browser/file_system/file_system_operation.h"

Expand Down Expand Up @@ -85,8 +84,10 @@ class AsyncFileUtil {
COMPONENT_EXPORT(STORAGE_BROWSER)
static AsyncFileUtil* CreateForLocalFileSystem();

AsyncFileUtil() {}
virtual ~AsyncFileUtil() {}
AsyncFileUtil() = default;
AsyncFileUtil(const AsyncFileUtil&) = delete;
AsyncFileUtil& operator=(const AsyncFileUtil&) = delete;
virtual ~AsyncFileUtil() = default;

// Creates or opens a file with the given flags.
// If File::FLAG_CREATE is set in |file_flags| it always tries to create
Expand Down Expand Up @@ -350,9 +351,6 @@ class AsyncFileUtil {
std::unique_ptr<FileSystemOperationContext> context,
const FileSystemURL& url,
CreateSnapshotFileCallback callback) = 0;

private:
DISALLOW_COPY_AND_ASSIGN(AsyncFileUtil);
};

} // namespace storage
Expand Down
16 changes: 14 additions & 2 deletions storage/browser/file_system/copy_or_move_file_validator.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) CopyOrMoveFileValidator {
// base::File::FILE_OK means the file validated.
using ResultCallback = base::OnceCallback<void(base::File::Error result)>;

virtual ~CopyOrMoveFileValidator() {}
CopyOrMoveFileValidator(const CopyOrMoveFileValidator&) = delete;
CopyOrMoveFileValidator& operator=(const CopyOrMoveFileValidator&) = delete;
virtual ~CopyOrMoveFileValidator() = default;

// Called on a source file before copying or moving to the final
// destination.
Expand All @@ -34,18 +36,28 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) CopyOrMoveFileValidator {
virtual void StartPostWriteValidation(
const base::FilePath& dest_platform_path,
ResultCallback result_callback) = 0;

protected:
CopyOrMoveFileValidator() = default;
};

class CopyOrMoveFileValidatorFactory {
public:
virtual ~CopyOrMoveFileValidatorFactory() {}
CopyOrMoveFileValidatorFactory(const CopyOrMoveFileValidatorFactory&) =
delete;
CopyOrMoveFileValidatorFactory& operator=(
const CopyOrMoveFileValidatorFactory&) = delete;
virtual ~CopyOrMoveFileValidatorFactory() = default;

// This method must always return a non-null validator. |src_url| is needed
// in addition to |platform_path| because in the obfuscated file system
// case, |platform_path| will be an obfuscated filename and extension.
virtual CopyOrMoveFileValidator* CreateCopyOrMoveFileValidator(
const FileSystemURL& src_url,
const base::FilePath& platform_path) = 0;

protected:
CopyOrMoveFileValidatorFactory() = default;
};

} // namespace storage
Expand Down
28 changes: 12 additions & 16 deletions storage/browser/file_system/file_observers.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <stdint.h>

#include "base/component_export.h"
#include "base/macros.h"

// TODO(kinuko): Split this file into per-observer multiple files.

Expand All @@ -31,15 +30,14 @@ class FileSystemURL;
// sandboxed files (where usage is tracked).
class COMPONENT_EXPORT(STORAGE_BROWSER) FileUpdateObserver {
public:
FileUpdateObserver() {}
virtual ~FileUpdateObserver() {}
FileUpdateObserver() = default;
FileUpdateObserver(const FileUpdateObserver&) = delete;
FileUpdateObserver& operator=(const FileUpdateObserver&) = delete;
virtual ~FileUpdateObserver() = default;

virtual void OnStartUpdate(const FileSystemURL& url) = 0;
virtual void OnUpdate(const FileSystemURL& url, int64_t delta) = 0;
virtual void OnEndUpdate(const FileSystemURL& url) = 0;

private:
DISALLOW_COPY_AND_ASSIGN(FileUpdateObserver);
};

// An abstract interface to observe file access.
Expand All @@ -48,13 +46,12 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) FileUpdateObserver {
// is recursive or not)
class COMPONENT_EXPORT(STORAGE_BROWSER) FileAccessObserver {
public:
FileAccessObserver() {}
virtual ~FileAccessObserver() {}
FileAccessObserver() = default;
FileAccessObserver(const FileAccessObserver&) = delete;
FileAccessObserver& operator=(const FileAccessObserver&) = delete;
virtual ~FileAccessObserver() = default;

virtual void OnAccess(const FileSystemURL& url) = 0;

private:
DISALLOW_COPY_AND_ASSIGN(FileAccessObserver);
};

// An abstract interface to observe file changes.
Expand All @@ -64,8 +61,10 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) FileAccessObserver {
// by the local sandbox file system.
class COMPONENT_EXPORT(STORAGE_BROWSER) FileChangeObserver {
public:
FileChangeObserver() {}
virtual ~FileChangeObserver() {}
FileChangeObserver() = default;
FileChangeObserver(const FileChangeObserver&) = delete;
FileChangeObserver& operator=(const FileChangeObserver&) = delete;
virtual ~FileChangeObserver() = default;

virtual void OnCreateFile(const FileSystemURL& url) = 0;
virtual void OnCreateFileFrom(const FileSystemURL& url,
Expand All @@ -75,9 +74,6 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) FileChangeObserver {

virtual void OnCreateDirectory(const FileSystemURL& url) = 0;
virtual void OnRemoveDirectory(const FileSystemURL& url) = 0;

private:
DISALLOW_COPY_AND_ASSIGN(FileChangeObserver);
};

} // namespace storage
Expand Down
7 changes: 6 additions & 1 deletion storage/browser/file_system/file_stream_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ class FileStreamWriter {
int64_t initial_offset,
OpenOrCreate open_or_create);

FileStreamWriter(const FileStreamWriter&) = delete;
FileStreamWriter& operator=(const FileStreamWriter&) = delete;
// Closes the file. If there's an in-flight operation, it is canceled (i.e.,
// the callback function associated with the operation is not called).
virtual ~FileStreamWriter() {}
virtual ~FileStreamWriter() = default;

// Writes to the current cursor position asynchronously.
//
Expand Down Expand Up @@ -94,6 +96,9 @@ class FileStreamWriter {
//
// It is invalid to call Flush while there is an in-flight async operation.
virtual int Flush(net::CompletionOnceCallback callback) = 0;

protected:
FileStreamWriter() = default;
};

} // namespace storage
Expand Down
8 changes: 3 additions & 5 deletions storage/browser/file_system/file_system_file_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "base/component_export.h"
#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/macros.h"
#include "storage/browser/blob/scoped_file.h"
#include "storage/browser/file_system/file_system_operation.h"

Expand Down Expand Up @@ -59,6 +58,8 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) FileSystemFileUtil {
bool IsDirectory() override;
};

FileSystemFileUtil(const FileSystemFileUtil&) = delete;
FileSystemFileUtil& operator=(const FileSystemFileUtil&) = delete;
virtual ~FileSystemFileUtil() = default;

// Creates or opens a file with the given flags.
Expand Down Expand Up @@ -176,10 +177,7 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) FileSystemFileUtil {
base::FilePath* platform_path) = 0;

protected:
FileSystemFileUtil() {}

private:
DISALLOW_COPY_AND_ASSIGN(FileSystemFileUtil);
FileSystemFileUtil() = default;
};

} // namespace storage
Expand Down
6 changes: 5 additions & 1 deletion storage/browser/file_system/file_system_operation.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ class FileSystemOperation {
FileSystemContext* file_system_context,
std::unique_ptr<FileSystemOperationContext> operation_context);

virtual ~FileSystemOperation() {}
FileSystemOperation(const FileSystemOperation&) = delete;
FileSystemOperation& operator=(const FileSystemOperation&) = delete;
virtual ~FileSystemOperation() = default;

// Used for CreateFile(), etc. |result| is the return code of the operation.
using StatusCallback = base::OnceCallback<void(base::File::Error result)>;
Expand Down Expand Up @@ -546,6 +548,8 @@ class FileSystemOperation {
kOperationGetLocalPath,
kOperationCancel,
};

FileSystemOperation() = default;
};

} // namespace storage
Expand Down
10 changes: 4 additions & 6 deletions storage/browser/file_system/mount_points.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include "base/component_export.h"
#include "base/files/file_path.h"
#include "base/macros.h"
#include "storage/common/file_system/file_system_util.h"

class GURL;
Expand Down Expand Up @@ -43,8 +42,10 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) MountPoints {
}
};

MountPoints() {}
virtual ~MountPoints() {}
MountPoints() = default;
MountPoints(const MountPoints&) = delete;
MountPoints& operator=(const MountPoints&) = delete;
virtual ~MountPoints() = default;

// Revokes a mount point identified by |mount_name|.
// Returns false if the |mount_name| is not (no longer) registered.
Expand Down Expand Up @@ -98,9 +99,6 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) MountPoints {
// instantiated as the FileSystemURL class. This is internally used for nested
// URL cracking in FileSystemContext.
virtual FileSystemURL CrackFileSystemURL(const FileSystemURL& url) const = 0;

private:
DISALLOW_COPY_AND_ASSIGN(MountPoints);
};

} // namespace storage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

namespace storage {

ObfuscatedFileUtilDiskDelegate::ObfuscatedFileUtilDiskDelegate() {}
ObfuscatedFileUtilDiskDelegate::ObfuscatedFileUtilDiskDelegate() = default;

ObfuscatedFileUtilDiskDelegate::~ObfuscatedFileUtilDiskDelegate() {}
ObfuscatedFileUtilDiskDelegate::~ObfuscatedFileUtilDiskDelegate() = default;

bool ObfuscatedFileUtilDiskDelegate::DirectoryExists(
const base::FilePath& path) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) ObfuscatedFileUtilDiskDelegate
: public ObfuscatedFileUtilDelegate {
public:
ObfuscatedFileUtilDiskDelegate();
ObfuscatedFileUtilDiskDelegate(const ObfuscatedFileUtilDiskDelegate&) =
delete;
ObfuscatedFileUtilDiskDelegate& operator=(
const ObfuscatedFileUtilDiskDelegate&) = delete;
~ObfuscatedFileUtilDiskDelegate() override;

bool DirectoryExists(const base::FilePath& path) override;
Expand Down Expand Up @@ -55,8 +59,6 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) ObfuscatedFileUtilDiskDelegate
FileSystemOperation::CopyOrMoveOption option,
NativeFileUtil::CopyOrMoveMode mode) override;
base::File::Error DeleteFile(const base::FilePath& path) override;

DISALLOW_COPY_AND_ASSIGN(ObfuscatedFileUtilDiskDelegate);
};

} // namespace storage
Expand Down
14 changes: 10 additions & 4 deletions storage/browser/file_system/sandbox_file_system_backend_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include "base/component_export.h"
#include "base/files/file_path.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/threading/thread_checker.h"
Expand Down Expand Up @@ -74,14 +73,19 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) SandboxFileSystemBackendDelegate
// An instance of this interface is assumed to be called on the file thread.
class OriginEnumerator {
public:
virtual ~OriginEnumerator() {}
OriginEnumerator(const OriginEnumerator&) = delete;
OriginEnumerator& operator=(const OriginEnumerator&) = delete;
virtual ~OriginEnumerator() = default;

// Returns the next origin. Returns absl::nullopt if there are no more
// origins.
virtual absl::optional<url::Origin> Next() = 0;

// Returns the current origin's information.
virtual bool HasFileSystemType(FileSystemType type) const = 0;

protected:
OriginEnumerator() = default;
};

// Returns the type directory name in sandbox directory for given |type|.
Expand All @@ -95,6 +99,10 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) SandboxFileSystemBackendDelegate
const FileSystemOptions& file_system_options,
leveldb::Env* env_override);

SandboxFileSystemBackendDelegate(const SandboxFileSystemBackendDelegate&) =
delete;
SandboxFileSystemBackendDelegate& operator=(
const SandboxFileSystemBackendDelegate&) = delete;
~SandboxFileSystemBackendDelegate() override;

// Returns an origin enumerator of sandbox filesystem.
Expand Down Expand Up @@ -266,8 +274,6 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) SandboxFileSystemBackendDelegate
base::Time next_release_time_for_open_filesystem_stat_;

base::WeakPtrFactory<SandboxFileSystemBackendDelegate> weak_factory_{this};

DISALLOW_COPY_AND_ASSIGN(SandboxFileSystemBackendDelegate);
};

} // namespace storage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) SandboxOriginDatabaseInterface {
~OriginRecord();
};

virtual ~SandboxOriginDatabaseInterface() {}
SandboxOriginDatabaseInterface(const SandboxOriginDatabaseInterface&) =
delete;
SandboxOriginDatabaseInterface& operator=(
const SandboxOriginDatabaseInterface&) = delete;
virtual ~SandboxOriginDatabaseInterface() = default;

// Returns true if the origin's path is included in this database.
virtual bool HasOriginPath(const std::string& origin) = 0;
Expand All @@ -50,7 +54,7 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) SandboxOriginDatabaseInterface {
virtual void RewriteDatabase() = 0;

protected:
SandboxOriginDatabaseInterface() {}
SandboxOriginDatabaseInterface() = default;
};

} // namespace storage
Expand Down
7 changes: 5 additions & 2 deletions storage/browser/file_system/task_runner_bound_observer_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@ class TaskRunnerBoundObserverList {
std::map<Observer*, scoped_refptr<base::SequencedTaskRunner>>;

// Creates an empty list.
TaskRunnerBoundObserverList() {}
TaskRunnerBoundObserverList() = default;

// Creates a new list with given |observers|.
explicit TaskRunnerBoundObserverList(const ObserversListMap& observers)
: observers_(observers) {}

virtual ~TaskRunnerBoundObserverList() {}
TaskRunnerBoundObserverList(const TaskRunnerBoundObserverList&) = default;
TaskRunnerBoundObserverList& operator=(const TaskRunnerBoundObserverList&) =
default;
virtual ~TaskRunnerBoundObserverList() = default;

// Returns a new observer list with given observer.
// It is valid to give nullptr as |runner_to_notify|, and in that case
Expand Down
7 changes: 6 additions & 1 deletion storage/browser/file_system/watcher_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ class WatcherManager {
using NotificationCallback =
base::RepeatingCallback<void(ChangeType change_type)>;

virtual ~WatcherManager() {}
WatcherManager(const WatcherManager&) = delete;
WatcherManager& operator=(const WatcherManager&) = delete;
virtual ~WatcherManager() = default;

// Adds an entry watcher. If the |recursive| mode is not supported then
// FILE_ERROR_INVALID_OPERATION must be returned as an error. If the |url| is
Expand All @@ -50,6 +52,9 @@ class WatcherManager {
virtual void RemoveWatcher(const FileSystemURL& url,
bool recursive,
StatusCallback callback) = 0;

protected:
WatcherManager() = default;
};

} // namespace storage
Expand Down

0 comments on commit 9de3358

Please sign in to comment.