1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_SYNCABLE_FILE_SYSTEM_OPERATION_H_
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_SYNCABLE_FILE_SYSTEM_OPERATION_H_
10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/threading/non_thread_safe.h"
15 #include "storage/browser/fileapi/file_system_operation.h"
16 #include "storage/browser/fileapi/file_system_url.h"
19 class FileSystemContext
;
20 class FileSystemOperationContext
;
23 namespace sync_file_system
{
25 class SyncableFileOperationRunner
;
27 // A wrapper class of FileSystemOperation for syncable file system.
28 class SyncableFileSystemOperation
29 : public NON_EXPORTED_BASE(storage::FileSystemOperation
),
30 public base::NonThreadSafe
{
32 ~SyncableFileSystemOperation() override
;
34 // storage::FileSystemOperation overrides.
35 void CreateFile(const storage::FileSystemURL
& url
,
37 const StatusCallback
& callback
) override
;
38 void CreateDirectory(const storage::FileSystemURL
& url
,
41 const StatusCallback
& callback
) override
;
42 void Copy(const storage::FileSystemURL
& src_url
,
43 const storage::FileSystemURL
& dest_url
,
44 CopyOrMoveOption option
,
45 const CopyProgressCallback
& progress_callback
,
46 const StatusCallback
& callback
) override
;
47 void Move(const storage::FileSystemURL
& src_url
,
48 const storage::FileSystemURL
& dest_url
,
49 CopyOrMoveOption option
,
50 const StatusCallback
& callback
) override
;
51 void DirectoryExists(const storage::FileSystemURL
& url
,
52 const StatusCallback
& callback
) override
;
53 void FileExists(const storage::FileSystemURL
& url
,
54 const StatusCallback
& callback
) override
;
55 void GetMetadata(const storage::FileSystemURL
& url
,
56 const GetMetadataCallback
& callback
) override
;
57 void ReadDirectory(const storage::FileSystemURL
& url
,
58 const ReadDirectoryCallback
& callback
) override
;
59 void Remove(const storage::FileSystemURL
& url
,
61 const StatusCallback
& callback
) override
;
62 void Write(const storage::FileSystemURL
& url
,
63 scoped_ptr
<storage::FileWriterDelegate
> writer_delegate
,
64 scoped_ptr
<net::URLRequest
> blob_request
,
65 const WriteCallback
& callback
) override
;
66 void Truncate(const storage::FileSystemURL
& url
,
68 const StatusCallback
& callback
) override
;
69 void TouchFile(const storage::FileSystemURL
& url
,
70 const base::Time
& last_access_time
,
71 const base::Time
& last_modified_time
,
72 const StatusCallback
& callback
) override
;
73 void OpenFile(const storage::FileSystemURL
& url
,
75 const OpenFileCallback
& callback
) override
;
76 void Cancel(const StatusCallback
& cancel_callback
) override
;
77 void CreateSnapshotFile(const storage::FileSystemURL
& path
,
78 const SnapshotFileCallback
& callback
) override
;
79 void CopyInForeignFile(const base::FilePath
& src_local_disk_path
,
80 const storage::FileSystemURL
& dest_url
,
81 const StatusCallback
& callback
) override
;
82 void RemoveFile(const storage::FileSystemURL
& url
,
83 const StatusCallback
& callback
) override
;
84 void RemoveDirectory(const storage::FileSystemURL
& url
,
85 const StatusCallback
& callback
) override
;
86 void CopyFileLocal(const storage::FileSystemURL
& src_url
,
87 const storage::FileSystemURL
& dest_url
,
88 CopyOrMoveOption option
,
89 const CopyFileProgressCallback
& progress_callback
,
90 const StatusCallback
& callback
) override
;
91 void MoveFileLocal(const storage::FileSystemURL
& src_url
,
92 const storage::FileSystemURL
& dest_url
,
93 CopyOrMoveOption option
,
94 const StatusCallback
& callback
) override
;
95 base::File::Error
SyncGetPlatformPath(const storage::FileSystemURL
& url
,
96 base::FilePath
* platform_path
) override
;
99 typedef SyncableFileSystemOperation self
;
102 // Only SyncFileSystemBackend can create a new operation directly.
103 friend class SyncFileSystemBackend
;
105 SyncableFileSystemOperation(
106 const storage::FileSystemURL
& url
,
107 storage::FileSystemContext
* file_system_context
,
108 scoped_ptr
<storage::FileSystemOperationContext
> operation_context
);
110 void DidFinish(base::File::Error status
);
111 void DidWrite(const WriteCallback
& callback
,
112 base::File::Error result
,
118 const storage::FileSystemURL url_
;
120 scoped_ptr
<storage::FileSystemOperation
> impl_
;
121 base::WeakPtr
<SyncableFileOperationRunner
> operation_runner_
;
122 std::vector
<storage::FileSystemURL
> target_paths_
;
124 StatusCallback completion_callback_
;
126 base::WeakPtrFactory
<SyncableFileSystemOperation
> weak_factory_
;
128 DISALLOW_COPY_AND_ASSIGN(SyncableFileSystemOperation
);
131 } // namespace sync_file_system
133 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_SYNCABLE_FILE_SYSTEM_OPERATION_H_