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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/metadata_database.h

Issue 1873683002: Convert //chrome/browser/sync_file_system from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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_DRIVE_BACKEND_METADATA_DATABASE_H_ 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_H_
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_H_ 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <map> 11 #include <map>
12 #include <memory>
12 #include <set> 13 #include <set>
13 #include <string> 14 #include <string>
14 #include <vector> 15 #include <vector>
15 16
16 #include "base/containers/hash_tables.h" 17 #include "base/containers/hash_tables.h"
17 #include "base/containers/scoped_ptr_hash_map.h" 18 #include "base/containers/scoped_ptr_hash_map.h"
18 #include "base/files/file_path.h" 19 #include "base/files/file_path.h"
19 #include "base/macros.h" 20 #include "base/macros.h"
20 #include "base/memory/scoped_ptr.h"
21 #include "base/memory/scoped_vector.h" 21 #include "base/memory/scoped_vector.h"
22 #include "base/memory/weak_ptr.h" 22 #include "base/memory/weak_ptr.h"
23 #include "base/sequence_checker.h" 23 #include "base/sequence_checker.h"
24 #include "base/values.h" 24 #include "base/values.h"
25 #include "chrome/browser/sync_file_system/drive_backend/tracker_id_set.h" 25 #include "chrome/browser/sync_file_system/drive_backend/tracker_id_set.h"
26 #include "chrome/browser/sync_file_system/sync_status_code.h" 26 #include "chrome/browser/sync_file_system/sync_status_code.h"
27 27
28 namespace leveldb { 28 namespace leveldb {
29 class Env; 29 class Env;
30 } 30 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 117
118 enum UpdateOption { 118 enum UpdateOption {
119 UPDATE_TRACKER_FOR_UNSYNCED_FILE, 119 UPDATE_TRACKER_FOR_UNSYNCED_FILE,
120 UPDATE_TRACKER_FOR_SYNCED_FILE, 120 UPDATE_TRACKER_FOR_SYNCED_FILE,
121 }; 121 };
122 122
123 // The entry point of the MetadataDatabase for production code. 123 // The entry point of the MetadataDatabase for production code.
124 // If |env_override| is non-NULL, internal LevelDB uses |env_override| instead 124 // If |env_override| is non-NULL, internal LevelDB uses |env_override| instead
125 // of leveldb::Env::Default(). Use leveldb::MemEnv in test code for faster 125 // of leveldb::Env::Default(). Use leveldb::MemEnv in test code for faster
126 // testing. 126 // testing.
127 static scoped_ptr<MetadataDatabase> Create( 127 static std::unique_ptr<MetadataDatabase> Create(
128 const base::FilePath& database_path, 128 const base::FilePath& database_path,
129 leveldb::Env* env_override, 129 leveldb::Env* env_override,
130 SyncStatusCode* status); 130 SyncStatusCode* status);
131 static scoped_ptr<MetadataDatabase> CreateInternal( 131 static std::unique_ptr<MetadataDatabase> CreateInternal(
132 const base::FilePath& database_path, 132 const base::FilePath& database_path,
133 leveldb::Env* env_override, 133 leveldb::Env* env_override,
134 bool enable_on_disk_index, 134 bool enable_on_disk_index,
135 SyncStatusCode* status); 135 SyncStatusCode* status);
136 static SyncStatusCode CreateForTesting( 136 static SyncStatusCode CreateForTesting(
137 scoped_ptr<LevelDBWrapper> db, 137 std::unique_ptr<LevelDBWrapper> db,
138 bool enable_on_disk_index, 138 bool enable_on_disk_index,
139 scoped_ptr<MetadataDatabase>* metadata_database_out); 139 std::unique_ptr<MetadataDatabase>* metadata_database_out);
140 140
141 ~MetadataDatabase(); 141 ~MetadataDatabase();
142 142
143 static void ClearDatabase(scoped_ptr<MetadataDatabase> metadata_database); 143 static void ClearDatabase(
144 std::unique_ptr<MetadataDatabase> metadata_database);
144 145
145 int64_t GetLargestFetchedChangeID() const; 146 int64_t GetLargestFetchedChangeID() const;
146 int64_t GetSyncRootTrackerID() const; 147 int64_t GetSyncRootTrackerID() const;
147 148
148 // Returns true if the client should check if the sync root is still valid. 149 // Returns true if the client should check if the sync root is still valid.
149 bool NeedsSyncRootRevalidation() const; 150 bool NeedsSyncRootRevalidation() const;
150 151
151 bool HasSyncRoot() const; 152 bool HasSyncRoot() const;
152 153
153 // Returns all file metadata for the given |app_id|. 154 // Returns all file metadata for the given |app_id|.
154 scoped_ptr<base::ListValue> DumpFiles(const std::string& app_id); 155 std::unique_ptr<base::ListValue> DumpFiles(const std::string& app_id);
155 156
156 // Returns all database data. 157 // Returns all database data.
157 scoped_ptr<base::ListValue> DumpDatabase(); 158 std::unique_ptr<base::ListValue> DumpDatabase();
158 159
159 // TODO(tzik): Move GetLargestKnownChangeID() to private section, and hide its 160 // TODO(tzik): Move GetLargestKnownChangeID() to private section, and hide its
160 // handling in the class, instead of letting user do. 161 // handling in the class, instead of letting user do.
161 // 162 //
162 // Gets / updates the largest known change ID. 163 // Gets / updates the largest known change ID.
163 // The largest known change ID is on-memory and not persist over restart. 164 // The largest known change ID is on-memory and not persist over restart.
164 // This is supposed to use when a task fetches ChangeList in parallel to other 165 // This is supposed to use when a task fetches ChangeList in parallel to other
165 // operation. When a task starts fetching paged ChangeList one by one, it 166 // operation. When a task starts fetching paged ChangeList one by one, it
166 // should update the largest known change ID on the first round and background 167 // should update the largest known change ID on the first round and background
167 // remaining fetch job. 168 // remaining fetch job.
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 bool CanActivateTracker(const FileTracker& tracker); 368 bool CanActivateTracker(const FileTracker& tracker);
368 bool ShouldKeepDirty(const FileTracker& tracker) const; 369 bool ShouldKeepDirty(const FileTracker& tracker) const;
369 370
370 bool HasDisabledAppRoot(const FileTracker& tracker) const; 371 bool HasDisabledAppRoot(const FileTracker& tracker) const;
371 bool HasActiveTrackerForFileID(const std::string& file_id) const; 372 bool HasActiveTrackerForFileID(const std::string& file_id) const;
372 bool HasActiveTrackerForPath(int64_t parent_tracker, 373 bool HasActiveTrackerForPath(int64_t parent_tracker,
373 const std::string& title) const; 374 const std::string& title) const;
374 375
375 void RemoveUnneededTrackersForMissingFile(const std::string& file_id); 376 void RemoveUnneededTrackersForMissingFile(const std::string& file_id);
376 void UpdateByFileMetadata(const tracked_objects::Location& from_where, 377 void UpdateByFileMetadata(const tracked_objects::Location& from_where,
377 scoped_ptr<FileMetadata> file, 378 std::unique_ptr<FileMetadata> file,
378 UpdateOption option); 379 UpdateOption option);
379 380
380 SyncStatusCode WriteToDatabase(); 381 SyncStatusCode WriteToDatabase();
381 382
382 bool HasNewerFileMetadata(const std::string& file_id, int64_t change_id); 383 bool HasNewerFileMetadata(const std::string& file_id, int64_t change_id);
383 384
384 scoped_ptr<base::ListValue> DumpTrackers(); 385 std::unique_ptr<base::ListValue> DumpTrackers();
385 scoped_ptr<base::ListValue> DumpMetadata(); 386 std::unique_ptr<base::ListValue> DumpMetadata();
386 387
387 void AttachSyncRoot(const google_apis::FileResource& sync_root_folder); 388 void AttachSyncRoot(const google_apis::FileResource& sync_root_folder);
388 void AttachInitialAppRoot(const google_apis::FileResource& app_root_folder); 389 void AttachInitialAppRoot(const google_apis::FileResource& app_root_folder);
389 390
390 void ForceActivateTrackerByPath(int64_t parent_tracker_id, 391 void ForceActivateTrackerByPath(int64_t parent_tracker_id,
391 const std::string& title, 392 const std::string& title,
392 const std::string& file_id); 393 const std::string& file_id);
393 394
394 bool CanClearDirty(const FileTracker& tracker); 395 bool CanClearDirty(const FileTracker& tracker);
395 396
396 base::FilePath database_path_; 397 base::FilePath database_path_;
397 leveldb::Env* env_override_; 398 leveldb::Env* env_override_;
398 scoped_ptr<LevelDBWrapper> db_; 399 std::unique_ptr<LevelDBWrapper> db_;
399 400
400 bool enable_on_disk_index_; 401 bool enable_on_disk_index_;
401 402
402 int64_t largest_known_change_id_; 403 int64_t largest_known_change_id_;
403 404
404 scoped_ptr<MetadataDatabaseIndexInterface> index_; 405 std::unique_ptr<MetadataDatabaseIndexInterface> index_;
405 406
406 base::WeakPtrFactory<MetadataDatabase> weak_ptr_factory_; 407 base::WeakPtrFactory<MetadataDatabase> weak_ptr_factory_;
407 408
408 DISALLOW_COPY_AND_ASSIGN(MetadataDatabase); 409 DISALLOW_COPY_AND_ASSIGN(MetadataDatabase);
409 }; 410 };
410 411
411 } // namespace drive_backend 412 } // namespace drive_backend
412 } // namespace sync_file_system 413 } // namespace sync_file_system
413 414
414 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_H_ 415 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698