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
|
// Copyright (c) 2013 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_FILEAPI_ASYNC_FILE_UTIL_ADAPTER_H_
#define WEBKIT_FILEAPI_ASYNC_FILE_UTIL_ADAPTER_H_
#include "base/memory/scoped_ptr.h"
#include "webkit/fileapi/async_file_util.h"
namespace fileapi {
class FileSystemFileUtil;
// An adapter class for FileSystemFileUtil classes to provide asynchronous
// interface.
//
// A filesystem can do either:
// - implement a synchronous version of FileUtil by extending
// FileSystemFileUtil and atach it to this adapter, or
// - directly implement AsyncFileUtil.
//
class WEBKIT_STORAGE_EXPORT_PRIVATE AsyncFileUtilAdapter
: public AsyncFileUtil {
public:
// Creates a new AsyncFileUtil for |sync_file_util|. This takes the
// ownership of |sync_file_util|. (This doesn't take scoped_ptr<> just
// to save extra make_scoped_ptr; in all use cases a new fresh FileUtil is
// created only for this adapter.)
explicit AsyncFileUtilAdapter(FileSystemFileUtil* sync_file_util);
virtual ~AsyncFileUtilAdapter();
FileSystemFileUtil* sync_file_util() {
return sync_file_util_.get();
}
// AsyncFileUtil overrides.
virtual bool CreateOrOpen(
FileSystemOperationContext* context,
const FileSystemURL& url,
int file_flags,
const CreateOrOpenCallback& callback) OVERRIDE;
virtual bool EnsureFileExists(
FileSystemOperationContext* context,
const FileSystemURL& url,
const EnsureFileExistsCallback& callback) OVERRIDE;
virtual bool CreateDirectory(
FileSystemOperationContext* context,
const FileSystemURL& url,
bool exclusive,
bool recursive,
const StatusCallback& callback) OVERRIDE;
virtual bool GetFileInfo(
FileSystemOperationContext* context,
const FileSystemURL& url,
const GetFileInfoCallback& callback) OVERRIDE;
virtual bool ReadDirectory(
FileSystemOperationContext* context,
const FileSystemURL& url,
const ReadDirectoryCallback& callback) OVERRIDE;
virtual bool Touch(
FileSystemOperationContext* context,
const FileSystemURL& url,
const base::Time& last_access_time,
const base::Time& last_modified_time,
const StatusCallback& callback) OVERRIDE;
virtual bool Truncate(
FileSystemOperationContext* context,
const FileSystemURL& url,
int64 length,
const StatusCallback& callback) OVERRIDE;
virtual bool CopyFileLocal(
FileSystemOperationContext* context,
const FileSystemURL& src_url,
const FileSystemURL& dest_url,
const StatusCallback& callback) OVERRIDE;
virtual bool MoveFileLocal(
FileSystemOperationContext* context,
const FileSystemURL& src_url,
const FileSystemURL& dest_url,
const StatusCallback& callback) OVERRIDE;
virtual bool CopyInForeignFile(
FileSystemOperationContext* context,
const base::FilePath& src_file_path,
const FileSystemURL& dest_url,
const StatusCallback& callback) OVERRIDE;
virtual bool DeleteFile(
FileSystemOperationContext* context,
const FileSystemURL& url,
const StatusCallback& callback) OVERRIDE;
virtual bool DeleteDirectory(
FileSystemOperationContext* context,
const FileSystemURL& url,
const StatusCallback& callback) OVERRIDE;
virtual bool CreateSnapshotFile(
FileSystemOperationContext* context,
const FileSystemURL& url,
const CreateSnapshotFileCallback& callback) OVERRIDE;
private:
scoped_ptr<FileSystemFileUtil> sync_file_util_;
DISALLOW_COPY_AND_ASSIGN(AsyncFileUtilAdapter);
};
} // namespace fileapi
#endif // WEBKIT_FILEAPI_ASYNC_FILE_UTIL_ADAPTER_H_
|