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_SYNC_FILE_SYSTEM_LOCAL_LOCAL_FILE_CHANGE_TRACKER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_LOCAL_FILE_CHANGE_TRACKER_H_ |
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_LOCAL_FILE_CHANGE_TRACKER_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_LOCAL_FILE_CHANGE_TRACKER_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 30 matching lines...) Expand all Loading... |
41 // Owned by FileSystemContext. | 41 // Owned by FileSystemContext. |
42 class LocalFileChangeTracker : public storage::FileUpdateObserver, | 42 class LocalFileChangeTracker : public storage::FileUpdateObserver, |
43 public storage::FileChangeObserver { | 43 public storage::FileChangeObserver { |
44 public: | 44 public: |
45 // |file_task_runner| must be the one where the observee file operations run. | 45 // |file_task_runner| must be the one where the observee file operations run. |
46 // (So that we can make sure DB operations are done before actual update | 46 // (So that we can make sure DB operations are done before actual update |
47 // happens) | 47 // happens) |
48 LocalFileChangeTracker(const base::FilePath& base_path, | 48 LocalFileChangeTracker(const base::FilePath& base_path, |
49 leveldb::Env* env_override, | 49 leveldb::Env* env_override, |
50 base::SequencedTaskRunner* file_task_runner); | 50 base::SequencedTaskRunner* file_task_runner); |
51 virtual ~LocalFileChangeTracker(); | 51 ~LocalFileChangeTracker() override; |
52 | 52 |
53 // FileUpdateObserver overrides. | 53 // FileUpdateObserver overrides. |
54 virtual void OnStartUpdate(const storage::FileSystemURL& url) override; | 54 void OnStartUpdate(const storage::FileSystemURL& url) override; |
55 virtual void OnUpdate(const storage::FileSystemURL& url, | 55 void OnUpdate(const storage::FileSystemURL& url, int64 delta) override {} |
56 int64 delta) override {} | 56 void OnEndUpdate(const storage::FileSystemURL& url) override; |
57 virtual void OnEndUpdate(const storage::FileSystemURL& url) override; | |
58 | 57 |
59 // FileChangeObserver overrides. | 58 // FileChangeObserver overrides. |
60 virtual void OnCreateFile(const storage::FileSystemURL& url) override; | 59 void OnCreateFile(const storage::FileSystemURL& url) override; |
61 virtual void OnCreateFileFrom(const storage::FileSystemURL& url, | 60 void OnCreateFileFrom(const storage::FileSystemURL& url, |
62 const storage::FileSystemURL& src) override; | 61 const storage::FileSystemURL& src) override; |
63 virtual void OnRemoveFile(const storage::FileSystemURL& url) override; | 62 void OnRemoveFile(const storage::FileSystemURL& url) override; |
64 virtual void OnModifyFile(const storage::FileSystemURL& url) override; | 63 void OnModifyFile(const storage::FileSystemURL& url) override; |
65 virtual void OnCreateDirectory(const storage::FileSystemURL& url) override; | 64 void OnCreateDirectory(const storage::FileSystemURL& url) override; |
66 virtual void OnRemoveDirectory(const storage::FileSystemURL& url) override; | 65 void OnRemoveDirectory(const storage::FileSystemURL& url) override; |
67 | 66 |
68 // Retrieves an array of |url| which have more than one pending changes. | 67 // Retrieves an array of |url| which have more than one pending changes. |
69 // If |max_urls| is non-zero (recommended in production code) this | 68 // If |max_urls| is non-zero (recommended in production code) this |
70 // returns URLs up to the number from the ones that have smallest | 69 // returns URLs up to the number from the ones that have smallest |
71 // change_seq numbers (i.e. older changes). | 70 // change_seq numbers (i.e. older changes). |
72 void GetNextChangedURLs(std::deque<storage::FileSystemURL>* urls, | 71 void GetNextChangedURLs(std::deque<storage::FileSystemURL>* urls, |
73 int max_urls); | 72 int max_urls); |
74 | 73 |
75 // Returns all changes recorded for the given |url|. | 74 // Returns all changes recorded for the given |url|. |
76 // Note that this also returns demoted changes. | 75 // Note that this also returns demoted changes. |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 // This can be accessed on any threads (with num_changes_lock_). | 187 // This can be accessed on any threads (with num_changes_lock_). |
189 int64 num_changes_; | 188 int64 num_changes_; |
190 mutable base::Lock num_changes_lock_; | 189 mutable base::Lock num_changes_lock_; |
191 | 190 |
192 DISALLOW_COPY_AND_ASSIGN(LocalFileChangeTracker); | 191 DISALLOW_COPY_AND_ASSIGN(LocalFileChangeTracker); |
193 }; | 192 }; |
194 | 193 |
195 } // namespace sync_file_system | 194 } // namespace sync_file_system |
196 | 195 |
197 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_LOCAL_FILE_CHANGE_TRACKER_H_ | 196 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_LOCAL_FILE_CHANGE_TRACKER_H_ |
OLD | NEW |