| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_DRIVE_FILE_WRITE_WATCHER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILE_WRITE_WATCHER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_WRITE_WATCHER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_WRITE_WATCHER_H_ |
| 7 | 7 |
| 8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 // When modification is detected, it is notified to the |observer| passed to | 39 // When modification is detected, it is notified to the |observer| passed to |
| 40 // the constructor by calling OnCacheFileUploadNeededByOperation(resource_id). | 40 // the constructor by calling OnCacheFileUploadNeededByOperation(resource_id). |
| 41 // | 41 // |
| 42 // Currently, the modification is watched in "one-shot" manner. That is, once | 42 // Currently, the modification is watched in "one-shot" manner. That is, once |
| 43 // a modification is notified, the watch is deactivated for freeing system | 43 // a modification is notified, the watch is deactivated for freeing system |
| 44 // resources. As a heuristic to capture the real end of write operations that | 44 // resources. As a heuristic to capture the real end of write operations that |
| 45 // might be done by several chunked writes, the notification is fired after | 45 // might be done by several chunked writes, the notification is fired after |
| 46 // 5 seconds has passed after the last write operation is detected. | 46 // 5 seconds has passed after the last write operation is detected. |
| 47 // | 47 // |
| 48 // TODO(kinaba): investigate the possibility to continuously watch the whole | 48 // TODO(kinaba): investigate the possibility to continuously watch the whole |
| 49 // cache directory. | 49 // cache directory. http://crbug.com/269424 |
| 50 void StartWatch(const base::FilePath& path, | 50 void StartWatch(const base::FilePath& path, |
| 51 const std::string& resource_id, | 51 const std::string& resource_id, |
| 52 const StartWatchCallback& callback); | 52 const StartWatchCallback& callback); |
| 53 | 53 |
| 54 // For testing purpose, stops inserting delay between the write detection and | 54 // For testing purpose, stops inserting delay between the write detection and |
| 55 // notification to the observer. | 55 // notification to the observer. |
| 56 void DisableDelayForTesting(); | 56 void DisableDelayForTesting(); |
| 57 | 57 |
| 58 private: | 58 private: |
| 59 // Invoked when a modification is observed. | 59 // Invoked when a modification is observed. |
| 60 void OnWriteEvent(const std::string& resource_id); | 60 void OnWriteEvent(const std::string& resource_id); |
| 61 | 61 |
| 62 class FileWriteWatcherImpl; | 62 class FileWriteWatcherImpl; |
| 63 scoped_ptr<FileWriteWatcherImpl, util::DestroyHelper> watcher_impl_; | 63 scoped_ptr<FileWriteWatcherImpl, util::DestroyHelper> watcher_impl_; |
| 64 file_system::OperationObserver* operation_observer_; | 64 file_system::OperationObserver* operation_observer_; |
| 65 | 65 |
| 66 // Note: This should remain the last member so it'll be destroyed and | 66 // Note: This should remain the last member so it'll be destroyed and |
| 67 // invalidate its weak pointers before any other members are destroyed. | 67 // invalidate its weak pointers before any other members are destroyed. |
| 68 base::WeakPtrFactory<FileWriteWatcher> weak_ptr_factory_; | 68 base::WeakPtrFactory<FileWriteWatcher> weak_ptr_factory_; |
| 69 DISALLOW_COPY_AND_ASSIGN(FileWriteWatcher); | 69 DISALLOW_COPY_AND_ASSIGN(FileWriteWatcher); |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 } // namespace internal | 72 } // namespace internal |
| 73 } // namespace drive | 73 } // namespace drive |
| 74 | 74 |
| 75 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_WRITE_WATCHER_H_ | 75 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_WRITE_WATCHER_H_ |
| OLD | NEW |