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

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: Normalize expected file path Created 8 years, 2 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
« no previous file with comments | « no previous file | webkit/fileapi/syncable/local_file_change_tracker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/basictypes.h" 12 #include "base/basictypes.h"
12 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
13 #include "base/file_path.h" 14 #include "base/file_path.h"
14 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
16 #include "base/time.h" 17 #include "base/time.h"
17 #include "webkit/fileapi/file_observers.h" 18 #include "webkit/fileapi/file_observers.h"
18 #include "webkit/fileapi/file_system_url.h" 19 #include "webkit/fileapi/file_system_url.h"
(...skipping 15 matching lines...) Expand all
34 : public FileUpdateObserver, 35 : public FileUpdateObserver,
35 public FileChangeObserver { 36 public FileChangeObserver {
36 public: 37 public:
37 typedef std::map<FileSystemURL, FileChangeList, FileSystemURL::Comparator> 38 typedef std::map<FileSystemURL, FileChangeList, FileSystemURL::Comparator>
38 FileChangeMap; 39 FileChangeMap;
39 40
40 // |file_task_runner| must be the one where the observee file operations run. 41 // |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 42 // (So that we can make sure DB operations are done before actual update
42 // happens) 43 // happens)
43 LocalFileChangeTracker(LocalFileSyncStatus* sync_status, 44 LocalFileChangeTracker(LocalFileSyncStatus* sync_status,
45 const FilePath& profile_path,
44 base::SequencedTaskRunner* file_task_runner); 46 base::SequencedTaskRunner* file_task_runner);
45 virtual ~LocalFileChangeTracker(); 47 virtual ~LocalFileChangeTracker();
46 48
47 // FileUpdateObserver overrides. 49 // FileUpdateObserver overrides.
48 virtual void OnStartUpdate(const FileSystemURL& url) OVERRIDE; 50 virtual void OnStartUpdate(const FileSystemURL& url) OVERRIDE;
49 virtual void OnUpdate(const FileSystemURL& url, int64 delta) OVERRIDE {} 51 virtual void OnUpdate(const FileSystemURL& url, int64 delta) OVERRIDE {}
50 virtual void OnEndUpdate(const FileSystemURL& url) OVERRIDE; 52 virtual void OnEndUpdate(const FileSystemURL& url) OVERRIDE;
51 53
52 // FileChangeObserver overrides. 54 // FileChangeObserver overrides.
53 virtual void OnCreateFile(const FileSystemURL& url) OVERRIDE; 55 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|. 70 // 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 71 // This removes |url| from the internal change map and re-enables writing
70 // for |url|. 72 // for |url|.
71 void FinalizeSyncForURL(const FileSystemURL& url); 73 void FinalizeSyncForURL(const FileSystemURL& url);
72 74
73 // Called by FileSyncService at the startup time to collect last 75 // Called by FileSyncService at the startup time to collect last
74 // dirty changes left after the last shutdown (if any). 76 // dirty changes left after the last shutdown (if any).
75 void CollectLastDirtyChanges(FileChangeMap* changes); 77 void CollectLastDirtyChanges(FileChangeMap* changes);
76 78
77 private: 79 private:
80 class TrackerDB;
81 friend class LocalFileChangeTrackerTest;
82
78 void RecordChange(const FileSystemURL& url, const FileChange& change); 83 void RecordChange(const FileSystemURL& url, const FileChange& change);
79 84
80 // Database related methods. 85 // Database related methods.
81 void MarkDirtyOnDatabase(const FileSystemURL& url); 86 void MarkDirtyOnDatabase(const FileSystemURL& url);
82 void ClearDirtyOnDatabase(const FileSystemURL& url); 87 void ClearDirtyOnDatabase(const FileSystemURL& url);
83 88
89 std::string SerializeExternalFileSystemURL(const FileSystemURL& url);
90 bool DeserializeExternalFileSystemURL(
91 const std::string& serialized_url, FileSystemURL* url);
92
84 // Not owned; this must have the same lifetime with us (both owned 93 // Not owned; this must have the same lifetime with us (both owned
85 // by FileSystemContext). 94 // by FileSystemContext).
86 LocalFileSyncStatus *sync_status_; 95 LocalFileSyncStatus *sync_status_;
87 96
88 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; 97 scoped_refptr<base::SequencedTaskRunner> file_task_runner_;
89 98
90 FileChangeMap changes_; 99 FileChangeMap changes_;
91 100
101 scoped_ptr<TrackerDB> tracker_db_;
102
92 DISALLOW_COPY_AND_ASSIGN(LocalFileChangeTracker); 103 DISALLOW_COPY_AND_ASSIGN(LocalFileChangeTracker);
93 }; 104 };
94 105
95 } // namespace fileapi 106 } // namespace fileapi
96 107
97 #endif // WEBKIT_FILEAPI_SYNCABLE_LOCAL_FILE_CHANGE_TRACKER_H_ 108 #endif // WEBKIT_FILEAPI_SYNCABLE_LOCAL_FILE_CHANGE_TRACKER_H_
OLDNEW
« no previous file with comments | « no previous file | webkit/fileapi/syncable/local_file_change_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698