Fix Win8 metro startup crash from window switcher button
[chromium-blink-merge.git] / webkit / fileapi / async_file_util_adapter.h
blob065354d4b6fcf5fa65ca1d585e32e05c13f35ed4
1 // Copyright (c) 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 WEBKIT_FILEAPI_ASYNC_FILE_UTIL_ADAPTER_H_
6 #define WEBKIT_FILEAPI_ASYNC_FILE_UTIL_ADAPTER_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "webkit/fileapi/async_file_util.h"
11 namespace fileapi {
13 class FileSystemFileUtil;
15 // An adapter class for FileSystemFileUtil classes to provide asynchronous
16 // interface.
18 // A filesystem can do either:
19 // - implement a synchronous version of FileUtil by extending
20 // FileSystemFileUtil and atach it to this adapter, or
21 // - directly implement AsyncFileUtil.
23 class WEBKIT_STORAGE_EXPORT_PRIVATE AsyncFileUtilAdapter
24 : public AsyncFileUtil {
25 public:
26 // Creates a new AsyncFileUtil for |sync_file_util|. This takes the
27 // ownership of |sync_file_util|. (This doesn't take scoped_ptr<> just
28 // to save extra make_scoped_ptr; in all use cases a new fresh FileUtil is
29 // created only for this adapter.)
30 explicit AsyncFileUtilAdapter(FileSystemFileUtil* sync_file_util);
32 virtual ~AsyncFileUtilAdapter();
34 FileSystemFileUtil* sync_file_util() {
35 return sync_file_util_.get();
38 // AsyncFileUtil overrides.
39 virtual bool CreateOrOpen(
40 FileSystemOperationContext* context,
41 const FileSystemURL& url,
42 int file_flags,
43 const CreateOrOpenCallback& callback) OVERRIDE;
44 virtual bool EnsureFileExists(
45 FileSystemOperationContext* context,
46 const FileSystemURL& url,
47 const EnsureFileExistsCallback& callback) OVERRIDE;
48 virtual bool CreateDirectory(
49 FileSystemOperationContext* context,
50 const FileSystemURL& url,
51 bool exclusive,
52 bool recursive,
53 const StatusCallback& callback) OVERRIDE;
54 virtual bool GetFileInfo(
55 FileSystemOperationContext* context,
56 const FileSystemURL& url,
57 const GetFileInfoCallback& callback) OVERRIDE;
58 virtual bool ReadDirectory(
59 FileSystemOperationContext* context,
60 const FileSystemURL& url,
61 const ReadDirectoryCallback& callback) OVERRIDE;
62 virtual bool Touch(
63 FileSystemOperationContext* context,
64 const FileSystemURL& url,
65 const base::Time& last_access_time,
66 const base::Time& last_modified_time,
67 const StatusCallback& callback) OVERRIDE;
68 virtual bool Truncate(
69 FileSystemOperationContext* context,
70 const FileSystemURL& url,
71 int64 length,
72 const StatusCallback& callback) OVERRIDE;
73 virtual bool CopyFileLocal(
74 FileSystemOperationContext* context,
75 const FileSystemURL& src_url,
76 const FileSystemURL& dest_url,
77 const StatusCallback& callback) OVERRIDE;
78 virtual bool MoveFileLocal(
79 FileSystemOperationContext* context,
80 const FileSystemURL& src_url,
81 const FileSystemURL& dest_url,
82 const StatusCallback& callback) OVERRIDE;
83 virtual bool CopyInForeignFile(
84 FileSystemOperationContext* context,
85 const base::FilePath& src_file_path,
86 const FileSystemURL& dest_url,
87 const StatusCallback& callback) OVERRIDE;
88 virtual bool DeleteFile(
89 FileSystemOperationContext* context,
90 const FileSystemURL& url,
91 const StatusCallback& callback) OVERRIDE;
92 virtual bool DeleteDirectory(
93 FileSystemOperationContext* context,
94 const FileSystemURL& url,
95 const StatusCallback& callback) OVERRIDE;
96 virtual bool CreateSnapshotFile(
97 FileSystemOperationContext* context,
98 const FileSystemURL& url,
99 const CreateSnapshotFileCallback& callback) OVERRIDE;
101 private:
102 scoped_ptr<FileSystemFileUtil> sync_file_util_;
104 DISALLOW_COPY_AND_ASSIGN(AsyncFileUtilAdapter);
107 } // namespace fileapi
109 #endif // WEBKIT_FILEAPI_ASYNC_FILE_UTIL_ADAPTER_H_