Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: webkit/fileapi/syncable/local_file_change_tracker.h

Issue 10966003: Add LocalFileChangeTracker database to record non-synced dirty files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 WEBKIT_FILEAPI_SYNCABLE_LOCAL_FILE_CHANGE_TRACKER_H_ 5 #ifndef WEBKIT_FILEAPI_SYNCABLE_LOCAL_FILE_CHANGE_TRACKER_H_
6 #define WEBKIT_FILEAPI_SYNCABLE_LOCAL_FILE_CHANGE_TRACKER_H_ 6 #define WEBKIT_FILEAPI_SYNCABLE_LOCAL_FILE_CHANGE_TRACKER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 23 matching lines...) Expand all
34 : public FileUpdateObserver, 34 : public FileUpdateObserver,
35 public FileChangeObserver { 35 public FileChangeObserver {
36 public: 36 public:
37 typedef std::map<FileSystemURL, FileChangeList, FileSystemURL::Comparator> 37 typedef std::map<FileSystemURL, FileChangeList, FileSystemURL::Comparator>
38 FileChangeMap; 38 FileChangeMap;
39 39
40 // |file_task_runner| must be the one where the observee file operations run. 40 // |file_task_runner| must be the one where the observee file operations run.
41 // (So that we can make sure DB operations are done before actual update 41 // (So that we can make sure DB operations are done before actual update
42 // happens) 42 // happens)
43 LocalFileChangeTracker(LocalFileSyncStatus* sync_status, 43 LocalFileChangeTracker(LocalFileSyncStatus* sync_status,
44 const FilePath& profile_path,
44 base::SequencedTaskRunner* file_task_runner); 45 base::SequencedTaskRunner* file_task_runner);
45 virtual ~LocalFileChangeTracker(); 46 virtual ~LocalFileChangeTracker();
46 47
47 // FileUpdateObserver overrides. 48 // FileUpdateObserver overrides.
48 virtual void OnStartUpdate(const FileSystemURL& url) OVERRIDE; 49 virtual void OnStartUpdate(const FileSystemURL& url) OVERRIDE;
49 virtual void OnUpdate(const FileSystemURL& url, int64 delta) OVERRIDE {} 50 virtual void OnUpdate(const FileSystemURL& url, int64 delta) OVERRIDE {}
50 virtual void OnEndUpdate(const FileSystemURL& url) OVERRIDE; 51 virtual void OnEndUpdate(const FileSystemURL& url) OVERRIDE;
51 52
52 // FileChangeObserver overrides. 53 // FileChangeObserver overrides.
53 virtual void OnCreateFile(const FileSystemURL& url) OVERRIDE; 54 virtual void OnCreateFile(const FileSystemURL& url) OVERRIDE;
(...skipping 14 matching lines...) Expand all
68 // Called by FileSyncService to notify that the changes are synced for |url|. 69 // Called by FileSyncService to notify that the changes are synced for |url|.
69 // This removes |url| from the internal change map and re-enables writing 70 // This removes |url| from the internal change map and re-enables writing
70 // for |url|. 71 // for |url|.
71 void FinalizeSyncForURL(const FileSystemURL& url); 72 void FinalizeSyncForURL(const FileSystemURL& url);
72 73
73 // Called by FileSyncService at the startup time to collect last 74 // Called by FileSyncService at the startup time to collect last
74 // dirty changes left after the last shutdown (if any). 75 // dirty changes left after the last shutdown (if any).
75 void CollectLastDirtyChanges(FileChangeMap* changes); 76 void CollectLastDirtyChanges(FileChangeMap* changes);
76 77
77 private: 78 private:
79 class TrackerDB;
80
78 void RecordChange(const FileSystemURL& url, const FileChange& change); 81 void RecordChange(const FileSystemURL& url, const FileChange& change);
79 82
80 // Database related methods. 83 // Database related methods.
81 void MarkDirtyOnDatabase(const FileSystemURL& url); 84 void MarkDirtyOnDatabase(const FileSystemURL& url);
82 void ClearDirtyOnDatabase(const FileSystemURL& url); 85 void ClearDirtyOnDatabase(const FileSystemURL& url);
83 86
84 // Not owned; this must have the same lifetime with us (both owned 87 // Not owned; this must have the same lifetime with us (both owned
85 // by FileSystemContext). 88 // by FileSystemContext).
86 LocalFileSyncStatus *sync_status_; 89 LocalFileSyncStatus *sync_status_;
87 90
88 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; 91 scoped_refptr<base::SequencedTaskRunner> file_task_runner_;
89 92
90 FileChangeMap changes_; 93 FileChangeMap changes_;
91 94
95 scoped_ptr<TrackerDB> tracker_db_;
96
92 DISALLOW_COPY_AND_ASSIGN(LocalFileChangeTracker); 97 DISALLOW_COPY_AND_ASSIGN(LocalFileChangeTracker);
93 }; 98 };
94 99
95 } // namespace fileapi 100 } // namespace fileapi
96 101
97 #endif // WEBKIT_FILEAPI_SYNCABLE_LOCAL_FILE_CHANGE_TRACKER_H_ 102 #endif // WEBKIT_FILEAPI_SYNCABLE_LOCAL_FILE_CHANGE_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698