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 #include <vector> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/observer_list.h" | |
| 15 #include "base/task/cancelable_task_tracker.h" | 16 #include "base/task/cancelable_task_tracker.h" |
| 16 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info .h" | 17 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info .h" |
| 17 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte rface.h" | 18 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte rface.h" |
| 19 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_obse rver.h" | |
| 18 | 20 |
| 19 class Profile; | 21 class Profile; |
| 20 | 22 |
| 21 namespace base { | 23 namespace base { |
| 22 class Time; | 24 class Time; |
| 23 } // namespace base | 25 } // namespace base |
| 24 | 26 |
| 25 namespace net { | 27 namespace net { |
| 26 class IOBuffer; | 28 class IOBuffer; |
| 27 } // namespace net | 29 } // namespace net |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 virtual AbortCallback Truncate( | 117 virtual AbortCallback Truncate( |
| 116 const base::FilePath& file_path, | 118 const base::FilePath& file_path, |
| 117 int64 length, | 119 int64 length, |
| 118 const storage::AsyncFileUtil::StatusCallback& callback) OVERRIDE; | 120 const storage::AsyncFileUtil::StatusCallback& callback) OVERRIDE; |
| 119 virtual AbortCallback WriteFile( | 121 virtual AbortCallback WriteFile( |
| 120 int file_handle, | 122 int file_handle, |
| 121 net::IOBuffer* buffer, | 123 net::IOBuffer* buffer, |
| 122 int64 offset, | 124 int64 offset, |
| 123 int length, | 125 int length, |
| 124 const storage::AsyncFileUtil::StatusCallback& callback) OVERRIDE; | 126 const storage::AsyncFileUtil::StatusCallback& callback) OVERRIDE; |
| 127 virtual AbortCallback ObserveDirectory( | |
|
mtomasz
2014/10/03 04:22:47
Currently we support observing directories only, n
| |
| 128 const base::FilePath& directory_path, | |
| 129 bool recursive, | |
| 130 const storage::AsyncFileUtil::StatusCallback& callback) OVERRIDE; | |
| 131 virtual AbortCallback UnobserveEntry( | |
|
mtomasz
2014/10/03 04:22:47
Method for unobserving files would have the same s
| |
| 132 const base::FilePath& entry_path, | |
| 133 const storage::AsyncFileUtil::StatusCallback& callback) OVERRIDE; | |
| 125 virtual const ProvidedFileSystemInfo& GetFileSystemInfo() const OVERRIDE; | 134 virtual const ProvidedFileSystemInfo& GetFileSystemInfo() const OVERRIDE; |
| 126 virtual RequestManager* GetRequestManager() OVERRIDE; | 135 virtual RequestManager* GetRequestManager() OVERRIDE; |
| 136 virtual ObservedEntries* GetObservedEntries() OVERRIDE; | |
| 137 virtual void AddObserver(ProvidedFileSystemObserver* observer) OVERRIDE; | |
|
mtomasz
2014/10/03 04:22:47
Cache implementation will add itself as an observe
| |
| 138 virtual void RemoveObserver(ProvidedFileSystemObserver* observer) OVERRIDE; | |
| 139 virtual bool Notify( | |
|
mtomasz
2014/10/03 04:22:47
This is called from file_system_provider_api.cc, s
| |
| 140 const base::FilePath& observed_path, | |
| 141 ProvidedFileSystemObserver::ChangeType change_type, | |
| 142 const ProvidedFileSystemObserver::ChildChanges& child_changes, | |
| 143 const std::string& tag) OVERRIDE; | |
| 127 virtual base::WeakPtr<ProvidedFileSystemInterface> GetWeakPtr() OVERRIDE; | 144 virtual base::WeakPtr<ProvidedFileSystemInterface> GetWeakPtr() OVERRIDE; |
| 128 | 145 |
| 129 // Factory callback, to be used in Service::SetFileSystemFactory(). The | 146 // Factory callback, to be used in Service::SetFileSystemFactory(). The |
| 130 // |event_router| argument can be NULL. | 147 // |event_router| argument can be NULL. |
| 131 static ProvidedFileSystemInterface* Create( | 148 static ProvidedFileSystemInterface* Create( |
| 132 Profile* profile, | 149 Profile* profile, |
| 133 const ProvidedFileSystemInfo& file_system_info); | 150 const ProvidedFileSystemInfo& file_system_info); |
| 134 | 151 |
| 135 private: | 152 private: |
| 136 typedef std::map<base::FilePath, linked_ptr<FakeEntry> > Entries; | 153 typedef std::map<base::FilePath, linked_ptr<FakeEntry> > Entries; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 149 // returning a response for the operation, which will be cancelled, hence not | 166 // returning a response for the operation, which will be cancelled, hence not |
| 150 // called. | 167 // called. |
| 151 void AbortMany(const std::vector<int>& task_ids, | 168 void AbortMany(const std::vector<int>& task_ids, |
| 152 const storage::AsyncFileUtil::StatusCallback& callback); | 169 const storage::AsyncFileUtil::StatusCallback& callback); |
| 153 | 170 |
| 154 ProvidedFileSystemInfo file_system_info_; | 171 ProvidedFileSystemInfo file_system_info_; |
| 155 Entries entries_; | 172 Entries entries_; |
| 156 OpenedFilesMap opened_files_; | 173 OpenedFilesMap opened_files_; |
| 157 int last_file_handle_; | 174 int last_file_handle_; |
| 158 base::CancelableTaskTracker tracker_; | 175 base::CancelableTaskTracker tracker_; |
| 176 ObserverList<ProvidedFileSystemObserver> observers_; | |
| 159 | 177 |
| 160 base::WeakPtrFactory<FakeProvidedFileSystem> weak_ptr_factory_; | 178 base::WeakPtrFactory<FakeProvidedFileSystem> weak_ptr_factory_; |
| 161 DISALLOW_COPY_AND_ASSIGN(FakeProvidedFileSystem); | 179 DISALLOW_COPY_AND_ASSIGN(FakeProvidedFileSystem); |
| 162 }; | 180 }; |
| 163 | 181 |
| 164 } // namespace file_system_provider | 182 } // namespace file_system_provider |
| 165 } // namespace chromeos | 183 } // namespace chromeos |
| 166 | 184 |
| 167 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FAKE_PROVIDED_FILE_SYSTE M_H_ | 185 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FAKE_PROVIDED_FILE_SYSTE M_H_ |
| OLD | NEW |