| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 68                           int max_urls); | 68                           int max_urls); | 
| 69 | 69 | 
| 70   // Returns all changes recorded for the given |url|. | 70   // Returns all changes recorded for the given |url|. | 
| 71   // This should be called after writing is disabled. | 71   // This should be called after writing is disabled. | 
| 72   void GetChangesForURL(const fileapi::FileSystemURL& url, | 72   void GetChangesForURL(const fileapi::FileSystemURL& url, | 
| 73                         FileChangeList* changes); | 73                         FileChangeList* changes); | 
| 74 | 74 | 
| 75   // Clears the pending changes recorded in this tracker for |url|. | 75   // Clears the pending changes recorded in this tracker for |url|. | 
| 76   void ClearChangesForURL(const fileapi::FileSystemURL& url); | 76   void ClearChangesForURL(const fileapi::FileSystemURL& url); | 
| 77 | 77 | 
|  | 78   // Creates a fresh (empty) in-memory record for |url|. | 
|  | 79   // Note that new changes are recorded to the mirror too. | 
|  | 80   void CreateFreshMirrorForURL(const fileapi::FileSystemURL& url); | 
|  | 81 | 
|  | 82   // Removes a mirror for |url|, and commits the change status to database. | 
|  | 83   void RemoveMirrorAndCommitChangesForURL(const fileapi::FileSystemURL& url); | 
|  | 84 | 
|  | 85   // Resets the changes to the ones recorded in mirror for |url|, and | 
|  | 86   // commits the updated change status to database. | 
|  | 87   void ResetToMirrorAndCommitChangesForURL(const fileapi::FileSystemURL& url); | 
|  | 88 | 
| 78   // Called by FileSyncService at the startup time to restore last dirty changes | 89   // Called by FileSyncService at the startup time to restore last dirty changes | 
| 79   // left after the last shutdown (if any). | 90   // left after the last shutdown (if any). | 
| 80   SyncStatusCode Initialize(fileapi::FileSystemContext* file_system_context); | 91   SyncStatusCode Initialize(fileapi::FileSystemContext* file_system_context); | 
| 81 | 92 | 
| 82   // This method is (exceptionally) thread-safe. | 93   // This method is (exceptionally) thread-safe. | 
| 83   int64 num_changes() const { | 94   int64 num_changes() const { | 
| 84     base::AutoLock lock(num_changes_lock_); | 95     base::AutoLock lock(num_changes_lock_); | 
| 85     return num_changes_; | 96     return num_changes_; | 
| 86   } | 97   } | 
| 87 | 98 | 
| (...skipping 28 matching lines...) Expand all  Loading... | 
| 116 | 127 | 
| 117   // Database related methods. | 128   // Database related methods. | 
| 118   SyncStatusCode MarkDirtyOnDatabase(const fileapi::FileSystemURL& url); | 129   SyncStatusCode MarkDirtyOnDatabase(const fileapi::FileSystemURL& url); | 
| 119   SyncStatusCode ClearDirtyOnDatabase(const fileapi::FileSystemURL& url); | 130   SyncStatusCode ClearDirtyOnDatabase(const fileapi::FileSystemURL& url); | 
| 120 | 131 | 
| 121   SyncStatusCode CollectLastDirtyChanges( | 132   SyncStatusCode CollectLastDirtyChanges( | 
| 122       fileapi::FileSystemContext* file_system_context); | 133       fileapi::FileSystemContext* file_system_context); | 
| 123   void RecordChange(const fileapi::FileSystemURL& url, | 134   void RecordChange(const fileapi::FileSystemURL& url, | 
| 124                     const FileChange& change); | 135                     const FileChange& change); | 
| 125 | 136 | 
|  | 137   static void RecordChangeToChangeMaps(const fileapi::FileSystemURL& url, | 
|  | 138                                        const FileChange& change, | 
|  | 139                                        int change_seq, | 
|  | 140                                        FileChangeMap* changes, | 
|  | 141                                        ChangeSeqMap* change_seqs); | 
|  | 142 | 
| 126   bool initialized_; | 143   bool initialized_; | 
| 127 | 144 | 
| 128   scoped_refptr<base::SequencedTaskRunner> file_task_runner_; | 145   scoped_refptr<base::SequencedTaskRunner> file_task_runner_; | 
| 129 | 146 | 
| 130   FileChangeMap changes_; | 147   FileChangeMap changes_; | 
| 131   ChangeSeqMap change_seqs_; | 148   ChangeSeqMap change_seqs_; | 
| 132 | 149 | 
|  | 150   // For mirrors. | 
|  | 151   FileChangeMap mirror_changes_; | 
|  | 152 | 
| 133   scoped_ptr<TrackerDB> tracker_db_; | 153   scoped_ptr<TrackerDB> tracker_db_; | 
| 134 | 154 | 
| 135   // Change sequence number. Briefly gives a hint about the order of changes, | 155   // Change sequence number. Briefly gives a hint about the order of changes, | 
| 136   // but they are updated when a new change comes on the same file (as | 156   // but they are updated when a new change comes on the same file (as | 
| 137   // well as Drive's changestamps). | 157   // well as Drive's changestamps). | 
| 138   int64 current_change_seq_; | 158   int64 current_change_seq_; | 
| 139 | 159 | 
| 140   // This can be accessed on any threads (with num_changes_lock_). | 160   // This can be accessed on any threads (with num_changes_lock_). | 
| 141   int64 num_changes_; | 161   int64 num_changes_; | 
| 142   mutable base::Lock num_changes_lock_; | 162   mutable base::Lock num_changes_lock_; | 
| 143 | 163 | 
| 144   DISALLOW_COPY_AND_ASSIGN(LocalFileChangeTracker); | 164   DISALLOW_COPY_AND_ASSIGN(LocalFileChangeTracker); | 
| 145 }; | 165 }; | 
| 146 | 166 | 
| 147 }  // namespace sync_file_system | 167 }  // namespace sync_file_system | 
| 148 | 168 | 
| 149 #endif  // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_LOCAL_FILE_CHANGE_TRACKER_H_ | 169 #endif  // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_LOCAL_FILE_CHANGE_TRACKER_H_ | 
| OLD | NEW | 
|---|