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

Side by Side Diff: chrome/browser/sync_file_system/local/local_file_change_tracker.h

Issue 1545223002: Switch to standard integer types in chrome/browser/, part 4 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 12 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
OLDNEW
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 <stdint.h>
9
8 #include <deque> 10 #include <deque>
9 #include <map> 11 #include <map>
10 #include <string> 12 #include <string>
11 13
12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
14 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
16 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
17 #include "base/synchronization/lock.h" 19 #include "base/synchronization/lock.h"
18 #include "chrome/browser/sync_file_system/file_change.h" 20 #include "chrome/browser/sync_file_system/file_change.h"
19 #include "chrome/browser/sync_file_system/sync_status_code.h" 21 #include "chrome/browser/sync_file_system/sync_status_code.h"
20 #include "storage/browser/fileapi/file_observers.h" 22 #include "storage/browser/fileapi/file_observers.h"
21 #include "storage/browser/fileapi/file_system_url.h" 23 #include "storage/browser/fileapi/file_system_url.h"
22 24
23 namespace base { 25 namespace base {
24 class SequencedTaskRunner; 26 class SequencedTaskRunner;
(...skipping 20 matching lines...) Expand all
45 // |file_task_runner| must be the one where the observee file operations run. 47 // |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 48 // (So that we can make sure DB operations are done before actual update
47 // happens) 49 // happens)
48 LocalFileChangeTracker(const base::FilePath& base_path, 50 LocalFileChangeTracker(const base::FilePath& base_path,
49 leveldb::Env* env_override, 51 leveldb::Env* env_override,
50 base::SequencedTaskRunner* file_task_runner); 52 base::SequencedTaskRunner* file_task_runner);
51 ~LocalFileChangeTracker() override; 53 ~LocalFileChangeTracker() override;
52 54
53 // FileUpdateObserver overrides. 55 // FileUpdateObserver overrides.
54 void OnStartUpdate(const storage::FileSystemURL& url) override; 56 void OnStartUpdate(const storage::FileSystemURL& url) override;
55 void OnUpdate(const storage::FileSystemURL& url, int64 delta) override {} 57 void OnUpdate(const storage::FileSystemURL& url, int64_t delta) override {}
56 void OnEndUpdate(const storage::FileSystemURL& url) override; 58 void OnEndUpdate(const storage::FileSystemURL& url) override;
57 59
58 // FileChangeObserver overrides. 60 // FileChangeObserver overrides.
59 void OnCreateFile(const storage::FileSystemURL& url) override; 61 void OnCreateFile(const storage::FileSystemURL& url) override;
60 void OnCreateFileFrom(const storage::FileSystemURL& url, 62 void OnCreateFileFrom(const storage::FileSystemURL& url,
61 const storage::FileSystemURL& src) override; 63 const storage::FileSystemURL& src) override;
62 void OnRemoveFile(const storage::FileSystemURL& url) override; 64 void OnRemoveFile(const storage::FileSystemURL& url) override;
63 void OnModifyFile(const storage::FileSystemURL& url) override; 65 void OnModifyFile(const storage::FileSystemURL& url) override;
64 void OnCreateDirectory(const storage::FileSystemURL& url) override; 66 void OnCreateDirectory(const storage::FileSystemURL& url) override;
65 void OnRemoveDirectory(const storage::FileSystemURL& url) override; 67 void OnRemoveDirectory(const storage::FileSystemURL& url) override;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // Called by FileSyncService at the startup time to restore last dirty changes 108 // Called by FileSyncService at the startup time to restore last dirty changes
107 // left after the last shutdown (if any). 109 // left after the last shutdown (if any).
108 SyncStatusCode Initialize(storage::FileSystemContext* file_system_context); 110 SyncStatusCode Initialize(storage::FileSystemContext* file_system_context);
109 111
110 // Resets all the changes recorded for the given |origin| and |type|. 112 // Resets all the changes recorded for the given |origin| and |type|.
111 // TODO(kinuko,nhiroki): Ideally this should be automatically called in 113 // TODO(kinuko,nhiroki): Ideally this should be automatically called in
112 // DeleteFileSystem via QuotaUtil::DeleteOriginDataOnFileThread. 114 // DeleteFileSystem via QuotaUtil::DeleteOriginDataOnFileThread.
113 void ResetForFileSystem(const GURL& origin, storage::FileSystemType type); 115 void ResetForFileSystem(const GURL& origin, storage::FileSystemType type);
114 116
115 // This method is (exceptionally) thread-safe. 117 // This method is (exceptionally) thread-safe.
116 int64 num_changes() const { 118 int64_t num_changes() const {
117 base::AutoLock lock(num_changes_lock_); 119 base::AutoLock lock(num_changes_lock_);
118 return num_changes_; 120 return num_changes_;
119 } 121 }
120 122
121 private: 123 private:
122 class TrackerDB; 124 class TrackerDB;
123 friend class CannedSyncableFileSystem; 125 friend class CannedSyncableFileSystem;
124 friend class LocalFileChangeTrackerTest; 126 friend class LocalFileChangeTrackerTest;
125 friend class LocalFileSyncContext; 127 friend class LocalFileSyncContext;
126 friend class LocalFileSyncContextTest; 128 friend class LocalFileSyncContextTest;
127 friend class SyncableFileSystemTest; 129 friend class SyncableFileSystemTest;
128 130
129 struct ChangeInfo { 131 struct ChangeInfo {
130 ChangeInfo(); 132 ChangeInfo();
131 ~ChangeInfo(); 133 ~ChangeInfo();
132 FileChangeList change_list; 134 FileChangeList change_list;
133 int64 change_seq; 135 int64_t change_seq;
134 }; 136 };
135 137
136 typedef std::map<storage::FileSystemURL, 138 typedef std::map<storage::FileSystemURL,
137 ChangeInfo, 139 ChangeInfo,
138 storage::FileSystemURL::Comparator> FileChangeMap; 140 storage::FileSystemURL::Comparator> FileChangeMap;
139 typedef std::map<int64, storage::FileSystemURL> ChangeSeqMap; 141 typedef std::map<int64_t, storage::FileSystemURL> ChangeSeqMap;
140 142
141 void UpdateNumChanges(); 143 void UpdateNumChanges();
142 144
143 // This does mostly same as calling GetNextChangedURLs with max_url=0 145 // This does mostly same as calling GetNextChangedURLs with max_url=0
144 // except that it returns urls in set rather than in deque. 146 // except that it returns urls in set rather than in deque.
145 // Used only in testings. 147 // Used only in testings.
146 void GetAllChangedURLs(storage::FileSystemURLSet* urls); 148 void GetAllChangedURLs(storage::FileSystemURLSet* urls);
147 149
148 // Used only in testings. 150 // Used only in testings.
149 void DropAllChanges(); 151 void DropAllChanges();
(...skipping 25 matching lines...) Expand all
175 ChangeSeqMap change_seqs_; 177 ChangeSeqMap change_seqs_;
176 178
177 FileChangeMap mirror_changes_; // For mirrors. 179 FileChangeMap mirror_changes_; // For mirrors.
178 FileChangeMap demoted_changes_; // For demoted changes. 180 FileChangeMap demoted_changes_; // For demoted changes.
179 181
180 scoped_ptr<TrackerDB> tracker_db_; 182 scoped_ptr<TrackerDB> tracker_db_;
181 183
182 // 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,
183 // 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
184 // well as Drive's changestamps). 186 // well as Drive's changestamps).
185 int64 current_change_seq_number_; 187 int64_t current_change_seq_number_;
186 188
187 // This can be accessed on any threads (with num_changes_lock_). 189 // This can be accessed on any threads (with num_changes_lock_).
188 int64 num_changes_; 190 int64_t num_changes_;
189 mutable base::Lock num_changes_lock_; 191 mutable base::Lock num_changes_lock_;
190 192
191 DISALLOW_COPY_AND_ASSIGN(LocalFileChangeTracker); 193 DISALLOW_COPY_AND_ASSIGN(LocalFileChangeTracker);
192 }; 194 };
193 195
194 } // namespace sync_file_system 196 } // namespace sync_file_system
195 197
196 #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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698