OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef WEBKIT_FILEAPI_SYNCABLE_CANNED_SYNCABLE_FILE_SYSTEM_H_ | 5 #ifndef WEBKIT_FILEAPI_SYNCABLE_CANNED_SYNCABLE_FILE_SYSTEM_H_ |
6 #define WEBKIT_FILEAPI_SYNCABLE_CANNED_SYNCABLE_FILE_SYSTEM_H_ | 6 #define WEBKIT_FILEAPI_SYNCABLE_CANNED_SYNCABLE_FILE_SYSTEM_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/platform_file.h" | 12 #include "base/platform_file.h" |
13 #include "base/scoped_temp_dir.h" | 13 #include "base/scoped_temp_dir.h" |
14 #include "webkit/fileapi/file_system_types.h" | 14 #include "webkit/fileapi/file_system_types.h" |
15 #include "webkit/fileapi/local_file_system_test_helper.h" | 15 #include "webkit/fileapi/local_file_system_test_helper.h" |
16 #include "webkit/fileapi/syncable/sync_status_code.h" | 16 #include "webkit/fileapi/syncable/sync_status_code.h" |
| 17 #include "webkit/quota/quota_types.h" |
17 | 18 |
18 namespace base { | 19 namespace base { |
19 class MessageLoopProxy; | 20 class MessageLoopProxy; |
20 class SingleThreadTaskRunner; | 21 class SingleThreadTaskRunner; |
21 class Thread; | 22 class Thread; |
22 } | 23 } |
23 | 24 |
24 namespace net { | 25 namespace net { |
25 class URLRequestContext; | 26 class URLRequestContext; |
26 } | 27 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 const FileSystemURL& dest_url); | 88 const FileSystemURL& dest_url); |
88 base::PlatformFileError TruncateFile(const FileSystemURL& url, int64 size); | 89 base::PlatformFileError TruncateFile(const FileSystemURL& url, int64 size); |
89 base::PlatformFileError Remove(const FileSystemURL& url, bool recursive); | 90 base::PlatformFileError Remove(const FileSystemURL& url, bool recursive); |
90 base::PlatformFileError FileExists(const FileSystemURL& url); | 91 base::PlatformFileError FileExists(const FileSystemURL& url); |
91 base::PlatformFileError DirectoryExists(const FileSystemURL& url); | 92 base::PlatformFileError DirectoryExists(const FileSystemURL& url); |
92 | 93 |
93 // Returns the # of bytes written (>=0) or an error code (<0). | 94 // Returns the # of bytes written (>=0) or an error code (<0). |
94 int64 Write(net::URLRequestContext* url_request_context, | 95 int64 Write(net::URLRequestContext* url_request_context, |
95 const FileSystemURL& url, const GURL& blob_url); | 96 const FileSystemURL& url, const GURL& blob_url); |
96 | 97 |
97 // Pruges the file system local storage. | 98 // Purges the file system local storage. |
98 base::PlatformFileError DeleteFileSystem(); | 99 base::PlatformFileError DeleteFileSystem(); |
99 | 100 |
| 101 // Retrieves the quota and usage. |
| 102 quota::QuotaStatusCode GetUsageAndQuota(int64* usage, int64* quota); |
| 103 |
100 // Returns new FileSystemOperation. | 104 // Returns new FileSystemOperation. |
101 FileSystemOperation* NewOperation(); | 105 FileSystemOperation* NewOperation(); |
102 | 106 |
103 private: | 107 private: |
104 // Operation methods body. | 108 // Operation methods body. |
105 void DoCreateDirectory(const FileSystemURL& url, | 109 void DoCreateDirectory(const FileSystemURL& url, |
106 const StatusCallback& callback); | 110 const StatusCallback& callback); |
107 void DoCreateFile(const FileSystemURL& url, | 111 void DoCreateFile(const FileSystemURL& url, |
108 const StatusCallback& callback); | 112 const StatusCallback& callback); |
109 void DoCopy(const FileSystemURL& src_url, | 113 void DoCopy(const FileSystemURL& src_url, |
110 const FileSystemURL& dest_url, | 114 const FileSystemURL& dest_url, |
111 const StatusCallback& callback); | 115 const StatusCallback& callback); |
112 void DoMove(const FileSystemURL& src_url, | 116 void DoMove(const FileSystemURL& src_url, |
113 const FileSystemURL& dest_url, | 117 const FileSystemURL& dest_url, |
114 const StatusCallback& callback); | 118 const StatusCallback& callback); |
115 void DoTruncateFile(const FileSystemURL& url, | 119 void DoTruncateFile(const FileSystemURL& url, |
116 int64 size, | 120 int64 size, |
117 const StatusCallback& callback); | 121 const StatusCallback& callback); |
118 void DoRemove(const FileSystemURL& url, | 122 void DoRemove(const FileSystemURL& url, |
119 bool recursive, | 123 bool recursive, |
120 const StatusCallback& callback); | 124 const StatusCallback& callback); |
121 void DoFileExists(const FileSystemURL& url, | 125 void DoFileExists(const FileSystemURL& url, |
122 const StatusCallback& callback); | 126 const StatusCallback& callback); |
123 void DoDirectoryExists(const FileSystemURL& url, | 127 void DoDirectoryExists(const FileSystemURL& url, |
124 const StatusCallback& callback); | 128 const StatusCallback& callback); |
125 void DoWrite(net::URLRequestContext* url_request_context, | 129 void DoWrite(net::URLRequestContext* url_request_context, |
126 const FileSystemURL& url, | 130 const FileSystemURL& url, |
127 const GURL& blob_url, | 131 const GURL& blob_url, |
128 const WriteCallback& callback); | 132 const WriteCallback& callback); |
| 133 void DoGetUsageAndQuota(int64* usage, |
| 134 int64* quota, |
| 135 const quota::StatusCallback& callback); |
129 | 136 |
130 // Callbacks. | 137 // Callbacks. |
131 void DidOpenFileSystem(base::PlatformFileError result, | 138 void DidOpenFileSystem(base::PlatformFileError result, |
132 const std::string& name, | 139 const std::string& name, |
133 const GURL& root); | 140 const GURL& root); |
134 void DidInitializeFileSystemContext(SyncStatusCode status); | 141 void DidInitializeFileSystemContext(SyncStatusCode status); |
135 | 142 |
136 ScopedTempDir data_dir_; | 143 ScopedTempDir data_dir_; |
137 const std::string service_name_; | 144 const std::string service_name_; |
138 | 145 |
139 scoped_refptr<quota::QuotaManager> quota_manager_; | 146 scoped_refptr<quota::QuotaManager> quota_manager_; |
140 scoped_refptr<FileSystemContext> file_system_context_; | 147 scoped_refptr<FileSystemContext> file_system_context_; |
141 LocalFileSystemTestOriginHelper test_helper_; | 148 LocalFileSystemTestOriginHelper test_helper_; |
142 GURL root_url_; | 149 GURL root_url_; |
143 base::PlatformFileError result_; | 150 base::PlatformFileError result_; |
144 SyncStatusCode sync_status_; | 151 SyncStatusCode sync_status_; |
145 | 152 |
146 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 153 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
147 | 154 |
148 // Boolean flags mainly for helping debug. | 155 // Boolean flags mainly for helping debug. |
149 bool is_filesystem_set_up_; | 156 bool is_filesystem_set_up_; |
150 bool is_filesystem_opened_; | 157 bool is_filesystem_opened_; |
151 | 158 |
152 DISALLOW_COPY_AND_ASSIGN(CannedSyncableFileSystem); | 159 DISALLOW_COPY_AND_ASSIGN(CannedSyncableFileSystem); |
153 }; | 160 }; |
154 | 161 |
155 } // namespace fileapi | 162 } // namespace fileapi |
156 | 163 |
157 #endif // WEBKIT_FILEAPI_SYNCABLE_CANNED_SYNCABLE_FILE_SYSTEM_H_ | 164 #endif // WEBKIT_FILEAPI_SYNCABLE_CANNED_SYNCABLE_FILE_SYSTEM_H_ |
OLD | NEW |