OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // This file provides the core implementation of fileapi methods. | 5 // This file provides the core implementation of fileapi methods. |
6 // The functions should be called on UI thread. | 6 // The functions should be called on UI thread. |
7 // Note that most method invocation of fileapi is done on IO thread. The gap is | 7 // Note that most method invocation of fileapi is done on IO thread. The gap is |
8 // filled by FileSystemProxy. | 8 // filled by FileSystemProxy. |
9 // Also, the order of arguments for the functions which take FileSystemInterface | 9 // Also, the order of arguments for the functions which take FileSystemInterface |
10 // at the last is intentional. The instance of FileSystemInterface should be | 10 // at the last is intentional. The instance of FileSystemInterface should be |
11 // accessible only on UI thread, but arguments are passed on IO thread. | 11 // accessible only on UI thread, but arguments are passed on IO thread. |
12 // So, here is an intended use case: | 12 // So, here is an intended use case: |
13 // 1) Bind arguments on IO thread. Then a callback instance whose type is | 13 // 1) Bind arguments on IO thread. Then a callback instance whose type is |
14 // Callback<void(FileSysstemInterface*)> is created. | 14 // Callback<void(FileSysstemInterface*)> is created. |
15 // 2) Post the task to the UI thread. | 15 // 2) Post the task to the UI thread. |
16 // 3) On UI thread, check if the instance of FileSystemInterface is alive or | 16 // 3) On UI thread, check if the instance of FileSystemInterface is alive or |
17 // not. If yes, Run the callback with it. | 17 // not. If yes, Run the callback with it. |
18 | 18 |
19 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILEAPI_FILEAPI_WORKER_H_ | 19 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILEAPI_FILEAPI_WORKER_H_ |
20 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILEAPI_FILEAPI_WORKER_H_ | 20 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILEAPI_FILEAPI_WORKER_H_ |
21 | 21 |
| 22 #include <stdint.h> |
| 23 |
22 #include <vector> | 24 #include <vector> |
23 | 25 |
24 #include "base/basictypes.h" | |
25 #include "base/callback_forward.h" | 26 #include "base/callback_forward.h" |
26 #include "base/memory/weak_ptr.h" | 27 #include "base/memory/weak_ptr.h" |
27 #include "components/drive/file_errors.h" | 28 #include "components/drive/file_errors.h" |
28 #include "storage/browser/blob/scoped_file.h" | 29 #include "storage/browser/blob/scoped_file.h" |
29 | 30 |
30 namespace base { | 31 namespace base { |
31 class FilePath; | 32 class FilePath; |
32 } // namespace base | 33 } // namespace base |
33 | 34 |
34 namespace storage { | 35 namespace storage { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 // Creates a new file at |file_path|. | 137 // Creates a new file at |file_path|. |
137 // Called from FileSystemProxy::CreateFile(). | 138 // Called from FileSystemProxy::CreateFile(). |
138 void CreateFile(const base::FilePath& file_path, | 139 void CreateFile(const base::FilePath& file_path, |
139 bool is_exclusive, | 140 bool is_exclusive, |
140 const StatusCallback& callback, | 141 const StatusCallback& callback, |
141 FileSystemInterface* file_system); | 142 FileSystemInterface* file_system); |
142 | 143 |
143 // Truncates the file at |file_path| to |length| bytes. | 144 // Truncates the file at |file_path| to |length| bytes. |
144 // Called from FileSystemProxy::Truncate(). | 145 // Called from FileSystemProxy::Truncate(). |
145 void Truncate(const base::FilePath& file_path, | 146 void Truncate(const base::FilePath& file_path, |
146 int64 length, | 147 int64_t length, |
147 const StatusCallback& callback, | 148 const StatusCallback& callback, |
148 FileSystemInterface* file_system); | 149 FileSystemInterface* file_system); |
149 | 150 |
150 // Creates a snapshot for the file at |file_path|. | 151 // Creates a snapshot for the file at |file_path|. |
151 // Called from FileSystemProxy::CreateSnapshotFile(). | 152 // Called from FileSystemProxy::CreateSnapshotFile(). |
152 void CreateSnapshotFile(const base::FilePath& file_path, | 153 void CreateSnapshotFile(const base::FilePath& file_path, |
153 const CreateSnapshotFileCallback& callback, | 154 const CreateSnapshotFileCallback& callback, |
154 FileSystemInterface* file_system); | 155 FileSystemInterface* file_system); |
155 | 156 |
156 // Creates a writable snapshot for the file at |file_path|. | 157 // Creates a writable snapshot for the file at |file_path|. |
(...skipping 15 matching lines...) Expand all Loading... |
172 void TouchFile(const base::FilePath& file_path, | 173 void TouchFile(const base::FilePath& file_path, |
173 const base::Time& last_access_time, | 174 const base::Time& last_access_time, |
174 const base::Time& last_modified_time, | 175 const base::Time& last_modified_time, |
175 const StatusCallback& callback, | 176 const StatusCallback& callback, |
176 FileSystemInterface* file_system); | 177 FileSystemInterface* file_system); |
177 | 178 |
178 } // namespace fileapi_internal | 179 } // namespace fileapi_internal |
179 } // namespace drive | 180 } // namespace drive |
180 | 181 |
181 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILEAPI_FILEAPI_WORKER_H_ | 182 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILEAPI_FILEAPI_WORKER_H_ |
OLD | NEW |