Chromium Code Reviews| 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 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FAKE_PROVIDED_FILE_SYSTEM_H _ | 5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FAKE_PROVIDED_FILE_SYSTEM_H _ |
| 6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FAKE_PROVIDED_FILE_SYSTEM_H _ | 6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FAKE_PROVIDED_FILE_SYSTEM_H _ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | |
| 10 | 11 |
| 11 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/task/cancelable_task_tracker.h" | |
| 12 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info .h" | 14 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info .h" |
| 13 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte rface.h" | 15 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte rface.h" |
| 14 | 16 |
| 15 class Profile; | 17 class Profile; |
| 16 | 18 |
| 17 namespace base { | 19 namespace base { |
| 18 class Time; | 20 class Time; |
| 19 } // namespace base | 21 } // namespace base |
| 20 | 22 |
| 21 namespace net { | 23 namespace net { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 base::Time modification_time, | 62 base::Time modification_time, |
| 61 std::string mime_type, | 63 std::string mime_type, |
| 62 std::string contents); | 64 std::string contents); |
| 63 | 65 |
| 64 // Fetches a pointer to a fake entry registered in the fake file system. If | 66 // Fetches a pointer to a fake entry registered in the fake file system. If |
| 65 // found, then the result is written to |fake_entry| and true is returned. | 67 // found, then the result is written to |fake_entry| and true is returned. |
| 66 // Otherwise, false is returned. |fake_entry| must not be NULL. | 68 // Otherwise, false is returned. |fake_entry| must not be NULL. |
| 67 bool GetEntry(const base::FilePath& entry_path, FakeEntry* fake_entry) const; | 69 bool GetEntry(const base::FilePath& entry_path, FakeEntry* fake_entry) const; |
| 68 | 70 |
| 69 // ProvidedFileSystemInterface overrides. | 71 // ProvidedFileSystemInterface overrides. |
| 70 virtual void RequestUnmount( | 72 virtual AbortCallback RequestUnmount( |
| 71 const fileapi::AsyncFileUtil::StatusCallback& callback) OVERRIDE; | 73 const fileapi::AsyncFileUtil::StatusCallback& callback) OVERRIDE; |
| 72 virtual void GetMetadata( | 74 virtual AbortCallback GetMetadata( |
| 73 const base::FilePath& entry_path, | 75 const base::FilePath& entry_path, |
| 74 const ProvidedFileSystemInterface::GetMetadataCallback& callback) | 76 const ProvidedFileSystemInterface::GetMetadataCallback& callback) |
| 75 OVERRIDE; | 77 OVERRIDE; |
| 76 virtual void ReadDirectory( | 78 virtual AbortCallback ReadDirectory( |
| 77 const base::FilePath& directory_path, | 79 const base::FilePath& directory_path, |
| 78 const fileapi::AsyncFileUtil::ReadDirectoryCallback& callback) OVERRIDE; | 80 const fileapi::AsyncFileUtil::ReadDirectoryCallback& callback) OVERRIDE; |
| 79 virtual void OpenFile(const base::FilePath& file_path, | 81 virtual AbortCallback OpenFile(const base::FilePath& file_path, |
|
hirono
2014/08/06 08:33:50
nit: Make it the rule of breaking lines consistent
mtomasz
2014/08/08 06:29:40
It is done by git cl format. AFAIR it is correct.
hirono
2014/08/08 07:23:38
Acknowledged.
| |
| 80 OpenFileMode mode, | 82 OpenFileMode mode, |
| 81 const OpenFileCallback& callback) OVERRIDE; | 83 const OpenFileCallback& callback) OVERRIDE; |
| 82 virtual void CloseFile( | 84 virtual AbortCallback CloseFile( |
| 83 int file_handle, | 85 int file_handle, |
| 84 const fileapi::AsyncFileUtil::StatusCallback& callback) OVERRIDE; | 86 const fileapi::AsyncFileUtil::StatusCallback& callback) OVERRIDE; |
| 85 virtual void ReadFile(int file_handle, | 87 virtual AbortCallback ReadFile( |
| 86 net::IOBuffer* buffer, | 88 int file_handle, |
| 87 int64 offset, | 89 net::IOBuffer* buffer, |
| 88 int length, | 90 int64 offset, |
| 89 const ReadChunkReceivedCallback& callback) OVERRIDE; | 91 int length, |
| 90 virtual void CreateDirectory( | 92 const ReadChunkReceivedCallback& callback) OVERRIDE; |
| 93 virtual AbortCallback CreateDirectory( | |
| 91 const base::FilePath& directory_path, | 94 const base::FilePath& directory_path, |
| 92 bool exclusive, | 95 bool exclusive, |
| 93 bool recursive, | 96 bool recursive, |
| 94 const fileapi::AsyncFileUtil::StatusCallback& callback) OVERRIDE; | 97 const fileapi::AsyncFileUtil::StatusCallback& callback) OVERRIDE; |
| 95 virtual void DeleteEntry( | 98 virtual AbortCallback DeleteEntry( |
| 96 const base::FilePath& entry_path, | 99 const base::FilePath& entry_path, |
| 97 bool recursive, | 100 bool recursive, |
| 98 const fileapi::AsyncFileUtil::StatusCallback& callback) OVERRIDE; | 101 const fileapi::AsyncFileUtil::StatusCallback& callback) OVERRIDE; |
| 99 virtual void CreateFile( | 102 virtual AbortCallback CreateFile( |
| 100 const base::FilePath& file_path, | 103 const base::FilePath& file_path, |
| 101 const fileapi::AsyncFileUtil::StatusCallback& callback) OVERRIDE; | 104 const fileapi::AsyncFileUtil::StatusCallback& callback) OVERRIDE; |
| 102 virtual void CopyEntry( | 105 virtual AbortCallback CopyEntry( |
| 103 const base::FilePath& source_path, | 106 const base::FilePath& source_path, |
| 104 const base::FilePath& target_path, | 107 const base::FilePath& target_path, |
| 105 const fileapi::AsyncFileUtil::StatusCallback& callback) OVERRIDE; | 108 const fileapi::AsyncFileUtil::StatusCallback& callback) OVERRIDE; |
| 106 virtual void MoveEntry( | 109 virtual AbortCallback MoveEntry( |
| 107 const base::FilePath& source_path, | 110 const base::FilePath& source_path, |
| 108 const base::FilePath& target_path, | 111 const base::FilePath& target_path, |
| 109 const fileapi::AsyncFileUtil::StatusCallback& callback) OVERRIDE; | 112 const fileapi::AsyncFileUtil::StatusCallback& callback) OVERRIDE; |
| 110 virtual void Truncate( | 113 virtual AbortCallback Truncate( |
| 111 const base::FilePath& file_path, | 114 const base::FilePath& file_path, |
| 112 int64 length, | 115 int64 length, |
| 113 const fileapi::AsyncFileUtil::StatusCallback& callback) OVERRIDE; | 116 const fileapi::AsyncFileUtil::StatusCallback& callback) OVERRIDE; |
| 114 virtual void WriteFile( | 117 virtual AbortCallback WriteFile( |
| 115 int file_handle, | 118 int file_handle, |
| 116 net::IOBuffer* buffer, | 119 net::IOBuffer* buffer, |
| 117 int64 offset, | 120 int64 offset, |
| 118 int length, | 121 int length, |
| 119 const fileapi::AsyncFileUtil::StatusCallback& callback) OVERRIDE; | 122 const fileapi::AsyncFileUtil::StatusCallback& callback) OVERRIDE; |
| 120 virtual const ProvidedFileSystemInfo& GetFileSystemInfo() const OVERRIDE; | 123 virtual const ProvidedFileSystemInfo& GetFileSystemInfo() const OVERRIDE; |
| 121 virtual RequestManager* GetRequestManager() OVERRIDE; | 124 virtual RequestManager* GetRequestManager() OVERRIDE; |
| 122 virtual base::WeakPtr<ProvidedFileSystemInterface> GetWeakPtr() OVERRIDE; | 125 virtual base::WeakPtr<ProvidedFileSystemInterface> GetWeakPtr() OVERRIDE; |
| 123 | 126 |
| 124 // Factory callback, to be used in Service::SetFileSystemFactory(). The | 127 // Factory callback, to be used in Service::SetFileSystemFactory(). The |
| 125 // |event_router| argument can be NULL. | 128 // |event_router| argument can be NULL. |
| 126 static ProvidedFileSystemInterface* Create( | 129 static ProvidedFileSystemInterface* Create( |
| 127 Profile* profile, | 130 Profile* profile, |
| 128 const ProvidedFileSystemInfo& file_system_info); | 131 const ProvidedFileSystemInfo& file_system_info); |
| 129 | 132 |
| 130 private: | 133 private: |
| 131 typedef std::map<base::FilePath, FakeEntry> Entries; | 134 typedef std::map<base::FilePath, FakeEntry> Entries; |
| 132 typedef std::map<int, base::FilePath> OpenedFilesMap; | 135 typedef std::map<int, base::FilePath> OpenedFilesMap; |
| 133 | 136 |
| 137 // Aborts a request. |task_id| refers to a posted callback returning a | |
| 138 // response for the operation, which will be cancelled, hence not called. | |
| 139 void Abort(int task_id, | |
| 140 const fileapi::AsyncFileUtil::StatusCallback& callback); | |
| 141 | |
| 142 // Aborts a request. |task_ids| refers to a vector of posted callbacks | |
| 143 // returning a response for the operation, which will be cancelled, hence not | |
| 144 // called. | |
| 145 void AbortMany(const std::vector<int>& task_ids, | |
| 146 const fileapi::AsyncFileUtil::StatusCallback& callback); | |
| 147 | |
| 134 ProvidedFileSystemInfo file_system_info_; | 148 ProvidedFileSystemInfo file_system_info_; |
| 135 Entries entries_; | 149 Entries entries_; |
| 136 OpenedFilesMap opened_files_; | 150 OpenedFilesMap opened_files_; |
| 137 int last_file_handle_; | 151 int last_file_handle_; |
| 152 base::CancelableTaskTracker tracker_; | |
| 138 | 153 |
| 139 base::WeakPtrFactory<ProvidedFileSystemInterface> weak_ptr_factory_; | 154 base::WeakPtrFactory<FakeProvidedFileSystem> weak_ptr_factory_; |
| 140 DISALLOW_COPY_AND_ASSIGN(FakeProvidedFileSystem); | 155 DISALLOW_COPY_AND_ASSIGN(FakeProvidedFileSystem); |
| 141 }; | 156 }; |
| 142 | 157 |
| 143 } // namespace file_system_provider | 158 } // namespace file_system_provider |
| 144 } // namespace chromeos | 159 } // namespace chromeos |
| 145 | 160 |
| 146 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FAKE_PROVIDED_FILE_SYSTE M_H_ | 161 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FAKE_PROVIDED_FILE_SYSTE M_H_ |
| OLD | NEW |