| 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 13 matching lines...) Expand all Loading... |
| 24 class SequencedTaskRunner; | 24 class SequencedTaskRunner; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace fileapi { | 27 namespace fileapi { |
| 28 class FileSystemContext; | 28 class FileSystemContext; |
| 29 class FileSystemURL; | 29 class FileSystemURL; |
| 30 } | 30 } |
| 31 | 31 |
| 32 namespace leveldb { | 32 namespace leveldb { |
| 33 class Env; | 33 class Env; |
| 34 class WriteBatch; |
| 34 } | 35 } |
| 35 | 36 |
| 36 namespace sync_file_system { | 37 namespace sync_file_system { |
| 37 | 38 |
| 38 // Tracks local file changes for cloud-backed file systems. | 39 // Tracks local file changes for cloud-backed file systems. |
| 39 // All methods must be called on the file_task_runner given to the constructor. | 40 // All methods must be called on the file_task_runner given to the constructor. |
| 40 // Owned by FileSystemContext. | 41 // Owned by FileSystemContext. |
| 41 class LocalFileChangeTracker | 42 class LocalFileChangeTracker |
| 42 : public fileapi::FileUpdateObserver, | 43 : public fileapi::FileUpdateObserver, |
| 43 public fileapi::FileChangeObserver { | 44 public fileapi::FileChangeObserver { |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 fileapi::FileSystemContext* file_system_context); | 158 fileapi::FileSystemContext* file_system_context); |
| 158 void RecordChange(const fileapi::FileSystemURL& url, | 159 void RecordChange(const fileapi::FileSystemURL& url, |
| 159 const FileChange& change); | 160 const FileChange& change); |
| 160 | 161 |
| 161 static void RecordChangeToChangeMaps(const fileapi::FileSystemURL& url, | 162 static void RecordChangeToChangeMaps(const fileapi::FileSystemURL& url, |
| 162 const FileChange& change, | 163 const FileChange& change, |
| 163 int change_seq, | 164 int change_seq, |
| 164 FileChangeMap* changes, | 165 FileChangeMap* changes, |
| 165 ChangeSeqMap* change_seqs); | 166 ChangeSeqMap* change_seqs); |
| 166 | 167 |
| 168 void ResetForURL(const fileapi::FileSystemURL& url, |
| 169 int change_seq, |
| 170 leveldb::WriteBatch* batch); |
| 171 |
| 167 bool initialized_; | 172 bool initialized_; |
| 168 | 173 |
| 169 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; | 174 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; |
| 170 | 175 |
| 171 FileChangeMap changes_; | 176 FileChangeMap changes_; |
| 172 ChangeSeqMap change_seqs_; | 177 ChangeSeqMap change_seqs_; |
| 173 | 178 |
| 174 FileChangeMap mirror_changes_; // For mirrors. | 179 FileChangeMap mirror_changes_; // For mirrors. |
| 175 FileChangeMap demoted_changes_; // For demoted changes. | 180 FileChangeMap demoted_changes_; // For demoted changes. |
| 176 | 181 |
| 177 scoped_ptr<TrackerDB> tracker_db_; | 182 scoped_ptr<TrackerDB> tracker_db_; |
| 178 | 183 |
| 179 // Change sequence number. Briefly gives a hint about the order of changes, | 184 // Change sequence number. Briefly gives a hint about the order of changes, |
| 180 // but they are updated when a new change comes on the same file (as | 185 // but they are updated when a new change comes on the same file (as |
| 181 // well as Drive's changestamps). | 186 // well as Drive's changestamps). |
| 182 int64 current_change_seq_; | 187 int64 current_change_seq_; |
| 183 | 188 |
| 184 // This can be accessed on any threads (with num_changes_lock_). | 189 // This can be accessed on any threads (with num_changes_lock_). |
| 185 int64 num_changes_; | 190 int64 num_changes_; |
| 186 mutable base::Lock num_changes_lock_; | 191 mutable base::Lock num_changes_lock_; |
| 187 | 192 |
| 188 DISALLOW_COPY_AND_ASSIGN(LocalFileChangeTracker); | 193 DISALLOW_COPY_AND_ASSIGN(LocalFileChangeTracker); |
| 189 }; | 194 }; |
| 190 | 195 |
| 191 } // namespace sync_file_system | 196 } // namespace sync_file_system |
| 192 | 197 |
| 193 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_LOCAL_FILE_CHANGE_TRACKER_H_ | 198 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_LOCAL_FILE_CHANGE_TRACKER_H_ |
| OLD | NEW |