| 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 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "base/basictypes.h" | 24 #include "base/basictypes.h" |
| 25 #include "base/callback_forward.h" | 25 #include "base/callback_forward.h" |
| 26 #include "base/memory/weak_ptr.h" | 26 #include "base/memory/weak_ptr.h" |
| 27 #include "chrome/browser/chromeos/drive/file_errors.h" | 27 #include "chrome/browser/chromeos/drive/file_errors.h" |
| 28 #include "webkit/common/blob/scoped_file.h" | 28 #include "webkit/common/blob/scoped_file.h" |
| 29 | 29 |
| 30 namespace base { | 30 namespace base { |
| 31 class FilePath; | 31 class FilePath; |
| 32 } // namespace base | 32 } // namespace base |
| 33 | 33 |
| 34 namespace fileapi { | 34 namespace storage { |
| 35 struct DirectoryEntry; | 35 struct DirectoryEntry; |
| 36 class FileSystemURL; | 36 class FileSystemURL; |
| 37 } // namespace fileapi | 37 } // namespace storage |
| 38 | 38 |
| 39 namespace drive { | 39 namespace drive { |
| 40 | 40 |
| 41 class FileSystemInterface; | 41 class FileSystemInterface; |
| 42 | 42 |
| 43 namespace fileapi_internal { | 43 namespace fileapi_internal { |
| 44 | 44 |
| 45 typedef base::Callback<FileSystemInterface*()> FileSystemGetter; | 45 typedef base::Callback<FileSystemInterface*()> FileSystemGetter; |
| 46 | 46 |
| 47 typedef base::Callback< | 47 typedef base::Callback< |
| 48 void(base::File::Error result)> StatusCallback; | 48 void(base::File::Error result)> StatusCallback; |
| 49 typedef base::Callback< | 49 typedef base::Callback< |
| 50 void(base::File::Error result, | 50 void(base::File::Error result, |
| 51 const base::File::Info& file_info)> GetFileInfoCallback; | 51 const base::File::Info& file_info)> GetFileInfoCallback; |
| 52 typedef base::Callback< | 52 typedef base::Callback< |
| 53 void(base::File::Error result, | 53 void(base::File::Error result, |
| 54 const std::vector<fileapi::DirectoryEntry>& file_list, | 54 const std::vector<storage::DirectoryEntry>& file_list, |
| 55 bool has_more)> ReadDirectoryCallback; | 55 bool has_more)> ReadDirectoryCallback; |
| 56 typedef base::Callback< | 56 typedef base::Callback<void(base::File::Error result, |
| 57 void(base::File::Error result, | 57 const base::File::Info& file_info, |
| 58 const base::File::Info& file_info, | 58 const base::FilePath& snapshot_file_path, |
| 59 const base::FilePath& snapshot_file_path, | 59 storage::ScopedFile::ScopeOutPolicy |
| 60 webkit_blob::ScopedFile::ScopeOutPolicy scope_out_policy)> | 60 scope_out_policy)> CreateSnapshotFileCallback; |
| 61 CreateSnapshotFileCallback; | |
| 62 typedef base::Callback< | 61 typedef base::Callback< |
| 63 void(base::File::Error result, | 62 void(base::File::Error result, |
| 64 const base::FilePath& snapshot_file_path, | 63 const base::FilePath& snapshot_file_path, |
| 65 const base::Closure& close_callback)> | 64 const base::Closure& close_callback)> |
| 66 CreateWritableSnapshotFileCallback; | 65 CreateWritableSnapshotFileCallback; |
| 67 typedef base::Callback< | 66 typedef base::Callback< |
| 68 void(base::File file, | 67 void(base::File file, |
| 69 const base::Closure& close_callback)> OpenFileCallback; | 68 const base::Closure& close_callback)> OpenFileCallback; |
| 70 | 69 |
| 71 // Gets the profile of the Drive entry pointed by |url|. Used as | 70 // Gets the profile of the Drive entry pointed by |url|. Used as |
| 72 // FileSystemGetter callback by binding an URL on the IO thread and passing to | 71 // FileSystemGetter callback by binding an URL on the IO thread and passing to |
| 73 // the UI thread. | 72 // the UI thread. |
| 74 FileSystemInterface* GetFileSystemFromUrl(const fileapi::FileSystemURL& url); | 73 FileSystemInterface* GetFileSystemFromUrl(const storage::FileSystemURL& url); |
| 75 | 74 |
| 76 // Runs |file_system_getter| to obtain the instance of FileSystemInstance, | 75 // Runs |file_system_getter| to obtain the instance of FileSystemInstance, |
| 77 // and then runs |callback| with it. | 76 // and then runs |callback| with it. |
| 78 // If |file_system_getter| returns NULL, runs |error_callback| instead. | 77 // If |file_system_getter| returns NULL, runs |error_callback| instead. |
| 79 // This function must be called on UI thread. | 78 // This function must be called on UI thread. |
| 80 // |file_system_getter| and |callback| must not be null, but | 79 // |file_system_getter| and |callback| must not be null, but |
| 81 // |error_callback| can be null (if no operation is necessary for error | 80 // |error_callback| can be null (if no operation is necessary for error |
| 82 // case). | 81 // case). |
| 83 void RunFileSystemCallback( | 82 void RunFileSystemCallback( |
| 84 const FileSystemGetter& file_system_getter, | 83 const FileSystemGetter& file_system_getter, |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 void TouchFile(const base::FilePath& file_path, | 172 void TouchFile(const base::FilePath& file_path, |
| 174 const base::Time& last_access_time, | 173 const base::Time& last_access_time, |
| 175 const base::Time& last_modified_time, | 174 const base::Time& last_modified_time, |
| 176 const StatusCallback& callback, | 175 const StatusCallback& callback, |
| 177 FileSystemInterface* file_system); | 176 FileSystemInterface* file_system); |
| 178 | 177 |
| 179 } // namespace fileapi_internal | 178 } // namespace fileapi_internal |
| 180 } // namespace drive | 179 } // namespace drive |
| 181 | 180 |
| 182 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILEAPI_FILEAPI_WORKER_H_ | 181 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILEAPI_FILEAPI_WORKER_H_ |
| OLD | NEW |