1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_CHROMEOS_FILEAPI_REMOTE_FILE_SYSTEM_PROXY_H_
#define WEBKIT_CHROMEOS_FILEAPI_REMOTE_FILE_SYSTEM_PROXY_H_
#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "webkit/fileapi/file_system_operation.h"
namespace fileapi {
typedef base::Callback<
void(base::PlatformFileError result,
const base::FilePath& platform_path,
const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref)>
WritableSnapshotFile;
// The interface class for remote file system proxy.
class RemoteFileSystemProxyInterface :
public base::RefCountedThreadSafe<RemoteFileSystemProxyInterface> {
public:
// Gets the file or directory info for given|path|.
virtual void GetFileInfo(const FileSystemURL& url,
const FileSystemOperation::GetMetadataCallback& callback) = 0;
// Copies a file or directory from |src_url| to |dest_url|. If
// |src_url| is a directory, the contents of |src_url| are copied to
// |dest_url| recursively. A new file or directory is created at
// |dest_url| as needed.
virtual void Copy(
const FileSystemURL& src_url,
const FileSystemURL& dest_url,
const FileSystemOperation::StatusCallback& callback) = 0;
// Moves a file or directory from |src_url| to |dest_url|. A new file
// or directory is created at |dest_url| as needed.
virtual void Move(
const FileSystemURL& src_url,
const FileSystemURL& dest_url,
const FileSystemOperation::StatusCallback& callback) = 0;
// Reads contents of a directory at |url|.
virtual void ReadDirectory(const FileSystemURL& url,
const FileSystemOperation::ReadDirectoryCallback& callback) = 0;
// Removes a file or directory at |url|. If |recursive| is true, remove
// all files and directories under the directory at |url| recursively.
virtual void Remove(const FileSystemURL& url, bool recursive,
const FileSystemOperation::StatusCallback& callback) = 0;
// Creates a directory at |url|. If |exclusive| is true, an error is
// raised in case a directory is already present at the URL. If
// |recursive| is true, create parent directories as needed just like
// mkdir -p does.
virtual void CreateDirectory(
const FileSystemURL& url,
bool exclusive,
bool recursive,
const FileSystemOperation::StatusCallback& callback) = 0;
// Creates a file at |url|. If the flag |is_exclusive| is true, an
// error is raised when a file already exists at the path. It is
// an error if a directory or a hosted document is already present at the
// path, or the parent directory of the path is not present yet.
virtual void CreateFile(
const FileSystemURL& url,
bool exclusive,
const FileSystemOperation::StatusCallback& callback) = 0;
// Changes the length of an existing file at |url| to |length|. If |length|
// is negative, an error is raised. If |length| is more than the current size
// of the file, zero is padded for the extended part.
virtual void Truncate(
const FileSystemURL& url,
int64 length,
const FileSystemOperation::StatusCallback& callback) = 0;
// Creates a local snapshot file for a given |url| and returns the
// metadata and platform path of the snapshot file via |callback|.
// See also FileSystemOperation::CreateSnapshotFile().
virtual void CreateSnapshotFile(
const FileSystemURL& url,
const FileSystemOperation::SnapshotFileCallback& callback) = 0;
// Creates a local snapshot file for a given |url| and marks it for
// modification. A webkit_blob::ShareableFileReference is passed to
// |callback|, and when the reference is released, modification to the
// snapshot is marked for uploading to the remote file system.
virtual void CreateWritableSnapshotFile(
const FileSystemURL& url,
const WritableSnapshotFile& callback) = 0;
// Opens file for a given |url| with specified |flags| (see
// base::PlatformFileFlags for details).
virtual void OpenFile(
const FileSystemURL& url,
int flags,
base::ProcessHandle peer_handle,
const FileSystemOperation::OpenFileCallback& callback) = 0;
// Notifies that a file opened by OpenFile (at |path|) is closed.
virtual void NotifyCloseFile(const FileSystemURL& url) = 0;
// Modifies the timestamp of a given |url| to |last_access_time| and
// |last_modified_time|. Note that unlike 'touch' command of Linux, it
// does not create a new file.
virtual void TouchFile(
const fileapi::FileSystemURL& url,
const base::Time& last_access_time,
const base::Time& last_modified_time,
const FileSystemOperation::StatusCallback& callback) = 0;
protected:
friend class base::RefCountedThreadSafe<RemoteFileSystemProxyInterface>;
virtual ~RemoteFileSystemProxyInterface() {}
};
} // namespace fileapi
#endif // WEBKIT_CHROMEOS_FILEAPI_REMOTE_FILE_SYSTEM_PROXY_H_
|