diff options
Diffstat (limited to 'chrome/browser/sync_file_system/drive_backend')
70 files changed, 555 insertions, 447 deletions
diff --git a/chrome/browser/sync_file_system/drive_backend/callback_helper.h b/chrome/browser/sync_file_system/drive_backend/callback_helper.h index d976acc..80a2e44 100644 --- a/chrome/browser/sync_file_system/drive_backend/callback_helper.h +++ b/chrome/browser/sync_file_system/drive_backend/callback_helper.h @@ -10,6 +10,7 @@ #include "base/bind.h" #include "base/location.h" #include "base/logging.h" +#include "base/macros.h" #include "base/sequenced_task_runner.h" #include "base/thread_task_runner_handle.h" diff --git a/chrome/browser/sync_file_system/drive_backend/callback_tracker.h b/chrome/browser/sync_file_system/drive_backend/callback_tracker.h index f3b1172..324e438 100644 --- a/chrome/browser/sync_file_system/drive_backend/callback_tracker.h +++ b/chrome/browser/sync_file_system/drive_backend/callback_tracker.h @@ -9,6 +9,7 @@ #include "base/bind.h" #include "base/callback_forward.h" +#include "base/macros.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/sync_file_system/drive_backend/callback_tracker_internal.h" diff --git a/chrome/browser/sync_file_system/drive_backend/callback_tracker_internal.h b/chrome/browser/sync_file_system/drive_backend/callback_tracker_internal.h index 665d2c1..0fb9eb4 100644 --- a/chrome/browser/sync_file_system/drive_backend/callback_tracker_internal.h +++ b/chrome/browser/sync_file_system/drive_backend/callback_tracker_internal.h @@ -7,6 +7,7 @@ #include "base/callback.h" #include "base/callback_internal.h" +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" diff --git a/chrome/browser/sync_file_system/drive_backend/conflict_resolver.cc b/chrome/browser/sync_file_system/drive_backend/conflict_resolver.cc index 3a9e673..91c9c48 100644 --- a/chrome/browser/sync_file_system/drive_backend/conflict_resolver.cc +++ b/chrome/browser/sync_file_system/drive_backend/conflict_resolver.cc @@ -4,6 +4,8 @@ #include "chrome/browser/sync_file_system/drive_backend/conflict_resolver.h" +#include <stdint.h> + #include "base/callback.h" #include "base/format_macros.h" #include "base/location.h" @@ -96,7 +98,7 @@ void ConflictResolver::RunExclusive(scoped_ptr<SyncTaskToken> token) { if (metadata_database()->GetConflictingTrackers(&trackers)) { target_file_id_ = PickPrimaryFile(trackers); DCHECK(!target_file_id_.empty()); - int64 primary_tracker_id = -1; + int64_t primary_tracker_id = -1; for (TrackerIDSet::const_iterator itr = trackers.begin(); itr != trackers.end(); ++itr) { FileTracker tracker; diff --git a/chrome/browser/sync_file_system/drive_backend/conflict_resolver.h b/chrome/browser/sync_file_system/drive_backend/conflict_resolver.h index e0cfef7..ae2e1f5 100644 --- a/chrome/browser/sync_file_system/drive_backend/conflict_resolver.h +++ b/chrome/browser/sync_file_system/drive_backend/conflict_resolver.h @@ -9,6 +9,7 @@ #include <utility> #include <vector> +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/sync_file_system/drive_backend/sync_task.h" diff --git a/chrome/browser/sync_file_system/drive_backend/conflict_resolver_unittest.cc b/chrome/browser/sync_file_system/drive_backend/conflict_resolver_unittest.cc index 64dc3ec..dec53c9 100644 --- a/chrome/browser/sync_file_system/drive_backend/conflict_resolver_unittest.cc +++ b/chrome/browser/sync_file_system/drive_backend/conflict_resolver_unittest.cc @@ -8,6 +8,7 @@ #include "base/callback.h" #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" +#include "base/macros.h" #include "base/run_loop.h" #include "base/thread_task_runner_handle.h" #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.h" diff --git a/chrome/browser/sync_file_system/drive_backend/drive_backend_constants.cc b/chrome/browser/sync_file_system/drive_backend/drive_backend_constants.cc index 8c96289..bfcd4b0 100644 --- a/chrome/browser/sync_file_system/drive_backend/drive_backend_constants.cc +++ b/chrome/browser/sync_file_system/drive_backend/drive_backend_constants.cc @@ -14,8 +14,8 @@ const base::FilePath::CharType kDatabaseName[] = FILE_PATH_LITERAL("DriveMetadata_v2"); const char kDatabaseVersionKey[] = "VERSION"; -const int64 kCurrentDatabaseVersion = 3; -const int64 kDatabaseOnDiskVersion = 4; +const int64_t kCurrentDatabaseVersion = 3; +const int64_t kDatabaseOnDiskVersion = 4; const char kServiceMetadataKey[] = "SERVICE"; const char kFileMetadataKeyPrefix[] = "FILE: "; const char kFileTrackerKeyPrefix[] = "TRACKER: "; @@ -32,9 +32,9 @@ const char kDirtyIDKeyPrefix[] = "DIRTY: "; const char kDemotedDirtyIDKeyPrefix[] = "DEMOTED_DIRTY: "; const int kMaxRetry = 5; -const int64 kListChangesRetryDelaySeconds = 60 * 60; +const int64_t kListChangesRetryDelaySeconds = 60 * 60; -const int64 kInvalidTrackerID = 0; +const int64_t kInvalidTrackerID = 0; } // namespace drive_backend } // namespace sync_file_system diff --git a/chrome/browser/sync_file_system/drive_backend/drive_backend_constants.h b/chrome/browser/sync_file_system/drive_backend/drive_backend_constants.h index 292393e..f342e5d5 100644 --- a/chrome/browser/sync_file_system/drive_backend/drive_backend_constants.h +++ b/chrome/browser/sync_file_system/drive_backend/drive_backend_constants.h @@ -5,6 +5,8 @@ #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_DRIVE_BACKEND_CONSTANTS_H_ #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_DRIVE_BACKEND_CONSTANTS_H_ +#include <stdint.h> + #include "base/files/file_path.h" namespace sync_file_system { @@ -16,8 +18,8 @@ extern const char kMimeTypeOctetStream[]; extern const base::FilePath::CharType kDatabaseName[]; extern const char kDatabaseVersionKey[]; -extern const int64 kCurrentDatabaseVersion; -extern const int64 kDatabaseOnDiskVersion; +extern const int64_t kCurrentDatabaseVersion; +extern const int64_t kDatabaseOnDiskVersion; extern const char kServiceMetadataKey[]; extern const char kFileMetadataKeyPrefix[]; extern const char kFileTrackerKeyPrefix[]; @@ -34,9 +36,9 @@ extern const char kDirtyIDKeyPrefix[]; extern const char kDemotedDirtyIDKeyPrefix[]; extern const int kMaxRetry; -extern const int64 kListChangesRetryDelaySeconds; +extern const int64_t kListChangesRetryDelaySeconds; -extern const int64 kInvalidTrackerID; +extern const int64_t kInvalidTrackerID; } // namespace drive_backend } // namespace sync_file_system diff --git a/chrome/browser/sync_file_system/drive_backend/drive_backend_sync_unittest.cc b/chrome/browser/sync_file_system/drive_backend/drive_backend_sync_unittest.cc index 110a6d4..b2589ca 100644 --- a/chrome/browser/sync_file_system/drive_backend/drive_backend_sync_unittest.cc +++ b/chrome/browser/sync_file_system/drive_backend/drive_backend_sync_unittest.cc @@ -2,10 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <stddef.h> +#include <stdint.h> + #include <algorithm> #include <stack> #include "base/files/file_util.h" +#include "base/macros.h" #include "base/message_loop/message_loop.h" #include "base/run_loop.h" #include "base/thread_task_runner_handle.h" @@ -156,11 +160,11 @@ class DriveBackendSyncTest : public testing::Test, RevokeSyncableFileSystem(); } - void OnRemoteChangeQueueUpdated(int64 pending_changes_hint) override { + void OnRemoteChangeQueueUpdated(int64_t pending_changes_hint) override { pending_remote_changes_ = pending_changes_hint; } - void OnLocalChangeAvailable(int64 pending_changes_hint) override { + void OnLocalChangeAvailable(int64_t pending_changes_hint) override { pending_local_changes_ = pending_changes_hint; } @@ -274,8 +278,8 @@ class DriveBackendSyncTest : public testing::Test, storage::FileSystemURL url(CreateURL(app_id, path)); ASSERT_TRUE(ContainsKey(file_systems_, app_id)); EXPECT_EQ(base::File::FILE_OK, file_systems_[app_id]->CreateFile(url)); - int64 bytes_written = file_systems_[app_id]->WriteString(url, content); - EXPECT_EQ(static_cast<int64>(content.size()), bytes_written); + int64_t bytes_written = file_systems_[app_id]->WriteString(url, content); + EXPECT_EQ(static_cast<int64_t>(content.size()), bytes_written); base::RunLoop().RunUntilIdle(); } @@ -283,9 +287,9 @@ class DriveBackendSyncTest : public testing::Test, const base::FilePath::StringType& path, const std::string& content) { ASSERT_TRUE(ContainsKey(file_systems_, app_id)); - int64 bytes_written = file_systems_[app_id]->WriteString( - CreateURL(app_id, path), content); - EXPECT_EQ(static_cast<int64>(content.size()), bytes_written); + int64_t bytes_written = + file_systems_[app_id]->WriteString(CreateURL(app_id, path), content); + EXPECT_EQ(static_cast<int64_t>(content.size()), bytes_written); base::RunLoop().RunUntilIdle(); } @@ -319,7 +323,7 @@ class DriveBackendSyncTest : public testing::Test, return status; } - int64 GetLargestChangeID() { + int64_t GetLargestChangeID() { scoped_ptr<google_apis::AboutResource> about_resource; EXPECT_EQ(google_apis::HTTP_SUCCESS, fake_drive_service_helper()->GetAboutResource(&about_resource)); @@ -374,14 +378,12 @@ class DriveBackendSyncTest : public testing::Test, continue; base::RunLoop run_loop; - int64 largest_fetched_change_id = -1; + int64_t largest_fetched_change_id = -1; PostTaskAndReplyWithResult( - worker_task_runner_.get(), - FROM_HERE, + worker_task_runner_.get(), FROM_HERE, base::Bind(&MetadataDatabase::GetLargestFetchedChangeID, base::Unretained(metadata_database())), - base::Bind(&SetValueAndCallClosure<int64>, - run_loop.QuitClosure(), + base::Bind(&SetValueAndCallClosure<int64_t>, run_loop.QuitClosure(), &largest_fetched_change_id)); run_loop.Run(); if (largest_fetched_change_id != GetLargestChangeID()) { @@ -627,8 +629,8 @@ class DriveBackendSyncTest : public testing::Test, scoped_ptr<SyncEngine> remote_sync_service_; scoped_ptr<LocalFileSyncService> local_sync_service_; - int64 pending_remote_changes_; - int64 pending_local_changes_; + int64_t pending_remote_changes_; + int64_t pending_local_changes_; scoped_ptr<FakeDriveServiceHelper> fake_drive_service_helper_; std::map<std::string, CannedSyncableFileSystem*> file_systems_; diff --git a/chrome/browser/sync_file_system/drive_backend/drive_backend_test_util.cc b/chrome/browser/sync_file_system/drive_backend/drive_backend_test_util.cc index 2904e26..4f13ff0 100644 --- a/chrome/browser/sync_file_system/drive_backend/drive_backend_test_util.cc +++ b/chrome/browser/sync_file_system/drive_backend/drive_backend_test_util.cc @@ -88,12 +88,12 @@ scoped_ptr<FileMetadata> CreateFileMetadata(const std::string& file_id, } scoped_ptr<FileTracker> CreateTracker(const FileMetadata& metadata, - int64 tracker_id, + int64_t tracker_id, const FileTracker* parent_tracker) { scoped_ptr<FileTracker> tracker(new FileTracker); tracker->set_tracker_id(tracker_id); - int64 parent_id = parent_tracker ? - parent_tracker->tracker_id() : kInvalidTrackerID; + int64_t parent_id = + parent_tracker ? parent_tracker->tracker_id() : kInvalidTrackerID; tracker->set_parent_tracker_id(parent_id); tracker->set_file_id(metadata.file_id()); if (parent_tracker) @@ -108,7 +108,7 @@ scoped_ptr<FileTracker> CreateTracker(const FileMetadata& metadata, scoped_ptr<FileTracker> CreatePlaceholderTracker( const std::string& file_id, - int64 tracker_id, + int64_t tracker_id, const FileTracker* parent_tracker) { scoped_ptr<FileTracker> tracker(new FileTracker); tracker->set_tracker_id(tracker_id); diff --git a/chrome/browser/sync_file_system/drive_backend/drive_backend_test_util.h b/chrome/browser/sync_file_system/drive_backend/drive_backend_test_util.h index d016381..e399f12 100644 --- a/chrome/browser/sync_file_system/drive_backend/drive_backend_test_util.h +++ b/chrome/browser/sync_file_system/drive_backend/drive_backend_test_util.h @@ -5,6 +5,8 @@ #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_DRIVE_BACKEND_TEST_UTIL_H_ #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_DRIVE_BACKEND_TEST_UTIL_H_ +#include <stdint.h> + #include "base/memory/scoped_ptr.h" #include "chrome/browser/sync_file_system/sync_status_code.h" #include "google_apis/drive/drive_api_error_codes.h" @@ -36,11 +38,11 @@ scoped_ptr<FileMetadata> CreateFileMetadata(const std::string& file_id, const std::string& title, const std::string& md5); scoped_ptr<FileTracker> CreateTracker(const FileMetadata& metadata, - int64 tracker_id, + int64_t tracker_id, const FileTracker* parent_tracker); scoped_ptr<FileTracker> CreatePlaceholderTracker( const std::string& file_id, - int64 tracker_id, + int64_t tracker_id, const FileTracker* parent_tracker); // The return value type of GetFileResourceKind(). diff --git a/chrome/browser/sync_file_system/drive_backend/drive_backend_util.cc b/chrome/browser/sync_file_system/drive_backend/drive_backend_util.cc index d41d311..40c25e3 100644 --- a/chrome/browser/sync_file_system/drive_backend/drive_backend_util.cc +++ b/chrome/browser/sync_file_system/drive_backend/drive_backend_util.cc @@ -19,7 +19,7 @@ namespace sync_file_system { namespace drive_backend { -void PutVersionToDB(int64 version, LevelDBWrapper* db) { +void PutVersionToDB(int64_t version, LevelDBWrapper* db) { DCHECK(db); db->Put(kDatabaseVersionKey, base::Int64ToString(version)); } @@ -59,7 +59,7 @@ void PutFileMetadataDeletionToDB(const std::string& file_id, db->Delete(kFileMetadataKeyPrefix + file_id); } -void PutFileTrackerDeletionToDB(int64 tracker_id, LevelDBWrapper* db) { +void PutFileTrackerDeletionToDB(int64_t tracker_id, LevelDBWrapper* db) { DCHECK(db); db->Delete(kFileTrackerKeyPrefix + base::Int64ToString(tracker_id)); } diff --git a/chrome/browser/sync_file_system/drive_backend/drive_backend_util.h b/chrome/browser/sync_file_system/drive_backend/drive_backend_util.h index 4702994..d393776 100644 --- a/chrome/browser/sync_file_system/drive_backend/drive_backend_util.h +++ b/chrome/browser/sync_file_system/drive_backend/drive_backend_util.h @@ -5,6 +5,8 @@ #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_DRIVE_BACKEND_UTIL_H_ #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_DRIVE_BACKEND_UTIL_H_ +#include <stdint.h> + #include <string> #include "base/bind.h" @@ -25,7 +27,7 @@ namespace drive_backend { class LevelDBWrapper; -void PutVersionToDB(int64 version, LevelDBWrapper* db); +void PutVersionToDB(int64_t version, LevelDBWrapper* db); void PutServiceMetadataToDB(const ServiceMetadata& service_metadata, LevelDBWrapper* db); @@ -34,7 +36,7 @@ void PutFileTrackerToDB(const FileTracker& tracker, LevelDBWrapper* db); void PutFileMetadataDeletionToDB(const std::string& file_id, LevelDBWrapper* db); -void PutFileTrackerDeletionToDB(int64 tracker_id, LevelDBWrapper* db); +void PutFileTrackerDeletionToDB(int64_t tracker_id, LevelDBWrapper* db); bool HasFileAsParent(const FileDetails& details, const std::string& file_id); diff --git a/chrome/browser/sync_file_system/drive_backend/drive_service_on_worker.cc b/chrome/browser/sync_file_system/drive_backend/drive_service_on_worker.cc index a7bf05b..7dc6f28 100644 --- a/chrome/browser/sync_file_system/drive_backend/drive_service_on_worker.cc +++ b/chrome/browser/sync_file_system/drive_backend/drive_service_on_worker.cc @@ -106,7 +106,7 @@ google_apis::CancelCallback DriveServiceOnWorker::GetAboutResource( } google_apis::CancelCallback DriveServiceOnWorker::GetChangeList( - int64 start_changestamp, + int64_t start_changestamp, const google_apis::ChangeListCallback& callback) { DCHECK(sequence_checker_.CalledOnValidSequencedThread()); @@ -335,7 +335,7 @@ google_apis::CancelCallback DriveServiceOnWorker::AddResourceToDirectory( google_apis::CancelCallback DriveServiceOnWorker::InitiateUploadNewFile( const std::string& content_type, - int64 content_length, + int64_t content_length, const std::string& parent_resource_id, const std::string& title, const drive::UploadNewFileOptions& options, @@ -346,7 +346,7 @@ google_apis::CancelCallback DriveServiceOnWorker::InitiateUploadNewFile( google_apis::CancelCallback DriveServiceOnWorker::InitiateUploadExistingFile( const std::string& content_type, - int64 content_length, + int64_t content_length, const std::string& resource_id, const drive::UploadExistingFileOptions& options, const google_apis::InitiateUploadCallback& callback) { @@ -356,9 +356,9 @@ google_apis::CancelCallback DriveServiceOnWorker::InitiateUploadExistingFile( google_apis::CancelCallback DriveServiceOnWorker::ResumeUpload( const GURL& upload_url, - int64 start_position, - int64 end_position, - int64 content_length, + int64_t start_position, + int64_t end_position, + int64_t content_length, const std::string& content_type, const base::FilePath& local_file_path, const google_apis::drive::UploadRangeCallback& callback, @@ -369,7 +369,7 @@ google_apis::CancelCallback DriveServiceOnWorker::ResumeUpload( google_apis::CancelCallback DriveServiceOnWorker::GetUploadStatus( const GURL& upload_url, - int64 content_length, + int64_t content_length, const google_apis::drive::UploadRangeCallback& callback) { NOTREACHED(); return google_apis::CancelCallback(); @@ -377,7 +377,7 @@ google_apis::CancelCallback DriveServiceOnWorker::GetUploadStatus( google_apis::CancelCallback DriveServiceOnWorker::MultipartUploadNewFile( const std::string& content_type, - int64 content_length, + int64_t content_length, const std::string& parent_resource_id, const std::string& title, const base::FilePath& local_file_path, @@ -390,7 +390,7 @@ google_apis::CancelCallback DriveServiceOnWorker::MultipartUploadNewFile( google_apis::CancelCallback DriveServiceOnWorker::MultipartUploadExistingFile( const std::string& content_type, - int64 content_length, + int64_t content_length, const std::string& parent_resource_id, const base::FilePath& local_file_path, const drive::UploadExistingFileOptions& options, diff --git a/chrome/browser/sync_file_system/drive_backend/drive_service_on_worker.h b/chrome/browser/sync_file_system/drive_backend/drive_service_on_worker.h index 57eafe7..12d6afc 100644 --- a/chrome/browser/sync_file_system/drive_backend/drive_service_on_worker.h +++ b/chrome/browser/sync_file_system/drive_backend/drive_service_on_worker.h @@ -5,6 +5,9 @@ #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_DRIVE_SERVICE_ON_WORKER_H_ #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_DRIVE_SERVICE_ON_WORKER_H_ +#include <stdint.h> + +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/sequence_checker.h" @@ -54,7 +57,7 @@ class DriveServiceOnWorker : public drive::DriveServiceInterface { const google_apis::AboutResourceCallback& callback) override; google_apis::CancelCallback GetChangeList( - int64 start_changestamp, + int64_t start_changestamp, const google_apis::ChangeListCallback& callback) override; google_apis::CancelCallback GetRemainingChangeList( @@ -131,33 +134,33 @@ class DriveServiceOnWorker : public drive::DriveServiceInterface { const google_apis::EntryActionCallback& callback) override; google_apis::CancelCallback InitiateUploadNewFile( const std::string& content_type, - int64 content_length, + int64_t content_length, const std::string& parent_resource_id, const std::string& title, const drive::UploadNewFileOptions& options, const google_apis::InitiateUploadCallback& callback) override; google_apis::CancelCallback InitiateUploadExistingFile( const std::string& content_type, - int64 content_length, + int64_t content_length, const std::string& resource_id, const drive::UploadExistingFileOptions& options, const google_apis::InitiateUploadCallback& callback) override; google_apis::CancelCallback ResumeUpload( const GURL& upload_url, - int64 start_position, - int64 end_position, - int64 content_length, + int64_t start_position, + int64_t end_position, + int64_t content_length, const std::string& content_type, const base::FilePath& local_file_path, const google_apis::drive::UploadRangeCallback& callback, const google_apis::ProgressCallback& progress_callback) override; google_apis::CancelCallback GetUploadStatus( const GURL& upload_url, - int64 content_length, + int64_t content_length, const google_apis::drive::UploadRangeCallback& callback) override; google_apis::CancelCallback MultipartUploadNewFile( const std::string& content_type, - int64 content_length, + int64_t content_length, const std::string& parent_resource_id, const std::string& title, const base::FilePath& local_file_path, @@ -166,7 +169,7 @@ class DriveServiceOnWorker : public drive::DriveServiceInterface { const google_apis::ProgressCallback& progress_callback) override; google_apis::CancelCallback MultipartUploadExistingFile( const std::string& content_type, - int64 content_length, + int64_t content_length, const std::string& resource_id, const base::FilePath& local_file_path, const drive::UploadExistingFileOptions& options, diff --git a/chrome/browser/sync_file_system/drive_backend/drive_service_wrapper.cc b/chrome/browser/sync_file_system/drive_backend/drive_service_wrapper.cc index 534f244..e7a2984 100644 --- a/chrome/browser/sync_file_system/drive_backend/drive_service_wrapper.cc +++ b/chrome/browser/sync_file_system/drive_backend/drive_service_wrapper.cc @@ -61,7 +61,7 @@ void DriveServiceWrapper::GetAboutResource( } void DriveServiceWrapper::GetChangeList( - int64 start_changestamp, + int64_t start_changestamp, const google_apis::ChangeListCallback& callback) { DCHECK(sequece_checker_.CalledOnValidSequencedThread()); drive_service_->GetChangeList(start_changestamp, callback); diff --git a/chrome/browser/sync_file_system/drive_backend/drive_service_wrapper.h b/chrome/browser/sync_file_system/drive_backend/drive_service_wrapper.h index fa7160e..9eca838 100644 --- a/chrome/browser/sync_file_system/drive_backend/drive_service_wrapper.h +++ b/chrome/browser/sync_file_system/drive_backend/drive_service_wrapper.h @@ -5,6 +5,9 @@ #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_DRIVE_SERVICE_WRAPPER_H_ #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_DRIVE_SERVICE_WRAPPER_H_ +#include <stdint.h> + +#include "base/macros.h" #include "base/memory/weak_ptr.h" #include "base/sequence_checker.h" #include "components/drive/service/drive_service_interface.h" @@ -40,9 +43,8 @@ class DriveServiceWrapper : public base::SupportsWeakPtr<DriveServiceWrapper> { void GetAboutResource( const google_apis::AboutResourceCallback& callback); - void GetChangeList( - int64 start_changestamp, - const google_apis::ChangeListCallback& callback); + void GetChangeList(int64_t start_changestamp, + const google_apis::ChangeListCallback& callback); void GetRemainingChangeList( const GURL& next_link, diff --git a/chrome/browser/sync_file_system/drive_backend/drive_uploader_on_worker.h b/chrome/browser/sync_file_system/drive_backend/drive_uploader_on_worker.h index cfd2c39..b7a6924 100644 --- a/chrome/browser/sync_file_system/drive_backend/drive_uploader_on_worker.h +++ b/chrome/browser/sync_file_system/drive_backend/drive_uploader_on_worker.h @@ -7,6 +7,7 @@ #include <string> +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/sequence_checker.h" diff --git a/chrome/browser/sync_file_system/drive_backend/drive_uploader_wrapper.h b/chrome/browser/sync_file_system/drive_backend/drive_uploader_wrapper.h index 4bdd548..621aafa 100644 --- a/chrome/browser/sync_file_system/drive_backend/drive_uploader_wrapper.h +++ b/chrome/browser/sync_file_system/drive_backend/drive_uploader_wrapper.h @@ -5,6 +5,7 @@ #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_DRIVE_UPLOADER_WRAPPER_H_ #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_DRIVE_UPLOADER_WRAPPER_H_ +#include "base/macros.h" #include "base/memory/weak_ptr.h" #include "base/sequence_checker.h" #include "components/drive/drive_uploader.h" diff --git a/chrome/browser/sync_file_system/drive_backend/fake_drive_uploader.h b/chrome/browser/sync_file_system/drive_backend/fake_drive_uploader.h index da79223..e46373b 100644 --- a/chrome/browser/sync_file_system/drive_backend/fake_drive_uploader.h +++ b/chrome/browser/sync_file_system/drive_backend/fake_drive_uploader.h @@ -8,6 +8,7 @@ #include <string> #include "base/files/file_util.h" +#include "base/macros.h" #include "base/strings/stringprintf.h" #include "base/values.h" #include "chrome/browser/sync_file_system/drive_backend/fake_drive_service_helper.h" diff --git a/chrome/browser/sync_file_system/drive_backend/fake_sync_worker.h b/chrome/browser/sync_file_system/drive_backend/fake_sync_worker.h index 2103427..f242d43 100644 --- a/chrome/browser/sync_file_system/drive_backend/fake_sync_worker.h +++ b/chrome/browser/sync_file_system/drive_backend/fake_sync_worker.h @@ -9,6 +9,7 @@ #include <string> #include "base/callback.h" +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/observer_list.h" #include "base/sequence_checker.h" diff --git a/chrome/browser/sync_file_system/drive_backend/folder_creator.cc b/chrome/browser/sync_file_system/drive_backend/folder_creator.cc index 1681184..40baec3 100644 --- a/chrome/browser/sync_file_system/drive_backend/folder_creator.cc +++ b/chrome/browser/sync_file_system/drive_backend/folder_creator.cc @@ -4,6 +4,8 @@ #include "chrome/browser/sync_file_system/drive_backend/folder_creator.h" +#include <stddef.h> + #include "chrome/browser/sync_file_system/drive_backend/drive_backend_util.h" #include "chrome/browser/sync_file_system/drive_backend/metadata_database.h" #include "components/drive/drive_api_util.h" diff --git a/chrome/browser/sync_file_system/drive_backend/folder_creator.h b/chrome/browser/sync_file_system/drive_backend/folder_creator.h index 2bce176..d00e7f2 100644 --- a/chrome/browser/sync_file_system/drive_backend/folder_creator.h +++ b/chrome/browser/sync_file_system/drive_backend/folder_creator.h @@ -7,6 +7,7 @@ #include <string> +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/memory/scoped_vector.h" #include "base/memory/weak_ptr.h" diff --git a/chrome/browser/sync_file_system/drive_backend/leveldb_wrapper.h b/chrome/browser/sync_file_system/drive_backend/leveldb_wrapper.h index 424db40..036e943 100644 --- a/chrome/browser/sync_file_system/drive_backend/leveldb_wrapper.h +++ b/chrome/browser/sync_file_system/drive_backend/leveldb_wrapper.h @@ -5,10 +5,11 @@ #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_LEVELDB_WRAPPER_H_ #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_LEVELDB_WRAPPER_H_ +#include <stdint.h> + #include <map> #include <string> -#include "base/basictypes.h" #include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "third_party/leveldatabase/src/include/leveldb/slice.h" @@ -93,8 +94,8 @@ class LevelDBWrapper { // Returns the number of pending PUT/DELETE operations. // Each counter counts operations independently, so operations on a key // may be counted more than once. - int64 num_puts() { return num_puts_; } - int64 num_deletes() { return num_deletes_; } + int64_t num_puts() { return num_puts_; } + int64_t num_deletes() { return num_deletes_; } // TODO(peria): Rename this method to GetLevelDBForTesting, after removing // usages of drive_backend::MigrateDatabaseFromVxToVy() under @@ -105,8 +106,8 @@ class LevelDBWrapper { scoped_ptr<leveldb::DB> db_; PendingOperationMap pending_; - int64 num_puts_; - int64 num_deletes_; + int64_t num_puts_; + int64_t num_deletes_; DISALLOW_COPY_AND_ASSIGN(LevelDBWrapper); }; diff --git a/chrome/browser/sync_file_system/drive_backend/leveldb_wrapper_unittest.cc b/chrome/browser/sync_file_system/drive_backend/leveldb_wrapper_unittest.cc index a8afb55..a61fc11 100644 --- a/chrome/browser/sync_file_system/drive_backend/leveldb_wrapper_unittest.cc +++ b/chrome/browser/sync_file_system/drive_backend/leveldb_wrapper_unittest.cc @@ -4,10 +4,13 @@ #include "chrome/browser/sync_file_system/drive_backend/leveldb_wrapper.h" +#include <stddef.h> + #include <string> #include "base/files/scoped_temp_dir.h" #include "base/logging.h" +#include "base/macros.h" #include "base/strings/string_number_conversions.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/leveldatabase/src/helpers/memenv/memenv.h" diff --git a/chrome/browser/sync_file_system/drive_backend/list_changes_task.cc b/chrome/browser/sync_file_system/drive_backend/list_changes_task.cc index 783ca26..de9b3cc 100644 --- a/chrome/browser/sync_file_system/drive_backend/list_changes_task.cc +++ b/chrome/browser/sync_file_system/drive_backend/list_changes_task.cc @@ -4,6 +4,8 @@ #include "chrome/browser/sync_file_system/drive_backend/list_changes_task.h" +#include <stddef.h> + #include <vector> #include "base/bind.h" @@ -108,7 +110,7 @@ void ListChangesTask::DidListChanges( change_list->largest_change_id())); } -void ListChangesTask::CheckInChangeList(int64 largest_change_id, +void ListChangesTask::CheckInChangeList(int64_t largest_change_id, scoped_ptr<SyncTaskToken> token) { token->RecordLog(base::StringPrintf( "Got %" PRIuS " changes, updating MetadataDatabase.", diff --git a/chrome/browser/sync_file_system/drive_backend/list_changes_task.h b/chrome/browser/sync_file_system/drive_backend/list_changes_task.h index d94cb7a..7e9255e 100644 --- a/chrome/browser/sync_file_system/drive_backend/list_changes_task.h +++ b/chrome/browser/sync_file_system/drive_backend/list_changes_task.h @@ -5,6 +5,9 @@ #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_LIST_CHANGES_TASK_H_ #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_LIST_CHANGES_TASK_H_ +#include <stdint.h> + +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/memory/scoped_vector.h" #include "base/memory/weak_ptr.h" @@ -38,7 +41,7 @@ class ListChangesTask : public SyncTask { void DidListChanges(scoped_ptr<SyncTaskToken> token, google_apis::DriveApiErrorCode error, scoped_ptr<google_apis::ChangeList> change_list); - void CheckInChangeList(int64 largest_change_id, + void CheckInChangeList(int64_t largest_change_id, scoped_ptr<SyncTaskToken> token); bool IsContextReady(); diff --git a/chrome/browser/sync_file_system/drive_backend/list_changes_task_unittest.cc b/chrome/browser/sync_file_system/drive_backend/list_changes_task_unittest.cc index 8216c1f..0c7e1f3 100644 --- a/chrome/browser/sync_file_system/drive_backend/list_changes_task_unittest.cc +++ b/chrome/browser/sync_file_system/drive_backend/list_changes_task_unittest.cc @@ -4,10 +4,13 @@ #include "chrome/browser/sync_file_system/drive_backend/list_changes_task.h" +#include <stddef.h> + #include <string> #include "base/files/scoped_temp_dir.h" #include "base/format_macros.h" +#include "base/macros.h" #include "base/run_loop.h" #include "base/thread_task_runner_handle.h" #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.h" diff --git a/chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.cc b/chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.cc index 220d384..f205186 100644 --- a/chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.cc +++ b/chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.cc @@ -37,7 +37,7 @@ namespace drive_backend { namespace { scoped_ptr<FileTracker> FindTrackerByID(MetadataDatabase* metadata_database, - int64 tracker_id) { + int64_t tracker_id) { scoped_ptr<FileTracker> tracker(new FileTracker); if (metadata_database->FindTrackerByTrackerID(tracker_id, tracker.get())) return tracker.Pass(); @@ -46,7 +46,7 @@ scoped_ptr<FileTracker> FindTrackerByID(MetadataDatabase* metadata_database, bool GetKnownChangeID(MetadataDatabase* metadata_database, const std::string& file_id, - int64* change_id) { + int64_t* change_id) { FileMetadata remote_file_metadata; if (!metadata_database->FindFileByFileID(file_id, &remote_file_metadata)) return false; @@ -295,7 +295,7 @@ void LocalToRemoteSyncer::ContinueAsBackgroundTask( // - Others, SyncEngineInitializer and RegisterAppTask doesn't affect to // LocalToRemoteSyncer. if (remote_file_tracker_) { - int64 latest_change_id = 0; + int64_t latest_change_id = 0; if (!GetKnownChangeID(metadata_database(), remote_file_tracker_->file_id(), &latest_change_id) || diff --git a/chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.h b/chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.h index f0b77ed..6cec015 100644 --- a/chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.h +++ b/chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.h @@ -5,8 +5,11 @@ #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_LOCAL_TO_REMOTE_SYNCER_H_ #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_LOCAL_TO_REMOTE_SYNCER_H_ +#include <stdint.h> + #include <string> +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/sync_file_system/drive_backend/sync_task.h" @@ -117,7 +120,7 @@ class LocalToRemoteSyncer : public SyncTask { scoped_ptr<FileTracker> remote_file_tracker_; scoped_ptr<FileTracker> remote_parent_folder_tracker_; base::FilePath target_path_; - int64 remote_file_change_id_; + int64_t remote_file_change_id_; bool retry_on_success_; bool needs_remote_change_listing_; diff --git a/chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer_unittest.cc b/chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer_unittest.cc index 89bd5a3..c0804d1 100644 --- a/chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer_unittest.cc +++ b/chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer_unittest.cc @@ -8,6 +8,7 @@ #include "base/callback.h" #include "base/files/scoped_temp_dir.h" #include "base/logging.h" +#include "base/macros.h" #include "base/run_loop.h" #include "base/thread_task_runner_handle.h" #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.h" diff --git a/chrome/browser/sync_file_system/drive_backend/metadata_database.cc b/chrome/browser/sync_file_system/drive_backend/metadata_database.cc index 52c741c..02561d0 100644 --- a/chrome/browser/sync_file_system/drive_backend/metadata_database.cc +++ b/chrome/browser/sync_file_system/drive_backend/metadata_database.cc @@ -12,6 +12,7 @@ #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/location.h" +#include "base/macros.h" #include "base/memory/scoped_vector.h" #include "base/single_thread_task_runner.h" #include "base/stl_util.h" @@ -112,7 +113,7 @@ void PopulateFileDetailsByFileResource( } scoped_ptr<FileMetadata> CreateFileMetadataFromFileResource( - int64 change_id, + int64_t change_id, const google_apis::FileResource& resource) { scoped_ptr<FileMetadata> file(new FileMetadata); file->set_file_id(resource.file_id()); @@ -146,9 +147,8 @@ scoped_ptr<FileMetadata> CreateFileMetadataFromChangeResource( return file.Pass(); } -scoped_ptr<FileMetadata> CreateDeletedFileMetadata( - int64 change_id, - const std::string& file_id) { +scoped_ptr<FileMetadata> CreateDeletedFileMetadata(int64_t change_id, + const std::string& file_id) { scoped_ptr<FileMetadata> file(new FileMetadata); file->set_file_id(file_id); @@ -159,7 +159,7 @@ scoped_ptr<FileMetadata> CreateDeletedFileMetadata( } scoped_ptr<FileTracker> CreateSyncRootTracker( - int64 tracker_id, + int64_t tracker_id, const FileMetadata& sync_root_metadata) { scoped_ptr<FileTracker> sync_root_tracker(new FileTracker); sync_root_tracker->set_tracker_id(tracker_id); @@ -174,8 +174,8 @@ scoped_ptr<FileTracker> CreateSyncRootTracker( } scoped_ptr<FileTracker> CreateInitialAppRootTracker( - int64 tracker_id, - int64 parent_tracker_id, + int64_t tracker_id, + int64_t parent_tracker_id, const FileMetadata& app_root_metadata) { scoped_ptr<FileTracker> app_root_tracker(new FileTracker); app_root_tracker->set_tracker_id(tracker_id); @@ -242,7 +242,7 @@ SyncStatusCode MigrateDatabaseIfNeeded(LevelDBWrapper* db) { DCHECK(db); std::string value; leveldb::Status status = db->Get(kDatabaseVersionKey, &value); - int64 version = 0; + int64_t version = 0; if (status.ok()) { if (!base::StringToInt64(value, &version)) return SYNC_DATABASE_ERROR_FAILED; @@ -294,7 +294,7 @@ void MarkTrackerSetDirty(const TrackerIDSet& trackers, } } -void MarkTrackersDirtyByPath(int64 parent_tracker_id, +void MarkTrackersDirtyByPath(int64_t parent_tracker_id, const std::string& title, MetadataDatabaseIndexInterface* index) { if (parent_tracker_id == kInvalidTrackerID || title.empty()) @@ -309,12 +309,12 @@ void MarkTrackersDirtyByFileID(const std::string& file_id, MarkTrackerSetDirty(index->GetFileTrackerIDsByFileID(file_id), index); } -void MarkTrackersDirtyRecursively(int64 root_tracker_id, +void MarkTrackersDirtyRecursively(int64_t root_tracker_id, MetadataDatabaseIndexInterface* index) { - std::vector<int64> stack; + std::vector<int64_t> stack; stack.push_back(root_tracker_id); while (!stack.empty()) { - int64 tracker_id = stack.back(); + int64_t tracker_id = stack.back(); stack.pop_back(); AppendContents(index->GetFileTrackerIDsByParent(tracker_id), &stack); @@ -326,17 +326,17 @@ void MarkTrackersDirtyRecursively(int64 root_tracker_id, } } -void RemoveAllDescendantTrackers(int64 root_tracker_id, +void RemoveAllDescendantTrackers(int64_t root_tracker_id, MetadataDatabaseIndexInterface* index) { - std::vector<int64> pending_trackers; + std::vector<int64_t> pending_trackers; AppendContents(index->GetFileTrackerIDsByParent(root_tracker_id), &pending_trackers); - std::vector<int64> to_be_removed; + std::vector<int64_t> to_be_removed; // List trackers to remove. while (!pending_trackers.empty()) { - int64 tracker_id = pending_trackers.back(); + int64_t tracker_id = pending_trackers.back(); pending_trackers.pop_back(); AppendContents(index->GetFileTrackerIDsByParent(tracker_id), &pending_trackers); @@ -345,7 +345,7 @@ void RemoveAllDescendantTrackers(int64 root_tracker_id, // Remove trackers in the reversed order. base::hash_set<std::string> affected_file_ids; - for (std::vector<int64>::reverse_iterator itr = to_be_removed.rbegin(); + for (std::vector<int64_t>::reverse_iterator itr = to_be_removed.rbegin(); itr != to_be_removed.rend(); ++itr) { FileTracker tracker; index->GetFileTracker(*itr, &tracker); @@ -365,11 +365,10 @@ void RemoveAllDescendantTrackers(int64 root_tracker_id, } } -bool FilterFileTrackersByParent( - const MetadataDatabaseIndexInterface* index, - const TrackerIDSet& trackers, - int64 parent_tracker_id, - FileTracker* tracker_out) { +bool FilterFileTrackersByParent(const MetadataDatabaseIndexInterface* index, + const TrackerIDSet& trackers, + int64_t parent_tracker_id, + FileTracker* tracker_out) { FileTracker tracker; for (TrackerIDSet::const_iterator itr = trackers.begin(); itr != trackers.end(); ++itr) { @@ -390,7 +389,7 @@ bool FilterFileTrackersByParent( bool FilterFileTrackersByParentAndTitle( const MetadataDatabaseIndexInterface* index, const TrackerIDSet& trackers, - int64 parent_tracker_id, + int64_t parent_tracker_id, const std::string& title, FileTracker* result) { bool found = false; @@ -452,7 +451,7 @@ enum DirtyingOption { MARK_SAME_PATH_TRACKERS_DIRTY = 1 << 2, }; -void ActivateFileTracker(int64 tracker_id, +void ActivateFileTracker(int64_t tracker_id, int dirtying_options, MetadataDatabaseIndexInterface* index) { DCHECK(dirtying_options == MARK_NOTHING_DIRTY || @@ -474,7 +473,7 @@ void ActivateFileTracker(int64 tracker_id, index->StoreFileTracker(tracker.Pass()); } -void DeactivateFileTracker(int64 tracker_id, +void DeactivateFileTracker(int64_t tracker_id, int dirtying_options, MetadataDatabaseIndexInterface* index) { RemoveAllDescendantTrackers(tracker_id, index); @@ -494,7 +493,7 @@ void DeactivateFileTracker(int64 tracker_id, index->StoreFileTracker(tracker.Pass()); } -void RemoveFileTracker(int64 tracker_id, +void RemoveFileTracker(int64_t tracker_id, int dirtying_options, MetadataDatabaseIndexInterface* index) { DCHECK(!(dirtying_options & MARK_ITSELF_DIRTY)); @@ -504,7 +503,7 @@ void RemoveFileTracker(int64 tracker_id, return; std::string file_id = tracker.file_id(); - int64 parent_tracker_id = tracker.parent_tracker_id(); + int64_t parent_tracker_id = tracker.parent_tracker_id(); std::string title = GetTrackerTitle(tracker); RemoveAllDescendantTrackers(tracker_id, index); @@ -595,20 +594,20 @@ void MetadataDatabase::ClearDatabase( base::DeleteFile(database_path, true /* recursive */); } -int64 MetadataDatabase::GetLargestFetchedChangeID() const { +int64_t MetadataDatabase::GetLargestFetchedChangeID() const { return index_->GetLargestChangeID(); } -int64 MetadataDatabase::GetSyncRootTrackerID() const { +int64_t MetadataDatabase::GetSyncRootTrackerID() const { return index_->GetSyncRootTrackerID(); } -int64 MetadataDatabase::GetLargestKnownChangeID() const { +int64_t MetadataDatabase::GetLargestKnownChangeID() const { DCHECK_LE(GetLargestFetchedChangeID(), largest_known_change_id_); return largest_known_change_id_; } -void MetadataDatabase::UpdateLargestKnownChangeID(int64 change_id) { +void MetadataDatabase::UpdateLargestKnownChangeID(int64_t change_id) { if (largest_known_change_id_ < change_id) largest_known_change_id_ = change_id; } @@ -622,7 +621,7 @@ bool MetadataDatabase::HasSyncRoot() const { } SyncStatusCode MetadataDatabase::PopulateInitialData( - int64 largest_change_id, + int64_t largest_change_id, const google_apis::FileResource& sync_root_folder, const ScopedVector<google_apis::FileResource>& app_root_folders) { index_->SetLargestChangeID(largest_change_id); @@ -641,7 +640,7 @@ SyncStatusCode MetadataDatabase::PopulateInitialData( } bool MetadataDatabase::IsAppEnabled(const std::string& app_id) const { - int64 tracker_id = index_->GetAppRootTracker(app_id); + int64_t tracker_id = index_->GetAppRootTracker(app_id); if (tracker_id == kInvalidTrackerID) return false; @@ -670,7 +669,7 @@ SyncStatusCode MetadataDatabase::RegisterApp(const std::string& app_id, return SYNC_STATUS_HAS_CONFLICT; } - int64 sync_root_tracker_id = index_->GetSyncRootTrackerID(); + int64_t sync_root_tracker_id = index_->GetSyncRootTrackerID(); if (!sync_root_tracker_id) { util::Log(logging::LOG_WARNING, FROM_HERE, "Sync-root needs to be set up before registering app-root"); @@ -694,7 +693,7 @@ SyncStatusCode MetadataDatabase::RegisterApp(const std::string& app_id, } SyncStatusCode MetadataDatabase::DisableApp(const std::string& app_id) { - int64 tracker_id = index_->GetAppRootTracker(app_id); + int64_t tracker_id = index_->GetAppRootTracker(app_id); scoped_ptr<FileTracker> tracker(new FileTracker); if (!index_->GetFileTracker(tracker_id, tracker.get())) { return SYNC_DATABASE_ERROR_NOT_FOUND; @@ -716,7 +715,7 @@ SyncStatusCode MetadataDatabase::DisableApp(const std::string& app_id) { } SyncStatusCode MetadataDatabase::EnableApp(const std::string& app_id) { - int64 tracker_id = index_->GetAppRootTracker(app_id); + int64_t tracker_id = index_->GetAppRootTracker(app_id); scoped_ptr<FileTracker> tracker(new FileTracker); if (!index_->GetFileTracker(tracker_id, tracker.get())) { return SYNC_DATABASE_ERROR_NOT_FOUND; @@ -737,7 +736,7 @@ SyncStatusCode MetadataDatabase::EnableApp(const std::string& app_id) { } SyncStatusCode MetadataDatabase::UnregisterApp(const std::string& app_id) { - int64 tracker_id = index_->GetAppRootTracker(app_id); + int64_t tracker_id = index_->GetAppRootTracker(app_id); scoped_ptr<FileTracker> tracker(new FileTracker); if (!index_->GetFileTracker(tracker_id, tracker.get()) || tracker->tracker_kind() == TRACKER_KIND_REGULAR) { @@ -757,7 +756,7 @@ SyncStatusCode MetadataDatabase::UnregisterApp(const std::string& app_id) { bool MetadataDatabase::FindAppRootTracker(const std::string& app_id, FileTracker* tracker_out) const { - int64 app_root_tracker_id = index_->GetAppRootTracker(app_id); + int64_t app_root_tracker_id = index_->GetAppRootTracker(app_id); if (!app_root_tracker_id) return false; @@ -787,7 +786,7 @@ bool MetadataDatabase::FindTrackersByFileID(const std::string& file_id, } bool MetadataDatabase::FindTrackersByParentAndTitle( - int64 parent_tracker_id, + int64_t parent_tracker_id, const std::string& title, TrackerIDSet* trackers_out) const { TrackerIDSet trackers = @@ -800,12 +799,12 @@ bool MetadataDatabase::FindTrackersByParentAndTitle( return true; } -bool MetadataDatabase::FindTrackerByTrackerID(int64 tracker_id, +bool MetadataDatabase::FindTrackerByTrackerID(int64_t tracker_id, FileTracker* tracker_out) const { return index_->GetFileTracker(tracker_id, tracker_out); } -bool MetadataDatabase::BuildPathForTracker(int64 tracker_id, +bool MetadataDatabase::BuildPathForTracker(int64_t tracker_id, base::FilePath* path) const { FileTracker current; if (!FindTrackerByTrackerID(tracker_id, ¤t) || !current.active()) @@ -890,7 +889,7 @@ bool MetadataDatabase::FindNearestActiveAncestor( } SyncStatusCode MetadataDatabase::UpdateByChangeList( - int64 largest_change_id, + int64_t largest_change_id, ScopedVector<google_apis::ChangeResource> changes) { DCHECK_LE(index_->GetLargestChangeID(), largest_change_id); @@ -954,7 +953,7 @@ SyncStatusCode MetadataDatabase::UpdateByDeletedRemoteFileList( } SyncStatusCode MetadataDatabase::ReplaceActiveTrackerWithNewResource( - int64 parent_tracker_id, + int64_t parent_tracker_id, const google_apis::FileResource& resource) { DCHECK(!index_->GetFileMetadata(resource.file_id(), nullptr)); DCHECK(index_->GetFileTracker(parent_tracker_id, nullptr)); @@ -977,7 +976,7 @@ SyncStatusCode MetadataDatabase::ReplaceActiveTrackerWithNewResource( return SYNC_STATUS_FAILED; } - int64 tracker_id = to_be_activated.tracker_id(); + int64_t tracker_id = to_be_activated.tracker_id(); if (same_path_trackers.has_active()) { DeactivateFileTracker(same_path_trackers.active_tracker(), MARK_ITSELF_DIRTY | @@ -1009,7 +1008,7 @@ SyncStatusCode MetadataDatabase::PopulateFolderByChildList( base::hash_set<std::string> children(child_file_ids.begin(), child_file_ids.end()); - std::vector<int64> known_children = + std::vector<int64_t> known_children = index_->GetFileTrackerIDsByParent(folder_tracker->tracker_id()); for (size_t i = 0; i < known_children.size(); ++i) { FileTracker tracker; @@ -1032,7 +1031,7 @@ SyncStatusCode MetadataDatabase::PopulateFolderByChildList( } SyncStatusCode MetadataDatabase::UpdateTracker( - int64 tracker_id, + int64_t tracker_id, const FileDetails& updated_details) { FileTracker tracker; if (!index_->GetFileTracker(tracker_id, &tracker)) { @@ -1127,7 +1126,7 @@ SyncStatusCode MetadataDatabase::UpdateTracker( } MetadataDatabase::ActivationStatus MetadataDatabase::TryActivateTracker( - int64 parent_tracker_id, + int64_t parent_tracker_id, const std::string& file_id, SyncStatusCode* status_out) { FileMetadata metadata; @@ -1191,7 +1190,7 @@ MetadataDatabase::ActivationStatus MetadataDatabase::TryActivateTracker( return ACTIVATION_PENDING; } -void MetadataDatabase::DemoteTracker(int64 tracker_id) { +void MetadataDatabase::DemoteTracker(int64_t tracker_id) { index_->DemoteDirtyTracker(tracker_id); WriteToDatabase(); } @@ -1202,14 +1201,14 @@ bool MetadataDatabase::PromoteDemotedTrackers() { return promoted; } -void MetadataDatabase::PromoteDemotedTracker(int64 tracker_id) { +void MetadataDatabase::PromoteDemotedTracker(int64_t tracker_id) { index_->PromoteDemotedDirtyTracker(tracker_id); WriteToDatabase(); } bool MetadataDatabase::GetDirtyTracker( FileTracker* tracker_out) const { - int64 dirty_tracker_id = index_->PickDirtyTracker(); + int64_t dirty_tracker_id = index_->PickDirtyTracker(); if (!dirty_tracker_id) return false; @@ -1287,7 +1286,7 @@ void MetadataDatabase::GetRegisteredAppIDs(std::vector<std::string>* app_ids) { SyncStatusCode MetadataDatabase::SweepDirtyTrackers( const std::vector<std::string>& file_ids) { - std::set<int64> tracker_ids; + std::set<int64_t> tracker_ids; for (size_t i = 0; i < file_ids.size(); ++i) { TrackerIDSet trackers_for_file_id = index_->GetFileTrackerIDsByFileID(file_ids[i]); @@ -1296,7 +1295,7 @@ SyncStatusCode MetadataDatabase::SweepDirtyTrackers( tracker_ids.insert(*itr); } - for (std::set<int64>::iterator itr = tracker_ids.begin(); + for (std::set<int64_t>::iterator itr = tracker_ids.begin(); itr != tracker_ids.end(); ++itr) { scoped_ptr<FileTracker> tracker(new FileTracker); if (!index_->GetFileTracker(*itr, tracker.get()) || @@ -1383,7 +1382,7 @@ void MetadataDatabase::CreateTrackerInternal(const FileTracker& parent_tracker, const std::string& file_id, const FileDetails* details, UpdateOption option) { - int64 tracker_id = IncrementTrackerID(); + int64_t tracker_id = IncrementTrackerID(); scoped_ptr<FileTracker> tracker(new FileTracker); tracker->set_tracker_id(tracker_id); tracker->set_parent_tracker_id(parent_tracker.tracker_id()); @@ -1406,7 +1405,7 @@ void MetadataDatabase::CreateTrackerInternal(const FileTracker& parent_tracker, void MetadataDatabase::MaybeAddTrackersForNewFile( const FileMetadata& metadata, UpdateOption option) { - std::set<int64> parents_to_exclude; + std::set<int64_t> parents_to_exclude; TrackerIDSet existing_trackers = index_->GetFileTrackerIDsByFileID(metadata.file_id()); for (TrackerIDSet::const_iterator itr = existing_trackers.begin(); @@ -1417,7 +1416,7 @@ void MetadataDatabase::MaybeAddTrackersForNewFile( continue; } - int64 parent_tracker_id = tracker.parent_tracker_id(); + int64_t parent_tracker_id = tracker.parent_tracker_id(); if (!parent_tracker_id) continue; @@ -1449,8 +1448,8 @@ void MetadataDatabase::MaybeAddTrackersForNewFile( } } -int64 MetadataDatabase::IncrementTrackerID() { - int64 tracker_id = index_->GetNextTrackerID(); +int64_t MetadataDatabase::IncrementTrackerID() { + int64_t tracker_id = index_->GetNextTrackerID(); index_->SetNextTrackerID(tracker_id + 1); DCHECK_GT(tracker_id, 0); return tracker_id; @@ -1512,7 +1511,7 @@ bool MetadataDatabase::ShouldKeepDirty(const FileTracker& tracker) const { } bool MetadataDatabase::HasDisabledAppRoot(const FileTracker& tracker) const { - int64 app_root_tracker_id = index_->GetAppRootTracker(tracker.app_id()); + int64_t app_root_tracker_id = index_->GetAppRootTracker(tracker.app_id()); if (app_root_tracker_id == kInvalidTrackerID) return false; @@ -1529,7 +1528,7 @@ bool MetadataDatabase::HasActiveTrackerForFileID( return index_->GetFileTrackerIDsByFileID(file_id).has_active(); } -bool MetadataDatabase::HasActiveTrackerForPath(int64 parent_tracker_id, +bool MetadataDatabase::HasActiveTrackerForPath(int64_t parent_tracker_id, const std::string& title) const { return index_->GetFileTrackerIDsByParentAndTitle(parent_tracker_id, title) .has_active(); @@ -1592,11 +1591,11 @@ scoped_ptr<base::ListValue> MetadataDatabase::DumpFiles( if (!FindAppRootTracker(app_id, &app_root_tracker)) return files.Pass(); - std::vector<int64> stack; + std::vector<int64_t> stack; AppendContents( index_->GetFileTrackerIDsByParent(app_root_tracker.tracker_id()), &stack); while (!stack.empty()) { - int64 tracker_id = stack.back(); + int64_t tracker_id = stack.back(); stack.pop_back(); AppendContents(index_->GetFileTrackerIDsByParent(tracker_id), &stack); @@ -1639,7 +1638,7 @@ scoped_ptr<base::ListValue> MetadataDatabase::DumpDatabase() { } bool MetadataDatabase::HasNewerFileMetadata(const std::string& file_id, - int64 change_id) { + int64_t change_id) { FileMetadata metadata; if (!index_->GetFileMetadata(file_id, &metadata)) return false; @@ -1666,10 +1665,10 @@ scoped_ptr<base::ListValue> MetadataDatabase::DumpTrackers() { trackers->Append(metadata); // Append tracker data. - std::vector<int64> tracker_ids(index_->GetAllTrackerIDs()); - for (std::vector<int64>::const_iterator itr = tracker_ids.begin(); + std::vector<int64_t> tracker_ids(index_->GetAllTrackerIDs()); + for (std::vector<int64_t>::const_iterator itr = tracker_ids.begin(); itr != tracker_ids.end(); ++itr) { - const int64 tracker_id = *itr; + const int64_t tracker_id = *itr; FileTracker tracker; if (!index_->GetFileTracker(tracker_id, &tracker)) { NOTREACHED(); diff --git a/chrome/browser/sync_file_system/drive_backend/metadata_database.h b/chrome/browser/sync_file_system/drive_backend/metadata_database.h index 35deb5f..138a5fd 100644 --- a/chrome/browser/sync_file_system/drive_backend/metadata_database.h +++ b/chrome/browser/sync_file_system/drive_backend/metadata_database.h @@ -5,6 +5,9 @@ #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_H_ #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_H_ +#include <stddef.h> +#include <stdint.h> + #include <map> #include <set> #include <string> @@ -13,6 +16,7 @@ #include "base/containers/hash_tables.h" #include "base/containers/scoped_ptr_hash_map.h" #include "base/files/file_path.h" +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/memory/scoped_vector.h" #include "base/memory/weak_ptr.h" @@ -138,8 +142,8 @@ class MetadataDatabase { static void ClearDatabase(scoped_ptr<MetadataDatabase> metadata_database); - int64 GetLargestFetchedChangeID() const; - int64 GetSyncRootTrackerID() const; + int64_t GetLargestFetchedChangeID() const; + int64_t GetSyncRootTrackerID() const; // Returns true if the client should check if the sync root is still valid. bool NeedsSyncRootRevalidation() const; @@ -166,8 +170,8 @@ class MetadataDatabase { // FileMetadata from overwritten by ChangeList. // Also if other tasks try to update a remote resource whose change is not yet // retrieved the task should fail due to etag check, so we should be fine. - int64 GetLargestKnownChangeID() const; - void UpdateLargestKnownChangeID(int64 change_id); + int64_t GetLargestKnownChangeID() const; + void UpdateLargestKnownChangeID(int64_t change_id); // Populates empty database with initial data. // Adds a file metadata and a file tracker for |sync_root_folder|, and adds @@ -177,7 +181,7 @@ class MetadataDatabase { // Trackers for |app_root_folders| are not yet registered as app-roots, but // are ready to register. SyncStatusCode PopulateInitialData( - int64 largest_change_id, + int64_t largest_change_id, const google_apis::FileResource& sync_root_folder, const ScopedVector<google_apis::FileResource>& app_root_folders); @@ -218,7 +222,7 @@ class MetadataDatabase { // is found. // Copies the tracker identified by |tracker_id| into |tracker| if exists and // |tracker| is non-NULL. - bool FindTrackerByTrackerID(int64 tracker_id, FileTracker* tracker) const; + bool FindTrackerByTrackerID(int64_t tracker_id, FileTracker* tracker) const; // Finds the trackers tracking |file_id|. Returns true if the trackers are // found. @@ -229,15 +233,14 @@ class MetadataDatabase { // and who has |title| as its title in the synced_details. // Copies the tracker set to |trackers| if it is non-NULL. // Returns true if the trackers are found. - bool FindTrackersByParentAndTitle( - int64 parent_tracker_id, - const std::string& title, - TrackerIDSet* trackers) const; + bool FindTrackersByParentAndTitle(int64_t parent_tracker_id, + const std::string& title, + TrackerIDSet* trackers) const; // Builds the file path for the given tracker. Returns true on success. // |path| can be NULL. // The file path is relative to app-root and have a leading path separator. - bool BuildPathForTracker(int64 tracker_id, base::FilePath* path) const; + bool BuildPathForTracker(int64_t tracker_id, base::FilePath* path) const; // Builds the file path for the given tracker for display purpose. // This may return a path ending with '<unknown>' if the given tracker does @@ -257,7 +260,7 @@ class MetadataDatabase { // Marks each tracker for modified file as dirty and adds new trackers if // needed. SyncStatusCode UpdateByChangeList( - int64 largest_change_id, + int64_t largest_change_id, ScopedVector<google_apis::ChangeResource> changes); // Updates database by |resource|. @@ -277,7 +280,7 @@ class MetadataDatabase { // Deactivates existing active tracker if exists that has the same title and // parent_tracker to the newly added tracker. SyncStatusCode ReplaceActiveTrackerWithNewResource( - int64 parent_tracker_id, + int64_t parent_tracker_id, const google_apis::FileResource& resource); // Adds |child_file_ids| to |folder_id| as its children. @@ -287,7 +290,7 @@ class MetadataDatabase { const FileIDList& child_file_ids); // Updates |synced_details| of the tracker with |updated_details|. - SyncStatusCode UpdateTracker(int64 tracker_id, + SyncStatusCode UpdateTracker(int64_t tracker_id, const FileDetails& updated_details); // Activates a tracker identified by |parent_tracker_id| and |file_id| if the @@ -303,14 +306,14 @@ class MetadataDatabase { // The tracker to be activated must: // - have a tracked metadata in the database, // - have |synced_details| with valid |title|. - ActivationStatus TryActivateTracker(int64 parent_tracker_id, + ActivationStatus TryActivateTracker(int64_t parent_tracker_id, const std::string& file_id, SyncStatusCode* status); // Changes the priority of the tracker to low. - void DemoteTracker(int64 tracker_id); + void DemoteTracker(int64_t tracker_id); bool PromoteDemotedTrackers(); - void PromoteDemotedTracker(int64 tracker_id); + void PromoteDemotedTracker(int64_t tracker_id); // Returns true if there is a normal priority dirty tracker. // Assigns the dirty tracker if exists and |tracker| is non-NULL. @@ -344,8 +347,7 @@ class MetadataDatabase { SyncStatusCode Initialize(); // Database manipulation methods. - void RegisterTrackerAsAppRoot(const std::string& app_id, - int64 tracker_id); + void RegisterTrackerAsAppRoot(const std::string& app_id, int64_t tracker_id); void CreateTrackerForParentAndFileID(const FileTracker& parent_tracker, const std::string& file_id); @@ -360,14 +362,14 @@ class MetadataDatabase { void MaybeAddTrackersForNewFile(const FileMetadata& file, UpdateOption option); - int64 IncrementTrackerID(); + int64_t IncrementTrackerID(); bool CanActivateTracker(const FileTracker& tracker); bool ShouldKeepDirty(const FileTracker& tracker) const; bool HasDisabledAppRoot(const FileTracker& tracker) const; bool HasActiveTrackerForFileID(const std::string& file_id) const; - bool HasActiveTrackerForPath(int64 parent_tracker, + bool HasActiveTrackerForPath(int64_t parent_tracker, const std::string& title) const; void RemoveUnneededTrackersForMissingFile(const std::string& file_id); @@ -377,7 +379,7 @@ class MetadataDatabase { SyncStatusCode WriteToDatabase(); - bool HasNewerFileMetadata(const std::string& file_id, int64 change_id); + bool HasNewerFileMetadata(const std::string& file_id, int64_t change_id); scoped_ptr<base::ListValue> DumpTrackers(); scoped_ptr<base::ListValue> DumpMetadata(); @@ -385,7 +387,7 @@ class MetadataDatabase { void AttachSyncRoot(const google_apis::FileResource& sync_root_folder); void AttachInitialAppRoot(const google_apis::FileResource& app_root_folder); - void ForceActivateTrackerByPath(int64 parent_tracker_id, + void ForceActivateTrackerByPath(int64_t parent_tracker_id, const std::string& title, const std::string& file_id); @@ -397,7 +399,7 @@ class MetadataDatabase { bool enable_on_disk_index_; - int64 largest_known_change_id_; + int64_t largest_known_change_id_; scoped_ptr<MetadataDatabaseIndexInterface> index_; diff --git a/chrome/browser/sync_file_system/drive_backend/metadata_database_index.cc b/chrome/browser/sync_file_system/drive_backend/metadata_database_index.cc index d33e191..df4dcf6 100644 --- a/chrome/browser/sync_file_system/drive_backend/metadata_database_index.cc +++ b/chrome/browser/sync_file_system/drive_backend/metadata_database_index.cc @@ -24,7 +24,7 @@ // // NOTE // - Entries are sorted by keys. -// - int64 value is serialized as a string by base::Int64ToString(). +// - int64_t value is serialized as a string by base::Int64ToString(). // - ServiceMetadata, FileMetadata, and FileTracker values are serialized // as a string by SerializeToString() of protocol buffers. // @@ -42,15 +42,14 @@ // value: <FileMetadata 'metadata'> // // # Trackers of local file updates -// key: "TRACKER: " + <int64 'tracker_id'> +// key: "TRACKER: " + <int64_t 'tracker_id'> // value: <FileTracker 'tracker'> namespace sync_file_system { namespace drive_backend { ParentIDAndTitle::ParentIDAndTitle() : parent_id(0) {} -ParentIDAndTitle::ParentIDAndTitle(int64 parent_id, - const std::string& title) +ParentIDAndTitle::ParentIDAndTitle(int64_t parent_id, const std::string& title) : parent_id(parent_id), title(title) {} bool operator==(const ParentIDAndTitle& left, const ParentIDAndTitle& right) { @@ -102,7 +101,7 @@ void ReadDatabaseContents(LevelDBWrapper* db, DatabaseContents* contents) { std::string tracker_id_str; if (RemovePrefix(key, kFileTrackerKeyPrefix, &tracker_id_str)) { - int64 tracker_id = 0; + int64_t tracker_id = 0; if (!base::StringToInt64(tracker_id_str, &tracker_id)) { util::Log(logging::LOG_WARNING, FROM_HERE, "Failed to parse TrackerID"); @@ -122,16 +121,16 @@ void ReadDatabaseContents(LevelDBWrapper* db, DatabaseContents* contents) { } void RemoveUnreachableItemsFromDB(DatabaseContents* contents, - int64 sync_root_tracker_id, + int64_t sync_root_tracker_id, LevelDBWrapper* db) { - typedef std::map<int64, std::set<int64> > ChildTrackersByParent; + typedef std::map<int64_t, std::set<int64_t>> ChildTrackersByParent; ChildTrackersByParent trackers_by_parent; // Set up links from parent tracker to child trackers. for (size_t i = 0; i < contents->file_trackers.size(); ++i) { const FileTracker& tracker = *contents->file_trackers[i]; - int64 parent_tracker_id = tracker.parent_tracker_id(); - int64 tracker_id = tracker.tracker_id(); + int64_t parent_tracker_id = tracker.parent_tracker_id(); + int64_t tracker_id = tracker.tracker_id(); trackers_by_parent[parent_tracker_id].insert(tracker_id); } @@ -144,14 +143,14 @@ void RemoveUnreachableItemsFromDB(DatabaseContents* contents, trackers_by_parent.erase(tracker.tracker_id()); } - std::vector<int64> pending; + std::vector<int64_t> pending; if (sync_root_tracker_id != kInvalidTrackerID) pending.push_back(sync_root_tracker_id); // Traverse tracker tree from sync-root. - std::set<int64> visited_trackers; + std::set<int64_t> visited_trackers; while (!pending.empty()) { - int64 tracker_id = pending.back(); + int64_t tracker_id = pending.back(); DCHECK_NE(kInvalidTrackerID, tracker_id); pending.pop_back(); @@ -161,7 +160,7 @@ void RemoveUnreachableItemsFromDB(DatabaseContents* contents, } AppendContents( - LookUpMap(trackers_by_parent, tracker_id, std::set<int64>()), + LookUpMap(trackers_by_parent, tracker_id, std::set<int64_t>()), &pending); } @@ -267,8 +266,8 @@ bool MetadataDatabaseIndex::GetFileMetadata( return true; } -bool MetadataDatabaseIndex::GetFileTracker( - int64 tracker_id, FileTracker* tracker) const { +bool MetadataDatabaseIndex::GetFileTracker(int64_t tracker_id, + FileTracker* tracker) const { FileTracker* identified = tracker_by_id_.get(tracker_id); if (!identified) return false; @@ -297,7 +296,7 @@ void MetadataDatabaseIndex::StoreFileTracker( return; } - int64 tracker_id = tracker->tracker_id(); + int64_t tracker_id = tracker->tracker_id(); FileTracker* old_tracker = tracker_by_id_.get(tracker_id); if (!old_tracker) { @@ -326,7 +325,7 @@ void MetadataDatabaseIndex::RemoveFileMetadata(const std::string& file_id) { metadata_by_id_.erase(file_id); } -void MetadataDatabaseIndex::RemoveFileTracker(int64 tracker_id) { +void MetadataDatabaseIndex::RemoveFileTracker(int64_t tracker_id) { PutFileTrackerDeletionToDB(tracker_id, db_); FileTracker* tracker = tracker_by_id_.get(tracker_id); @@ -351,13 +350,13 @@ TrackerIDSet MetadataDatabaseIndex::GetFileTrackerIDsByFileID( return FindItem(trackers_by_file_id_, file_id); } -int64 MetadataDatabaseIndex::GetAppRootTracker( +int64_t MetadataDatabaseIndex::GetAppRootTracker( const std::string& app_id) const { return FindItem(app_root_by_app_id_, app_id); } TrackerIDSet MetadataDatabaseIndex::GetFileTrackerIDsByParentAndTitle( - int64 parent_tracker_id, + int64_t parent_tracker_id, const std::string& title) const { TrackerIDsByParentAndTitle::const_iterator found = trackers_by_parent_and_title_.find(parent_tracker_id); @@ -366,9 +365,9 @@ TrackerIDSet MetadataDatabaseIndex::GetFileTrackerIDsByParentAndTitle( return FindItem(found->second, title); } -std::vector<int64> MetadataDatabaseIndex::GetFileTrackerIDsByParent( - int64 parent_tracker_id) const { - std::vector<int64> result; +std::vector<int64_t> MetadataDatabaseIndex::GetFileTrackerIDsByParent( + int64_t parent_tracker_id) const { + std::vector<int64_t> result; TrackerIDsByParentAndTitle::const_iterator found = trackers_by_parent_and_title_.find(parent_tracker_id); if (found == trackers_by_parent_and_title_.end()) @@ -394,13 +393,13 @@ ParentIDAndTitle MetadataDatabaseIndex::PickMultiBackingFilePath() const { return *multi_backing_file_paths_.begin(); } -int64 MetadataDatabaseIndex::PickDirtyTracker() const { +int64_t MetadataDatabaseIndex::PickDirtyTracker() const { if (dirty_trackers_.empty()) return kInvalidTrackerID; return *dirty_trackers_.begin(); } -void MetadataDatabaseIndex::DemoteDirtyTracker(int64 tracker_id) { +void MetadataDatabaseIndex::DemoteDirtyTracker(int64_t tracker_id) { if (dirty_trackers_.erase(tracker_id)) demoted_dirty_trackers_.insert(tracker_id); } @@ -409,12 +408,12 @@ bool MetadataDatabaseIndex::HasDemotedDirtyTracker() const { return !demoted_dirty_trackers_.empty(); } -bool MetadataDatabaseIndex::IsDemotedDirtyTracker(int64 tracker_id) const { +bool MetadataDatabaseIndex::IsDemotedDirtyTracker(int64_t tracker_id) const { return demoted_dirty_trackers_.find(tracker_id) != demoted_dirty_trackers_.end(); } -void MetadataDatabaseIndex::PromoteDemotedDirtyTracker(int64 tracker_id) { +void MetadataDatabaseIndex::PromoteDemotedDirtyTracker(int64_t tracker_id) { if (demoted_dirty_trackers_.erase(tracker_id) == 1) dirty_trackers_.insert(tracker_id); } @@ -444,20 +443,18 @@ void MetadataDatabaseIndex::SetSyncRootRevalidated() const { PutServiceMetadataToDB(*service_metadata_, db_); } -void MetadataDatabaseIndex::SetSyncRootTrackerID( - int64 sync_root_id) const { +void MetadataDatabaseIndex::SetSyncRootTrackerID(int64_t sync_root_id) const { service_metadata_->set_sync_root_tracker_id(sync_root_id); PutServiceMetadataToDB(*service_metadata_, db_); } void MetadataDatabaseIndex::SetLargestChangeID( - int64 largest_change_id) const { + int64_t largest_change_id) const { service_metadata_->set_largest_change_id(largest_change_id); PutServiceMetadataToDB(*service_metadata_, db_); } -void MetadataDatabaseIndex::SetNextTrackerID( - int64 next_tracker_id) const { +void MetadataDatabaseIndex::SetNextTrackerID(int64_t next_tracker_id) const { service_metadata_->set_next_tracker_id(next_tracker_id); PutServiceMetadataToDB(*service_metadata_, db_); } @@ -467,19 +464,19 @@ bool MetadataDatabaseIndex::IsSyncRootRevalidated() const { service_metadata_->sync_root_revalidated(); } -int64 MetadataDatabaseIndex::GetSyncRootTrackerID() const { +int64_t MetadataDatabaseIndex::GetSyncRootTrackerID() const { if (!service_metadata_->has_sync_root_tracker_id()) return kInvalidTrackerID; return service_metadata_->sync_root_tracker_id(); } -int64 MetadataDatabaseIndex::GetLargestChangeID() const { +int64_t MetadataDatabaseIndex::GetLargestChangeID() const { if (!service_metadata_->has_largest_change_id()) return kInvalidTrackerID; return service_metadata_->largest_change_id(); } -int64 MetadataDatabaseIndex::GetNextTrackerID() const { +int64_t MetadataDatabaseIndex::GetNextTrackerID() const { if (!service_metadata_->has_next_tracker_id()) { NOTREACHED(); return kInvalidTrackerID; @@ -496,8 +493,8 @@ std::vector<std::string> MetadataDatabaseIndex::GetRegisteredAppIDs() const { return result; } -std::vector<int64> MetadataDatabaseIndex::GetAllTrackerIDs() const { - std::vector<int64> result; +std::vector<int64_t> MetadataDatabaseIndex::GetAllTrackerIDs() const { + std::vector<int64_t> result; for (TrackerByID::const_iterator itr = tracker_by_id_.begin(); itr != tracker_by_id_.end(); ++itr) { result.push_back(itr->first); @@ -615,7 +612,7 @@ void MetadataDatabaseIndex::RemoveFromFileIDIndexes( void MetadataDatabaseIndex::AddToPathIndexes( const FileTracker& new_tracker) { - int64 parent = new_tracker.parent_tracker_id(); + int64_t parent = new_tracker.parent_tracker_id(); std::string title = GetTrackerTitle(new_tracker); DVLOG(3) << " Add to trackers_by_parent_and_title_: " @@ -640,8 +637,8 @@ void MetadataDatabaseIndex::UpdateInPathIndexes( DCHECK(GetTrackerTitle(old_tracker) == GetTrackerTitle(new_tracker) || !old_tracker.has_synced_details()); - int64 tracker_id = new_tracker.tracker_id(); - int64 parent = new_tracker.parent_tracker_id(); + int64_t tracker_id = new_tracker.tracker_id(); + int64_t parent = new_tracker.parent_tracker_id(); std::string old_title = GetTrackerTitle(old_tracker); std::string title = GetTrackerTitle(new_tracker); @@ -693,8 +690,8 @@ void MetadataDatabaseIndex::UpdateInPathIndexes( void MetadataDatabaseIndex::RemoveFromPathIndexes( const FileTracker& tracker) { - int64 tracker_id = tracker.tracker_id(); - int64 parent = tracker.parent_tracker_id(); + int64_t tracker_id = tracker.tracker_id(); + int64_t parent = tracker.parent_tracker_id(); std::string title = GetTrackerTitle(tracker); DCHECK(ContainsKey(trackers_by_parent_and_title_, parent)); @@ -737,7 +734,7 @@ void MetadataDatabaseIndex::UpdateInDirtyTrackerIndexes( const FileTracker& new_tracker) { DCHECK_EQ(old_tracker.tracker_id(), new_tracker.tracker_id()); - int64 tracker_id = new_tracker.tracker_id(); + int64_t tracker_id = new_tracker.tracker_id(); if (old_tracker.dirty() && !new_tracker.dirty()) { DCHECK(ContainsKey(dirty_trackers_, tracker_id) || ContainsKey(demoted_dirty_trackers_, tracker_id)); @@ -759,7 +756,7 @@ void MetadataDatabaseIndex::UpdateInDirtyTrackerIndexes( void MetadataDatabaseIndex::RemoveFromDirtyTrackerIndexes( const FileTracker& tracker) { if (tracker.dirty()) { - int64 tracker_id = tracker.tracker_id(); + int64_t tracker_id = tracker.tracker_id(); DCHECK(ContainsKey(dirty_trackers_, tracker_id) || ContainsKey(demoted_dirty_trackers_, tracker_id)); diff --git a/chrome/browser/sync_file_system/drive_backend/metadata_database_index.h b/chrome/browser/sync_file_system/drive_backend/metadata_database_index.h index c907e6d..a6f4510 100644 --- a/chrome/browser/sync_file_system/drive_backend/metadata_database_index.h +++ b/chrome/browser/sync_file_system/drive_backend/metadata_database_index.h @@ -5,6 +5,9 @@ #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_INDEX_H_ #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_INDEX_H_ +#include <stddef.h> +#include <stdint.h> + #include <map> #include <set> #include <string> @@ -12,6 +15,7 @@ #include "base/containers/hash_tables.h" #include "base/containers/scoped_ptr_hash_map.h" +#include "base/macros.h" #include "base/memory/scoped_vector.h" #include "chrome/browser/sync_file_system/drive_backend/metadata_database_index_interface.h" #include "chrome/browser/sync_file_system/drive_backend/tracker_id_set.h" @@ -61,53 +65,53 @@ class MetadataDatabaseIndex : public MetadataDatabaseIndexInterface { void RemoveUnreachableItems() override; bool GetFileMetadata(const std::string& file_id, FileMetadata* metadata) const override; - bool GetFileTracker(int64 tracker_id, FileTracker* tracker) const override; + bool GetFileTracker(int64_t tracker_id, FileTracker* tracker) const override; void StoreFileMetadata(scoped_ptr<FileMetadata> metadata) override; void StoreFileTracker(scoped_ptr<FileTracker> tracker) override; void RemoveFileMetadata(const std::string& file_id) override; - void RemoveFileTracker(int64 tracker_id) override; + void RemoveFileTracker(int64_t tracker_id) override; TrackerIDSet GetFileTrackerIDsByFileID( const std::string& file_id) const override; - int64 GetAppRootTracker(const std::string& app_id) const override; + int64_t GetAppRootTracker(const std::string& app_id) const override; TrackerIDSet GetFileTrackerIDsByParentAndTitle( - int64 parent_tracker_id, + int64_t parent_tracker_id, const std::string& title) const override; - std::vector<int64> GetFileTrackerIDsByParent( - int64 parent_tracker_id) const override; + std::vector<int64_t> GetFileTrackerIDsByParent( + int64_t parent_tracker_id) const override; std::string PickMultiTrackerFileID() const override; ParentIDAndTitle PickMultiBackingFilePath() const override; - int64 PickDirtyTracker() const override; - void DemoteDirtyTracker(int64 tracker_id) override; + int64_t PickDirtyTracker() const override; + void DemoteDirtyTracker(int64_t tracker_id) override; bool HasDemotedDirtyTracker() const override; - bool IsDemotedDirtyTracker(int64 tracker_id) const override; - void PromoteDemotedDirtyTracker(int64 tracker_id) override; + bool IsDemotedDirtyTracker(int64_t tracker_id) const override; + void PromoteDemotedDirtyTracker(int64_t tracker_id) override; bool PromoteDemotedDirtyTrackers() override; size_t CountDirtyTracker() const override; size_t CountFileMetadata() const override; size_t CountFileTracker() const override; void SetSyncRootRevalidated() const override; - void SetSyncRootTrackerID(int64 sync_root_id) const override; - void SetLargestChangeID(int64 largest_change_id) const override; - void SetNextTrackerID(int64 next_tracker_id) const override; + void SetSyncRootTrackerID(int64_t sync_root_id) const override; + void SetLargestChangeID(int64_t largest_change_id) const override; + void SetNextTrackerID(int64_t next_tracker_id) const override; bool IsSyncRootRevalidated() const override; - int64 GetSyncRootTrackerID() const override; - int64 GetLargestChangeID() const override; - int64 GetNextTrackerID() const override; + int64_t GetSyncRootTrackerID() const override; + int64_t GetLargestChangeID() const override; + int64_t GetNextTrackerID() const override; std::vector<std::string> GetRegisteredAppIDs() const override; - std::vector<int64> GetAllTrackerIDs() const override; + std::vector<int64_t> GetAllTrackerIDs() const override; std::vector<std::string> GetAllMetadataIDs() const override; private: typedef base::ScopedPtrHashMap<std::string, scoped_ptr<FileMetadata>> MetadataByID; - typedef base::ScopedPtrHashMap<int64, scoped_ptr<FileTracker>> TrackerByID; + typedef base::ScopedPtrHashMap<int64_t, scoped_ptr<FileTracker>> TrackerByID; typedef base::hash_map<std::string, TrackerIDSet> TrackerIDsByFileID; typedef base::hash_map<std::string, TrackerIDSet> TrackerIDsByTitle; - typedef std::map<int64, TrackerIDsByTitle> TrackerIDsByParentAndTitle; - typedef base::hash_map<std::string, int64> TrackerIDByAppID; + typedef std::map<int64_t, TrackerIDsByTitle> TrackerIDsByParentAndTitle; + typedef base::hash_map<std::string, int64_t> TrackerIDByAppID; typedef base::hash_set<std::string> FileIDSet; typedef base::hash_set<ParentIDAndTitle> PathSet; - typedef std::set<int64> DirtyTrackers; + typedef std::set<int64_t> DirtyTrackers; friend class MetadataDatabaseTest; diff --git a/chrome/browser/sync_file_system/drive_backend/metadata_database_index_interface.h b/chrome/browser/sync_file_system/drive_backend/metadata_database_index_interface.h index 0c06301..622c35c 100644 --- a/chrome/browser/sync_file_system/drive_backend/metadata_database_index_interface.h +++ b/chrome/browser/sync_file_system/drive_backend/metadata_database_index_interface.h @@ -5,10 +5,13 @@ #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_INDEX_INTERFACE_H_ #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_INDEX_INTERFACE_H_ +#include <stddef.h> +#include <stdint.h> + #include <string> #include <vector> -#include "base/basictypes.h" +#include "base/macros.h" #include "base/memory/scoped_ptr.h" namespace sync_file_system { @@ -19,11 +22,11 @@ class FileTracker; class TrackerIDSet; struct ParentIDAndTitle { - int64 parent_id; + int64_t parent_id; std::string title; ParentIDAndTitle(); - ParentIDAndTitle(int64 parent_id, const std::string& title); + ParentIDAndTitle(int64_t parent_id, const std::string& title); }; bool operator==(const ParentIDAndTitle& left, const ParentIDAndTitle& right); @@ -45,8 +48,8 @@ class MetadataDatabaseIndexInterface { // Returns true if FileTracker identified by |tracker_id| exists. // If |tracker| is not NULL, the FileTracker is copied to it. - virtual bool GetFileTracker( - int64 tracker_id, FileTracker* tracker) const = 0; + virtual bool GetFileTracker(int64_t tracker_id, + FileTracker* tracker) const = 0; // Stores |metadata| and updates indexes. // This overwrites existing FileMetadata for the same |file_id|. @@ -60,7 +63,7 @@ class MetadataDatabaseIndexInterface { virtual void RemoveFileMetadata(const std::string& file_id) = 0; // Removes FileTracker identified by |tracker_id| from indexes. - virtual void RemoveFileTracker(int64 tracker_id) = 0; + virtual void RemoveFileTracker(int64_t tracker_id) = 0; // Returns a set of FileTracker that have |file_id| as its own. virtual TrackerIDSet GetFileTrackerIDsByFileID( @@ -68,15 +71,15 @@ class MetadataDatabaseIndexInterface { // Returns an app-root tracker identified by |app_id|. Returns 0 if not // found. - virtual int64 GetAppRootTracker(const std::string& app_id) const = 0; + virtual int64_t GetAppRootTracker(const std::string& app_id) const = 0; // Returns a set of FileTracker that have |parent_tracker_id| and |title|. virtual TrackerIDSet GetFileTrackerIDsByParentAndTitle( - int64 parent_tracker_id, + int64_t parent_tracker_id, const std::string& title) const = 0; - virtual std::vector<int64> GetFileTrackerIDsByParent( - int64 parent_tracker_id) const = 0; + virtual std::vector<int64_t> GetFileTrackerIDsByParent( + int64_t parent_tracker_id) const = 0; // Returns the |file_id| of a file that has multiple trackers. virtual std::string PickMultiTrackerFileID() const = 0; @@ -87,16 +90,16 @@ class MetadataDatabaseIndexInterface { // Returns a FileTracker whose |dirty| is set and which isn't demoted. // Returns 0 if not found. - virtual int64 PickDirtyTracker() const = 0; + virtual int64_t PickDirtyTracker() const = 0; // Demotes a dirty tracker. - virtual void DemoteDirtyTracker(int64 tracker_id) = 0; + virtual void DemoteDirtyTracker(int64_t tracker_id) = 0; virtual bool HasDemotedDirtyTracker() const = 0; - virtual bool IsDemotedDirtyTracker(int64 tracker_id) const = 0; + virtual bool IsDemotedDirtyTracker(int64_t tracker_id) const = 0; // Promotes single demoted dirty tracker to a normal dirty tracker. - virtual void PromoteDemotedDirtyTracker(int64 tracker_id) = 0; + virtual void PromoteDemotedDirtyTracker(int64_t tracker_id) = 0; // Promotes all demoted dirty trackers to normal dirty trackers. // Returns true if any tracker was promoted. @@ -107,15 +110,15 @@ class MetadataDatabaseIndexInterface { virtual size_t CountFileTracker() const = 0; virtual void SetSyncRootRevalidated() const = 0; - virtual void SetSyncRootTrackerID(int64 sync_root_id) const = 0; - virtual void SetLargestChangeID(int64 largest_change_id) const = 0; - virtual void SetNextTrackerID(int64 next_tracker_id) const = 0; + virtual void SetSyncRootTrackerID(int64_t sync_root_id) const = 0; + virtual void SetLargestChangeID(int64_t largest_change_id) const = 0; + virtual void SetNextTrackerID(int64_t next_tracker_id) const = 0; virtual bool IsSyncRootRevalidated() const = 0; - virtual int64 GetSyncRootTrackerID() const = 0; - virtual int64 GetLargestChangeID() const = 0; - virtual int64 GetNextTrackerID() const = 0; + virtual int64_t GetSyncRootTrackerID() const = 0; + virtual int64_t GetLargestChangeID() const = 0; + virtual int64_t GetNextTrackerID() const = 0; virtual std::vector<std::string> GetRegisteredAppIDs() const = 0; - virtual std::vector<int64> GetAllTrackerIDs() const = 0; + virtual std::vector<int64_t> GetAllTrackerIDs() const = 0; virtual std::vector<std::string> GetAllMetadataIDs() const = 0; private: diff --git a/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.cc b/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.cc index 4956f48..2587acb 100644 --- a/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.cc +++ b/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.cc @@ -6,6 +6,7 @@ #include "base/format_macros.h" #include "base/logging.h" +#include "base/macros.h" #include "base/stl_util.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" @@ -21,7 +22,7 @@ // // NOTE // - Entries are sorted by keys. -// - int64 value is serialized as a string by base::Int64ToString(). +// - int64_t value is serialized as a string by base::Int64ToString(). // - ServiceMetadata, FileMetadata, and FileTracker values are serialized // as a string by SerializeToString() of protocol buffers. // @@ -39,45 +40,46 @@ // value: <FileMetadata 'metadata'> // // # Trackers of remote file updates (compatible with version 3) -// key: "TRACKER: " + <int64 'tracker_id'> +// key: "TRACKER: " + <int64_t 'tracker_id'> // value: <FileTracker 'tracker'> // // # Index from App ID to the tracker ID // key: "APP_ROOT: " + <string 'app_id'> -// value: <int64 'app_root_tracker_id'> +// value: <int64_t 'app_root_tracker_id'> // // # Index from file ID to the active tracker ID // key: "ACTIVE_FILE: " + <string 'file_id'> -// value: <int64 'active_tracker_id'> +// value: <int64_t 'active_tracker_id'> // // # Index from file ID to a tracker ID -// key: "TRACKER_FILE: " + <string 'file_id'> + '\x00' + <int64 'tracker_id'> +// key: "TRACKER_FILE: " + <string 'file_id'> + '\x00' + +// <int64_t'tracker_id'> // value: <empty> // // # Tracker IDs; a file metadata linked to multiple tracker IDs. -// key: "MULTI_FILE: " + <int64 'tracker_id'> +// key: "MULTI_FILE: " + <int64_t 'tracker_id'> // value: <empty> // // # Index from the parent tracker ID and the title to the active tracker ID -// key: "ACTIVE_PATH: " + <int64 'parent_tracker_id'> + +// key: "ACTIVE_PATH: " + <int64_t 'parent_tracker_id'> + // '\x00' + <string 'title'> -// value: <int64 'active_tracker_id'> +// value: <int64_t 'active_tracker_id'> // // # Index from the parent tracker ID and the title to a tracker ID -// key: "TRACKER_PATH: " + <int64 'parent_tracker_id'> + -// '\x00' + <string 'title'> + '\x00' + <int64 'tracker_id'> +// key: "TRACKER_PATH: " + <int64_t 'parent_tracker_id'> + +// '\x00' + <string 'title'> + '\x00' + <int64_t 'tracker_id'> // value: <empty> // // # Tracker IDs; a parent tracker ID and a title figure multiple tracker IDs -// key: "MULTI_PATH: " + <int64 'tracker_id'> +// key: "MULTI_PATH: " + <int64_t 'tracker_id'> // value: <empty> // // # Dirty tracker IDs -// key: "DIRTY: " + <int64 'dirty_tracker_id'> +// key: "DIRTY: " + <int64_t 'dirty_tracker_id'> // value: <empty> // // # Demoted dirty tracker IDs -// key: "DEMOTED_DIRTY: " + <int64 'demoted_dirty_tracker_id'> +// key: "DEMOTED_DIRTY: " + <int64_t 'demoted_dirty_tracker_id'> // value: <empty> // // # Timestamp when the last validation ran @@ -108,7 +110,8 @@ std::string GenerateMultiTrackerKey(const std::string& file_id) { } std::string GenerateActiveTrackerIDByParentAndTitleKey( - int64 parent_id, const std::string& title) { + int64_t parent_id, + const std::string& title) { std::ostringstream oss; oss << kActiveTrackerIDByParentAndTitleKeyPrefix << parent_id << '\0' << title; @@ -116,44 +119,45 @@ std::string GenerateActiveTrackerIDByParentAndTitleKey( } std::string GenerateTrackerIDByParentAndTitleKeyPrefix( - int64 parent_id, const std::string& title) { + int64_t parent_id, + const std::string& title) { std::ostringstream oss; oss << kTrackerIDByParentAndTitleKeyPrefix << parent_id << '\0' << title << '\0'; return oss.str(); } -std::string GenerateTrackerIDsByParentIDKeyPrefix(int64 parent_id) { +std::string GenerateTrackerIDsByParentIDKeyPrefix(int64_t parent_id) { std::ostringstream oss; oss << kTrackerIDByParentAndTitleKeyPrefix << parent_id << '\0'; return oss.str(); } -std::string GenerateMultiBackingParentAndTitleKey( - int64 parent_id, const std::string& title) { +std::string GenerateMultiBackingParentAndTitleKey(int64_t parent_id, + const std::string& title) { std::ostringstream oss; oss << kMultiBackingParentAndTitleKeyPrefix << parent_id << '\0' << title; return oss.str(); } -std::string GenerateDirtyIDKey(int64 tracker_id) { +std::string GenerateDirtyIDKey(int64_t tracker_id) { return kDirtyIDKeyPrefix + base::Int64ToString(tracker_id); } -std::string GenerateDemotedDirtyIDKey(int64 tracker_id) { +std::string GenerateDemotedDirtyIDKey(int64_t tracker_id) { return kDemotedDirtyIDKeyPrefix + base::Int64ToString(tracker_id); } void RemoveUnreachableItemsFromDB(LevelDBWrapper* db, - int64 sync_root_tracker_id) { + int64_t sync_root_tracker_id) { DCHECK(db); - typedef std::map<int64, std::set<int64> > ChildTrackersByParent; + typedef std::map<int64_t, std::set<int64_t>> ChildTrackersByParent; ChildTrackersByParent trackers_by_parent; { // Set up links from parent tracker to child trackers. - std::set<int64> inactive_trackers; + std::set<int64_t> inactive_trackers; scoped_ptr<LevelDBWrapper::Iterator> itr = db->NewIterator(); for (itr->Seek(kFileTrackerKeyPrefix); itr->Valid(); itr->Next()) { if (!RemovePrefix(itr->key().ToString(), kFileTrackerKeyPrefix, nullptr)) @@ -166,29 +170,29 @@ void RemoveUnreachableItemsFromDB(LevelDBWrapper* db, continue; } - int64 parent_tracker_id = tracker->parent_tracker_id(); - int64 tracker_id = tracker->tracker_id(); + int64_t parent_tracker_id = tracker->parent_tracker_id(); + int64_t tracker_id = tracker->tracker_id(); trackers_by_parent[parent_tracker_id].insert(tracker_id); if (!tracker->active()) inactive_trackers.insert(tracker_id); } // Drop links from inactive trackers. - for (std::set<int64>::iterator iter = inactive_trackers.begin(); + for (std::set<int64_t>::iterator iter = inactive_trackers.begin(); iter != inactive_trackers.end(); ++iter) { trackers_by_parent.erase(*iter); } } // Traverse tracker tree from sync-root. - std::set<int64> visited_trackers; + std::set<int64_t> visited_trackers; { - std::vector<int64> pending; + std::vector<int64_t> pending; if (sync_root_tracker_id != kInvalidTrackerID) pending.push_back(sync_root_tracker_id); while (!pending.empty()) { - int64 tracker_id = pending.back(); + int64_t tracker_id = pending.back(); DCHECK_NE(kInvalidTrackerID, tracker_id); pending.pop_back(); @@ -198,7 +202,7 @@ void RemoveUnreachableItemsFromDB(LevelDBWrapper* db, } AppendContents( - LookUpMap(trackers_by_parent, tracker_id, std::set<int64>()), + LookUpMap(trackers_by_parent, tracker_id, std::set<int64_t>()), &pending); } } @@ -305,8 +309,8 @@ bool MetadataDatabaseIndexOnDisk::GetFileMetadata( return true; } -bool MetadataDatabaseIndexOnDisk::GetFileTracker( - int64 tracker_id, FileTracker* tracker) const { +bool MetadataDatabaseIndexOnDisk::GetFileTracker(int64_t tracker_id, + FileTracker* tracker) const { const std::string key = kFileTrackerKeyPrefix + base::Int64ToString(tracker_id); std::string value; @@ -346,7 +350,7 @@ void MetadataDatabaseIndexOnDisk::StoreFileTracker( scoped_ptr<FileTracker> tracker) { DCHECK(tracker); - int64 tracker_id = tracker->tracker_id(); + int64_t tracker_id = tracker->tracker_id(); FileTracker old_tracker; if (!GetFileTracker(tracker_id, &old_tracker)) { DVLOG(3) << "Adding new tracker: " << tracker->tracker_id() @@ -372,7 +376,7 @@ void MetadataDatabaseIndexOnDisk::RemoveFileMetadata( PutFileMetadataDeletionToDB(file_id, db_); } -void MetadataDatabaseIndexOnDisk::RemoveFileTracker(int64 tracker_id) { +void MetadataDatabaseIndexOnDisk::RemoveFileTracker(int64_t tracker_id) { FileTracker tracker; if (!GetFileTracker(tracker_id, &tracker)) { NOTREACHED(); @@ -396,7 +400,7 @@ TrackerIDSet MetadataDatabaseIndexOnDisk::GetFileTrackerIDsByFileID( GenerateTrackerIDByFileIDKeyPrefix(file_id)); } -int64 MetadataDatabaseIndexOnDisk::GetAppRootTracker( +int64_t MetadataDatabaseIndexOnDisk::GetAppRootTracker( const std::string& app_id) const { const std::string key = GenerateAppRootIDByAppIDKey(app_id); std::string value; @@ -413,7 +417,7 @@ int64 MetadataDatabaseIndexOnDisk::GetAppRootTracker( return kInvalidTrackerID; } - int64 root_id; + int64_t root_id; if (!base::StringToInt64(value, &root_id)) { util::Log(logging::LOG_WARNING, FROM_HERE, "Failed to parse a root ID (%s) for an App ID: %s", @@ -426,15 +430,16 @@ int64 MetadataDatabaseIndexOnDisk::GetAppRootTracker( } TrackerIDSet MetadataDatabaseIndexOnDisk::GetFileTrackerIDsByParentAndTitle( - int64 parent_tracker_id, const std::string& title) const { + int64_t parent_tracker_id, + const std::string& title) const { return GetTrackerIDSetByPrefix( GenerateActiveTrackerIDByParentAndTitleKey(parent_tracker_id, title), GenerateTrackerIDByParentAndTitleKeyPrefix(parent_tracker_id, title)); } -std::vector<int64> MetadataDatabaseIndexOnDisk::GetFileTrackerIDsByParent( - int64 parent_id) const { - std::vector<int64> result; +std::vector<int64_t> MetadataDatabaseIndexOnDisk::GetFileTrackerIDsByParent( + int64_t parent_id) const { + std::vector<int64_t> result; const std::string prefix = GenerateTrackerIDsByParentIDKeyPrefix(parent_id); scoped_ptr<LevelDBWrapper::Iterator> itr(db_->NewIterator()); @@ -447,7 +452,7 @@ std::vector<int64> MetadataDatabaseIndexOnDisk::GetFileTrackerIDsByParent( size_t pos = title_and_id.rfind('\0'); DCHECK(pos != std::string::npos); - int64 tracker_id; + int64_t tracker_id; if (!base::StringToInt64(title_and_id.substr(pos + 1), &tracker_id)) continue; result.push_back(tracker_id); @@ -484,12 +489,12 @@ ParentIDAndTitle MetadataDatabaseIndexOnDisk::PickMultiBackingFilePath() const { if (pos == std::string::npos) return ParentIDAndTitle(); - int64 parent_id; + int64_t parent_id; return base::StringToInt64(value.substr(0, pos), &parent_id) ? ParentIDAndTitle(parent_id, value.substr(pos + 1)) : ParentIDAndTitle(); } -int64 MetadataDatabaseIndexOnDisk::PickDirtyTracker() const { +int64_t MetadataDatabaseIndexOnDisk::PickDirtyTracker() const { scoped_ptr<LevelDBWrapper::Iterator> itr(db_->NewIterator()); itr->Seek(kDirtyIDKeyPrefix); if (!itr->Valid()) @@ -499,14 +504,14 @@ int64 MetadataDatabaseIndexOnDisk::PickDirtyTracker() const { if (!RemovePrefix(itr->key().ToString(), kDirtyIDKeyPrefix, &id_str)) return kInvalidTrackerID; - int64 tracker_id; + int64_t tracker_id; if (!base::StringToInt64(id_str, &tracker_id)) return kInvalidTrackerID; return tracker_id; } -void MetadataDatabaseIndexOnDisk::DemoteDirtyTracker(int64 tracker_id) { +void MetadataDatabaseIndexOnDisk::DemoteDirtyTracker(int64_t tracker_id) { const std::string key = GenerateDirtyIDKey(tracker_id); std::string value; @@ -536,11 +541,12 @@ bool MetadataDatabaseIndexOnDisk::HasDemotedDirtyTracker() const { } bool MetadataDatabaseIndexOnDisk::IsDemotedDirtyTracker( - int64 tracker_id) const { + int64_t tracker_id) const { return DBHasKey(GenerateDemotedDirtyIDKey(tracker_id)); } -void MetadataDatabaseIndexOnDisk::PromoteDemotedDirtyTracker(int64 tracker_id) { +void MetadataDatabaseIndexOnDisk::PromoteDemotedDirtyTracker( + int64_t tracker_id) { std::string demoted_key = GenerateDemotedDirtyIDKey(tracker_id); std::string empty; @@ -559,7 +565,7 @@ bool MetadataDatabaseIndexOnDisk::PromoteDemotedDirtyTrackers() { if (!RemovePrefix(itr->key().ToString(), kDemotedDirtyIDKeyPrefix, &id_str)) break; - int64 tracker_id; + int64_t tracker_id; if (!base::StringToInt64(id_str, &tracker_id)) continue; @@ -607,19 +613,19 @@ void MetadataDatabaseIndexOnDisk::SetSyncRootRevalidated() const { } void MetadataDatabaseIndexOnDisk::SetSyncRootTrackerID( - int64 sync_root_id) const { + int64_t sync_root_id) const { service_metadata_->set_sync_root_tracker_id(sync_root_id); PutServiceMetadataToDB(*service_metadata_, db_); } void MetadataDatabaseIndexOnDisk::SetLargestChangeID( - int64 largest_change_id) const { + int64_t largest_change_id) const { service_metadata_->set_largest_change_id(largest_change_id); PutServiceMetadataToDB(*service_metadata_, db_); } void MetadataDatabaseIndexOnDisk::SetNextTrackerID( - int64 next_tracker_id) const { + int64_t next_tracker_id) const { service_metadata_->set_next_tracker_id(next_tracker_id); PutServiceMetadataToDB(*service_metadata_, db_); } @@ -629,19 +635,19 @@ bool MetadataDatabaseIndexOnDisk::IsSyncRootRevalidated() const { service_metadata_->sync_root_revalidated(); } -int64 MetadataDatabaseIndexOnDisk::GetSyncRootTrackerID() const { +int64_t MetadataDatabaseIndexOnDisk::GetSyncRootTrackerID() const { if (!service_metadata_->has_sync_root_tracker_id()) return kInvalidTrackerID; return service_metadata_->sync_root_tracker_id(); } -int64 MetadataDatabaseIndexOnDisk::GetLargestChangeID() const { +int64_t MetadataDatabaseIndexOnDisk::GetLargestChangeID() const { if (!service_metadata_->has_largest_change_id()) return kInvalidTrackerID; return service_metadata_->largest_change_id(); } -int64 MetadataDatabaseIndexOnDisk::GetNextTrackerID() const { +int64_t MetadataDatabaseIndexOnDisk::GetNextTrackerID() const { if (!service_metadata_->has_next_tracker_id()) return kInvalidTrackerID; return service_metadata_->next_tracker_id(); @@ -660,15 +666,15 @@ MetadataDatabaseIndexOnDisk::GetRegisteredAppIDs() const { return result; } -std::vector<int64> MetadataDatabaseIndexOnDisk::GetAllTrackerIDs() const { - std::vector<int64> tracker_ids; +std::vector<int64_t> MetadataDatabaseIndexOnDisk::GetAllTrackerIDs() const { + std::vector<int64_t> tracker_ids; scoped_ptr<LevelDBWrapper::Iterator> itr(db_->NewIterator()); for (itr->Seek(kFileTrackerKeyPrefix); itr->Valid(); itr->Next()) { std::string id_str; if (!RemovePrefix(itr->key().ToString(), kFileTrackerKeyPrefix, &id_str)) break; - int64 tracker_id; + int64_t tracker_id; if (!base::StringToInt64(id_str, &tracker_id)) continue; tracker_ids.push_back(tracker_id); @@ -689,8 +695,8 @@ MetadataDatabaseIndexOnDisk::GetAllMetadataIDs() const { return file_ids; } -int64 MetadataDatabaseIndexOnDisk::BuildTrackerIndexes() { - int64 num_puts_before = db_->num_puts(); +int64_t MetadataDatabaseIndexOnDisk::BuildTrackerIndexes() { + int64_t num_puts_before = db_->num_puts(); scoped_ptr<LevelDBWrapper::Iterator> itr(db_->NewIterator()); for (itr->Seek(kFileTrackerKeyPrefix); itr->Valid(); itr->Next()) { @@ -713,7 +719,7 @@ int64 MetadataDatabaseIndexOnDisk::BuildTrackerIndexes() { return db_->num_puts() - num_puts_before; } -int64 MetadataDatabaseIndexOnDisk::DeleteTrackerIndexes() { +int64_t MetadataDatabaseIndexOnDisk::DeleteTrackerIndexes() { const char* kIndexPrefixes[] = { kAppRootIDByAppIDKeyPrefix, kActiveTrackerIDByFileIDKeyPrefix, kTrackerIDByFileIDKeyPrefix, kMultiTrackerByFileIDKeyPrefix, @@ -722,7 +728,7 @@ int64 MetadataDatabaseIndexOnDisk::DeleteTrackerIndexes() { kDirtyIDKeyPrefix, kDemotedDirtyIDKeyPrefix }; - int64 num_deletes_before = db_->num_deletes(); + int64_t num_deletes_before = db_->num_deletes(); for (size_t i = 0; i < arraysize(kIndexPrefixes); ++i) DeleteKeyStartsWith(kIndexPrefixes[i]); num_dirty_trackers_ = 0; @@ -741,15 +747,15 @@ MetadataDatabaseIndexOnDisk::MetadataDatabaseIndexOnDisk(LevelDBWrapper* db) service_metadata_ = InitializeServiceMetadata(db_); // Check if index is valid, if no validations run in 7 days. - const int64 kThresholdToValidateInDays = 7; + const int64_t kThresholdToValidateInDays = 7; - int64 last_check_time = 0; + int64_t last_check_time = 0; std::string value; if (db_->Get(kLastValidationTimeKey, &value).ok()) base::StringToInt64(value, &last_check_time); base::TimeDelta since_last_check = base::Time::Now() - base::Time::FromInternalValue(last_check_time); - int64 since_last_check_in_days = since_last_check.InDays(); + int64_t since_last_check_in_days = since_last_check.InDays(); if (since_last_check_in_days >= kThresholdToValidateInDays || since_last_check_in_days < 0) { // TODO(peria): Add UMA to check if the number of deleted entries and the @@ -877,7 +883,7 @@ void MetadataDatabaseIndexOnDisk::RemoveFromFileIDIndexes( void MetadataDatabaseIndexOnDisk::AddToPathIndexes( const FileTracker& new_tracker) { - int64 parent_id = new_tracker.parent_tracker_id(); + int64_t parent_id = new_tracker.parent_tracker_id(); std::string title = GetTrackerTitle(new_tracker); DVLOG(1) << " Add to trackers by parent and title: " @@ -892,7 +898,7 @@ void MetadataDatabaseIndexOnDisk::AddToPathIndexes( if (!RemovePrefix(itr->key().ToString(), prefix, &id_str)) break; - int64 tracker_id; + int64_t tracker_id; if (!base::StringToInt64(id_str, &tracker_id)) continue; if (tracker_id == new_tracker.tracker_id()) { @@ -922,8 +928,8 @@ void MetadataDatabaseIndexOnDisk::UpdateInPathIndexes( DCHECK(GetTrackerTitle(old_tracker) == GetTrackerTitle(new_tracker) || !old_tracker.has_synced_details()); - int64 tracker_id = new_tracker.tracker_id(); - int64 parent_id = new_tracker.parent_tracker_id(); + int64_t tracker_id = new_tracker.tracker_id(); + int64_t parent_id = new_tracker.parent_tracker_id(); const std::string old_title = GetTrackerTitle(old_tracker); const std::string title = GetTrackerTitle(new_tracker); @@ -980,8 +986,8 @@ void MetadataDatabaseIndexOnDisk::UpdateInPathIndexes( void MetadataDatabaseIndexOnDisk::RemoveFromPathIndexes( const FileTracker& tracker) { - int64 tracker_id = tracker.tracker_id(); - int64 parent_id = tracker.parent_tracker_id(); + int64_t tracker_id = tracker.tracker_id(); + int64_t parent_id = tracker.parent_tracker_id(); std::string title = GetTrackerTitle(tracker); DVLOG(1) << " Remove from trackers by parent and title: " @@ -1023,7 +1029,7 @@ void MetadataDatabaseIndexOnDisk::UpdateInDirtyTrackerIndexes( const FileTracker& new_tracker) { DCHECK_EQ(old_tracker.tracker_id(), new_tracker.tracker_id()); - int64 tracker_id = new_tracker.tracker_id(); + int64_t tracker_id = new_tracker.tracker_id(); const std::string dirty_key = GenerateDirtyIDKey(tracker_id); const std::string demoted_key = GenerateDemotedDirtyIDKey(tracker_id); if (old_tracker.dirty() && !new_tracker.dirty()) { @@ -1049,7 +1055,7 @@ void MetadataDatabaseIndexOnDisk::UpdateInDirtyTrackerIndexes( void MetadataDatabaseIndexOnDisk::RemoveFromDirtyTrackerIndexes( const FileTracker& tracker) { if (tracker.dirty()) { - int64 tracker_id = tracker.tracker_id(); + int64_t tracker_id = tracker.tracker_id(); const std::string dirty_key = GenerateDirtyIDKey(tracker_id); const std::string demoted_key = GenerateDemotedDirtyIDKey(tracker_id); DCHECK(DBHasKey(dirty_key) || DBHasKey(demoted_key)); @@ -1075,7 +1081,7 @@ TrackerIDSet MetadataDatabaseIndexOnDisk::GetTrackerIDSetByPrefix( if (!RemovePrefix(key, ids_prefix, &id_str)) break; - int64 tracker_id; + int64_t tracker_id; if (!base::StringToInt64(id_str, &tracker_id)) continue; trackers.InsertInactiveTracker(tracker_id); @@ -1084,7 +1090,7 @@ TrackerIDSet MetadataDatabaseIndexOnDisk::GetTrackerIDSetByPrefix( // Set an active tracker ID, if available. std::string value; leveldb::Status status = db_->Get(active_tracker_key, &value); - int64 active_tracker; + int64_t active_tracker; if (status.ok() && base::StringToInt64(value, &active_tracker)) { DCHECK_NE(kInvalidTrackerID, active_tracker); trackers.Activate(active_tracker); @@ -1105,8 +1111,9 @@ void MetadataDatabaseIndexOnDisk::AddToTrackerIDSetWithPrefix( } bool MetadataDatabaseIndexOnDisk::EraseInTrackerIDSetWithPrefix( - const std::string& active_tracker_key, const std::string& key_prefix, - int64 tracker_id) { + const std::string& active_tracker_key, + const std::string& key_prefix, + int64_t tracker_id) { std::string value; const std::string del_key = key_prefix + base::Int64ToString(tracker_id); leveldb::Status status = db_->Get(del_key, &value); @@ -1116,7 +1123,7 @@ bool MetadataDatabaseIndexOnDisk::EraseInTrackerIDSetWithPrefix( db_->Delete(del_key); status = db_->Get(active_tracker_key, &value); - int64 active_tracker_id; + int64_t active_tracker_id; if (status.ok() && base::StringToInt64(value, &active_tracker_id) && active_tracker_id == tracker_id) { db_->Delete(active_tracker_key); @@ -1126,13 +1133,14 @@ bool MetadataDatabaseIndexOnDisk::EraseInTrackerIDSetWithPrefix( } void MetadataDatabaseIndexOnDisk::ActivateInTrackerIDSetWithPrefix( - const std::string& active_tracker_key, const std::string& key_prefix, - int64 tracker_id) { + const std::string& active_tracker_key, + const std::string& key_prefix, + int64_t tracker_id) { DCHECK(DBHasKey(key_prefix + base::Int64ToString(tracker_id))); std::string value; leveldb::Status status = db_->Get(active_tracker_key, &value); - int64 active_tracker_id = kInvalidTrackerID; + int64_t active_tracker_id = kInvalidTrackerID; if (status.IsNotFound() || (status.ok() && base::StringToInt64(value, &active_tracker_id))) { DCHECK(active_tracker_id != tracker_id); @@ -1141,13 +1149,14 @@ void MetadataDatabaseIndexOnDisk::ActivateInTrackerIDSetWithPrefix( } void MetadataDatabaseIndexOnDisk::DeactivateInTrackerIDSetWithPrefix( - const std::string& active_tracker_key, const std::string& key_prefix, - int64 tracker_id) { + const std::string& active_tracker_key, + const std::string& key_prefix, + int64_t tracker_id) { DCHECK(DBHasKey(key_prefix + base::Int64ToString(tracker_id))); std::string value; leveldb::Status status = db_->Get(active_tracker_key, &value); - int64 active_tracker_id; + int64_t active_tracker_id; if (status.ok() && base::StringToInt64(value, &active_tracker_id)) { DCHECK(active_tracker_id == tracker_id); db_->Delete(active_tracker_key); @@ -1175,8 +1184,8 @@ size_t MetadataDatabaseIndexOnDisk::CountDirtyTrackerInternal() const { } MetadataDatabaseIndexOnDisk::NumEntries -MetadataDatabaseIndexOnDisk::CountWithPrefix( - const std::string& prefix, int64 ignored_id) { +MetadataDatabaseIndexOnDisk::CountWithPrefix(const std::string& prefix, + int64_t ignored_id) { const std::string ignored = base::Int64ToString(ignored_id); size_t count = 0; diff --git a/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.h b/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.h index 5e50572..c06adb9 100644 --- a/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.h +++ b/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.h @@ -5,11 +5,15 @@ #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_INDEX_ON_DISK_H_ #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_INDEX_ON_DISK_H_ +#include <stddef.h> +#include <stdint.h> + #include <map> #include <set> #include <string> #include <vector> +#include "base/macros.h" #include "chrome/browser/sync_file_system/drive_backend/metadata_database_index_interface.h" #include "chrome/browser/sync_file_system/drive_backend/tracker_id_set.h" @@ -36,49 +40,49 @@ class MetadataDatabaseIndexOnDisk : public MetadataDatabaseIndexInterface { void RemoveUnreachableItems() override; bool GetFileMetadata(const std::string& file_id, FileMetadata* metadata) const override; - bool GetFileTracker(int64 tracker_id, FileTracker* tracker) const override; + bool GetFileTracker(int64_t tracker_id, FileTracker* tracker) const override; void StoreFileMetadata(scoped_ptr<FileMetadata> metadata) override; void StoreFileTracker(scoped_ptr<FileTracker> tracker) override; void RemoveFileMetadata(const std::string& file_id) override; - void RemoveFileTracker(int64 tracker_id) override; + void RemoveFileTracker(int64_t tracker_id) override; TrackerIDSet GetFileTrackerIDsByFileID( const std::string& file_id) const override; - int64 GetAppRootTracker(const std::string& app_id) const override; + int64_t GetAppRootTracker(const std::string& app_id) const override; TrackerIDSet GetFileTrackerIDsByParentAndTitle( - int64 parent_tracker_id, + int64_t parent_tracker_id, const std::string& title) const override; - std::vector<int64> GetFileTrackerIDsByParent( - int64 parent_tracker_id) const override; + std::vector<int64_t> GetFileTrackerIDsByParent( + int64_t parent_tracker_id) const override; std::string PickMultiTrackerFileID() const override; ParentIDAndTitle PickMultiBackingFilePath() const override; - int64 PickDirtyTracker() const override; - void DemoteDirtyTracker(int64 tracker_id) override; + int64_t PickDirtyTracker() const override; + void DemoteDirtyTracker(int64_t tracker_id) override; bool HasDemotedDirtyTracker() const override; - bool IsDemotedDirtyTracker(int64 tracker_id) const override; - void PromoteDemotedDirtyTracker(int64 tracker_id) override; + bool IsDemotedDirtyTracker(int64_t tracker_id) const override; + void PromoteDemotedDirtyTracker(int64_t tracker_id) override; bool PromoteDemotedDirtyTrackers() override; size_t CountDirtyTracker() const override; size_t CountFileMetadata() const override; size_t CountFileTracker() const override; void SetSyncRootRevalidated() const override; - void SetSyncRootTrackerID(int64 sync_root_id) const override; - void SetLargestChangeID(int64 largest_change_id) const override; - void SetNextTrackerID(int64 next_tracker_id) const override; + void SetSyncRootTrackerID(int64_t sync_root_id) const override; + void SetLargestChangeID(int64_t largest_change_id) const override; + void SetNextTrackerID(int64_t next_tracker_id) const override; bool IsSyncRootRevalidated() const override; - int64 GetSyncRootTrackerID() const override; - int64 GetLargestChangeID() const override; - int64 GetNextTrackerID() const override; + int64_t GetSyncRootTrackerID() const override; + int64_t GetLargestChangeID() const override; + int64_t GetNextTrackerID() const override; std::vector<std::string> GetRegisteredAppIDs() const override; - std::vector<int64> GetAllTrackerIDs() const override; + std::vector<int64_t> GetAllTrackerIDs() const override; std::vector<std::string> GetAllMetadataIDs() const override; // Builds on-disk indexes from FileTracker entries on disk. // Returns the number of newly added entries for indexing. - int64 BuildTrackerIndexes(); + int64_t BuildTrackerIndexes(); // Deletes entries used for indexes on on-disk database. // Returns the number of the deleted entries. - int64 DeleteTrackerIndexes(); + int64_t DeleteTrackerIndexes(); LevelDBWrapper* GetDBForTesting(); @@ -133,24 +137,21 @@ class MetadataDatabaseIndexOnDisk : public MetadataDatabaseIndexInterface { // Returns true if |tracker_id| is removed successfully. If no other entries // are stored with |key_prefix|, the entry for |active_key| is also removed. - bool EraseInTrackerIDSetWithPrefix( - const std::string& active_tracker_key, - const std::string& key_prefix, - int64 tracker_id); + bool EraseInTrackerIDSetWithPrefix(const std::string& active_tracker_key, + const std::string& key_prefix, + int64_t tracker_id); // Adds an entry for |active_key| on DB, if |tracker_id| has an entry with // |key_prefix|. - void ActivateInTrackerIDSetWithPrefix( - const std::string& active_tracker_key, - const std::string& key_prefix, - int64 tracker_id); + void ActivateInTrackerIDSetWithPrefix(const std::string& active_tracker_key, + const std::string& key_prefix, + int64_t tracker_id); // Removes an entry for |active_key| on DB, if the value of |active_key| key // is |tracker_id|. - void DeactivateInTrackerIDSetWithPrefix( - const std::string& active_tracker_key, - const std::string& key_prefix, - int64 tracker_id); + void DeactivateInTrackerIDSetWithPrefix(const std::string& active_tracker_key, + const std::string& key_prefix, + int64_t tracker_id); // Checks if |db_| has an entry whose key is |key|. bool DBHasKey(const std::string& key) const; @@ -160,7 +161,7 @@ class MetadataDatabaseIndexOnDisk : public MetadataDatabaseIndexInterface { // Returns the number of entries starting with |prefix| in NumEntries format. // Entries for |ignored_id| are not counted in. - NumEntries CountWithPrefix(const std::string& prefix, int64 ignored_id); + NumEntries CountWithPrefix(const std::string& prefix, int64_t ignored_id); // Deletes entries whose keys start from |prefix|. void DeleteKeyStartsWith(const std::string& prefix); diff --git a/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk_unittest.cc b/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk_unittest.cc index 1ec85c5..55442a0 100644 --- a/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk_unittest.cc +++ b/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk_unittest.cc @@ -4,6 +4,8 @@ #include "chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.h" +#include <stdint.h> + #include <algorithm> #include "base/files/scoped_temp_dir.h" @@ -24,10 +26,10 @@ namespace drive_backend { namespace { -const int64 kSyncRootTrackerID = 1; -const int64 kAppRootTrackerID = 2; -const int64 kFileTrackerID = 3; -const int64 kPlaceholderTrackerID = 4; +const int64_t kSyncRootTrackerID = 1; +const int64_t kAppRootTrackerID = 2; +const int64_t kFileTrackerID = 3; +const int64_t kPlaceholderTrackerID = 4; } // namespace @@ -154,7 +156,7 @@ TEST_F(MetadataDatabaseIndexOnDiskTest, GetEntryTest) { TEST_F(MetadataDatabaseIndexOnDiskTest, SetEntryTest) { CreateTestDatabase(false, nullptr); - const int64 tracker_id = 10; + const int64_t tracker_id = 10; scoped_ptr<FileMetadata> metadata = test_util::CreateFileMetadata("test_file_id", "test_title", "test_md5"); FileTracker root_tracker; @@ -230,7 +232,7 @@ TEST_F(MetadataDatabaseIndexOnDiskTest, SyncRootInvalidation) { CreateTestDatabase(true, nullptr); EXPECT_NE(kInvalidTrackerID, index()->GetAppRootTracker("app_id")); - const int64 kNewSyncRootTrackerID = 10; + const int64_t kNewSyncRootTrackerID = 10; scoped_ptr<FileMetadata> new_sync_root_metadata = test_util::CreateFolderMetadata("new_sync_root_folder_id", kSyncRootFolderTitle); @@ -280,7 +282,7 @@ TEST_F(MetadataDatabaseIndexOnDiskTest, BuildIndexTest) { TEST_F(MetadataDatabaseIndexOnDiskTest, BuildAndDeleteIndexTest) { CreateTestDatabase(false, nullptr); - int64 answer = index()->BuildTrackerIndexes(); + int64_t answer = index()->BuildTrackerIndexes(); WriteToDB(); ASSERT_EQ(16, answer); EXPECT_EQ(answer, index()->DeleteTrackerIndexes()); @@ -301,7 +303,7 @@ TEST_F(MetadataDatabaseIndexOnDiskTest, AllEntriesTest) { EXPECT_EQ("sync_root_folder_id", file_ids[2]); EXPECT_EQ(4U, index()->CountFileTracker()); - std::vector<int64> tracker_ids = index()->GetAllTrackerIDs(); + std::vector<int64_t> tracker_ids = index()->GetAllTrackerIDs(); ASSERT_EQ(4U, tracker_ids.size()); std::sort(tracker_ids.begin(), tracker_ids.end()); EXPECT_EQ(kSyncRootTrackerID, tracker_ids[0]); @@ -320,7 +322,7 @@ TEST_F(MetadataDatabaseIndexOnDiskTest, IndexAppRootIDByAppIDTest) { EXPECT_EQ(kInvalidTrackerID, index()->GetAppRootTracker("")); EXPECT_EQ(kAppRootTrackerID, index()->GetAppRootTracker("app_id")); - const int64 kAppRootTrackerID2 = 12; + const int64_t kAppRootTrackerID2 = 12; FileTracker sync_root_tracker; index()->GetFileTracker(kSyncRootTrackerID, &sync_root_tracker); scoped_ptr<FileMetadata> app_root_metadata = @@ -383,7 +385,7 @@ TEST_F(MetadataDatabaseIndexOnDiskTest, TrackerIDSetByFileIDTest) { EXPECT_EQ(1U, tracker_ids.size()); EXPECT_EQ(kFileTrackerID, tracker_ids.active_tracker()); - const int64 tracker_id = 21; + const int64_t tracker_id = 21; // Testing AddToFileIDIndexes scoped_ptr<FileTracker> file_tracker = test_util::CreateTracker(metadata, tracker_id, &app_root_tracker); @@ -452,7 +454,7 @@ TEST_F(MetadataDatabaseIndexOnDiskTest, TrackerIDSetByParentIDAndTitleTest) { kAppRootTrackerID, "file2"); EXPECT_TRUE(tracker_ids.empty()); - const int64 tracker_id = 72; + const int64_t tracker_id = 72; // Testing AddToFileIDIndexes scoped_ptr<FileTracker> file_tracker = test_util::CreateTracker(metadata, tracker_id, &app_root_tracker); @@ -515,8 +517,8 @@ TEST_F(MetadataDatabaseIndexOnDiskTest, TrackerIDSetByParentIDAndTitleTest_EmptyTitle) { CreateTestDatabase(true, nullptr); - const int64 kFolderTrackerID = 23; - const int64 kNewFileTrackerID = 42; + const int64_t kFolderTrackerID = 23; + const int64_t kNewFileTrackerID = 42; { FileTracker app_root_tracker; EXPECT_TRUE(index()->GetFileTracker(kAppRootTrackerID, &app_root_tracker)); @@ -575,8 +577,8 @@ TEST_F(MetadataDatabaseIndexOnDiskTest, TrackerIDSetDetailsTest) { FileTracker app_root; EXPECT_TRUE(index()->GetFileTracker(kAppRootTrackerID, &app_root)); - const int64 kFileTrackerID2 = 123; - const int64 kFileTrackerID3 = 124; + const int64_t kFileTrackerID2 = 123; + const int64_t kFileTrackerID3 = 124; scoped_ptr<FileMetadata> file_metadata = test_util::CreateFileMetadata("file_id2", "file_2", "file_md5_2"); scoped_ptr<FileTracker> file_tracker = @@ -619,7 +621,7 @@ TEST_F(MetadataDatabaseIndexOnDiskTest, DirtyTrackersTest) { EXPECT_TRUE(index()->HasDemotedDirtyTracker()); EXPECT_EQ(0U, index()->CountDirtyTracker()); - const int64 tracker_id = 13; + const int64_t tracker_id = 13; scoped_ptr<FileTracker> app_root_tracker(new FileTracker); index()->GetFileTracker(kAppRootTrackerID, app_root_tracker.get()); diff --git a/chrome/browser/sync_file_system/drive_backend/metadata_database_index_unittest.cc b/chrome/browser/sync_file_system/drive_backend/metadata_database_index_unittest.cc index 482c0dd..dc0e596 100644 --- a/chrome/browser/sync_file_system/drive_backend/metadata_database_index_unittest.cc +++ b/chrome/browser/sync_file_system/drive_backend/metadata_database_index_unittest.cc @@ -4,6 +4,8 @@ #include "chrome/browser/sync_file_system/drive_backend/metadata_database_index.h" +#include <stdint.h> + #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.h" #include "chrome/browser/sync_file_system/drive_backend/drive_backend_test_util.h" #include "chrome/browser/sync_file_system/drive_backend/leveldb_wrapper.h" @@ -19,10 +21,10 @@ namespace drive_backend { namespace { -const int64 kSyncRootTrackerID = 1; -const int64 kAppRootTrackerID = 2; -const int64 kFileTrackerID = 3; -const int64 kPlaceholderTrackerID = 4; +const int64_t kSyncRootTrackerID = 1; +const int64_t kAppRootTrackerID = 2; +const int64_t kFileTrackerID = 3; +const int64_t kPlaceholderTrackerID = 4; scoped_ptr<DatabaseContents> CreateTestDatabaseContents() { scoped_ptr<DatabaseContents> contents(new DatabaseContents); @@ -117,7 +119,7 @@ TEST_F(MetadataDatabaseIndexTest, IndexLookUpTest) { EXPECT_TRUE(trackers.has_active()); EXPECT_EQ(kFileTrackerID, trackers.active_tracker()); - int64 app_root_tracker_id = index()->GetAppRootTracker("app_id"); + int64_t app_root_tracker_id = index()->GetAppRootTracker("app_id"); EXPECT_EQ(kAppRootTrackerID, app_root_tracker_id); trackers = index()->GetFileTrackerIDsByParentAndTitle( @@ -145,7 +147,7 @@ TEST_F(MetadataDatabaseIndexTest, UpdateTest) { FileTracker app_root_tracker; ASSERT_TRUE(index()->GetFileTracker(kAppRootTrackerID, &app_root_tracker)); - int64 new_tracker_id = 100; + int64_t new_tracker_id = 100; scoped_ptr<FileTracker> new_tracker = test_util::CreateTracker(metadata, new_tracker_id, &app_root_tracker); new_tracker->set_active(false); diff --git a/chrome/browser/sync_file_system/drive_backend/metadata_database_unittest.cc b/chrome/browser/sync_file_system/drive_backend/metadata_database_unittest.cc index 90f43f5..cd7af78 100644 --- a/chrome/browser/sync_file_system/drive_backend/metadata_database_unittest.cc +++ b/chrome/browser/sync_file_system/drive_backend/metadata_database_unittest.cc @@ -4,8 +4,11 @@ #include "chrome/browser/sync_file_system/drive_backend/metadata_database.h" +#include <stdint.h> + #include "base/bind.h" #include "base/files/scoped_temp_dir.h" +#include "base/macros.h" #include "base/message_loop/message_loop.h" #include "base/strings/string_number_conversions.h" #include "base/thread_task_runner_handle.h" @@ -34,8 +37,8 @@ namespace { typedef MetadataDatabase::FileIDList FileIDList; -const int64 kInitialChangeID = 1234; -const int64 kSyncRootTrackerID = 100; +const int64_t kInitialChangeID = 1234; +const int64_t kSyncRootTrackerID = 100; const char kSyncRootFolderID[] = "sync_root_folder_id"; // This struct is used to setup initial state of the database in the test and @@ -82,7 +85,7 @@ void ExpectEquivalent(const FileTracker* left, const FileTracker* right) { test_util::ExpectEquivalentTrackers(*left, *right); } -void ExpectEquivalent(int64 left, int64 right) { +void ExpectEquivalent(int64_t left, int64_t right) { EXPECT_EQ(left, right); } @@ -192,7 +195,7 @@ class MetadataDatabaseTest : public testing::TestWithParam<bool> { return "file_id_" + base::Int64ToString(next_file_id_number_++); } - int64 GetTrackerIDByFileID(const std::string& file_id) { + int64_t GetTrackerIDByFileID(const std::string& file_id) { TrackerIDSet trackers; if (metadata_database_->FindTrackersByFileID(file_id, &trackers)) { EXPECT_FALSE(trackers.empty()); @@ -587,7 +590,7 @@ class MetadataDatabaseTest : public testing::TestWithParam<bool> { } SyncStatusCode PopulateInitialData( - int64 largest_change_id, + int64_t largest_change_id, const google_apis::FileResource& sync_root_folder, const ScopedVector<google_apis::FileResource>& app_root_folders) { return metadata_database_->PopulateInitialData( @@ -598,9 +601,7 @@ class MetadataDatabaseTest : public testing::TestWithParam<bool> { tracker->set_tracker_id(GetTrackerIDByFileID(tracker->file_id())); } - int64 current_change_id() const { - return current_change_id_; - } + int64_t current_change_id() const { return current_change_id_; } private: base::ScopedTempDir database_dir_; @@ -609,10 +610,10 @@ class MetadataDatabaseTest : public testing::TestWithParam<bool> { scoped_ptr<leveldb::Env> in_memory_env_; scoped_ptr<MetadataDatabase> metadata_database_; - int64 current_change_id_; - int64 next_tracker_id_; - int64 next_file_id_number_; - int64 next_md5_sequence_number_; + int64_t current_change_id_; + int64_t next_tracker_id_; + int64_t next_file_id_number_; + int64_t next_md5_sequence_number_; DISALLOW_COPY_AND_ASSIGN(MetadataDatabaseTest); }; diff --git a/chrome/browser/sync_file_system/drive_backend/register_app_task.cc b/chrome/browser/sync_file_system/drive_backend/register_app_task.cc index cc2249b..594df14 100644 --- a/chrome/browser/sync_file_system/drive_backend/register_app_task.cc +++ b/chrome/browser/sync_file_system/drive_backend/register_app_task.cc @@ -4,6 +4,8 @@ #include "chrome/browser/sync_file_system/drive_backend/register_app_task.h" +#include <stdint.h> + #include "base/bind.h" #include "base/location.h" #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.h" @@ -57,7 +59,7 @@ void RegisterAppTask::RunExclusive(const SyncStatusCallback& callback) { return; } - int64 sync_root = metadata_database()->GetSyncRootTrackerID(); + int64_t sync_root = metadata_database()->GetSyncRootTrackerID(); TrackerIDSet trackers; if (!metadata_database()->FindTrackersByParentAndTitle( sync_root, app_id_, &trackers)) { @@ -82,7 +84,7 @@ void RegisterAppTask::RunExclusive(const SyncStatusCallback& callback) { } void RegisterAppTask::CreateAppRootFolder(const SyncStatusCallback& callback) { - int64 sync_root_tracker_id = metadata_database()->GetSyncRootTrackerID(); + int64_t sync_root_tracker_id = metadata_database()->GetSyncRootTrackerID(); FileTracker sync_root_tracker; bool should_success = metadata_database()->FindTrackerByTrackerID( sync_root_tracker_id, diff --git a/chrome/browser/sync_file_system/drive_backend/register_app_task.h b/chrome/browser/sync_file_system/drive_backend/register_app_task.h index dda99c6..d6b7e94 100644 --- a/chrome/browser/sync_file_system/drive_backend/register_app_task.h +++ b/chrome/browser/sync_file_system/drive_backend/register_app_task.h @@ -7,6 +7,7 @@ #include <string> +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/sync_file_system/drive_backend/sync_task.h" diff --git a/chrome/browser/sync_file_system/drive_backend/register_app_task_unittest.cc b/chrome/browser/sync_file_system/drive_backend/register_app_task_unittest.cc index 6145984..c6efe8d 100644 --- a/chrome/browser/sync_file_system/drive_backend/register_app_task_unittest.cc +++ b/chrome/browser/sync_file_system/drive_backend/register_app_task_unittest.cc @@ -4,10 +4,14 @@ #include "chrome/browser/sync_file_system/drive_backend/register_app_task.h" +#include <stddef.h> +#include <stdint.h> + #include <vector> #include "base/files/scoped_temp_dir.h" #include "base/format_macros.h" +#include "base/macros.h" #include "base/run_loop.h" #include "base/strings/string_number_conversions.h" #include "base/strings/stringprintf.h" @@ -33,7 +37,7 @@ namespace sync_file_system { namespace drive_backend { namespace { -const int64 kSyncRootTrackerID = 100; +const int64_t kSyncRootTrackerID = 100; } // namespace class RegisterAppTaskTest : public testing::Test { @@ -261,8 +265,8 @@ class RegisterAppTaskTest : public testing::Test { std::string sync_root_folder_id_; - int64 next_file_id_; - int64 next_tracker_id_; + int64_t next_file_id_; + int64_t next_tracker_id_; content::TestBrowserThreadBundle browser_threads_; base::ScopedTempDir database_dir_; diff --git a/chrome/browser/sync_file_system/drive_backend/remote_change_processor_on_worker.h b/chrome/browser/sync_file_system/drive_backend/remote_change_processor_on_worker.h index 2e68c09..78e5d4f 100644 --- a/chrome/browser/sync_file_system/drive_backend/remote_change_processor_on_worker.h +++ b/chrome/browser/sync_file_system/drive_backend/remote_change_processor_on_worker.h @@ -5,6 +5,7 @@ #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_REMOTE_CHANGE_PROCESSOR_ON_WORKER_H_ #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_REMOTE_CHANGE_PROCESSOR_ON_WORKER_H_ +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/sequence_checker.h" diff --git a/chrome/browser/sync_file_system/drive_backend/remote_change_processor_wrapper.h b/chrome/browser/sync_file_system/drive_backend/remote_change_processor_wrapper.h index 714dfba..bf277cc 100644 --- a/chrome/browser/sync_file_system/drive_backend/remote_change_processor_wrapper.h +++ b/chrome/browser/sync_file_system/drive_backend/remote_change_processor_wrapper.h @@ -5,6 +5,7 @@ #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_REMOTE_CHANGE_PROCESSOR_WRAPPER_H_ #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_REMOTE_CHANGE_PROCESSOR_WRAPPER_H_ +#include "base/macros.h" #include "base/memory/weak_ptr.h" #include "base/sequence_checker.h" #include "chrome/browser/sync_file_system/remote_change_processor.h" diff --git a/chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer.h b/chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer.h index 5609c17..0e5332d 100644 --- a/chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer.h +++ b/chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer.h @@ -8,6 +8,7 @@ #include <string> #include <vector> +#include "base/macros.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h" #include "chrome/browser/sync_file_system/drive_backend/sync_task.h" diff --git a/chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer_unittest.cc b/chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer_unittest.cc index 3cd033e0..4d1d0da 100644 --- a/chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer_unittest.cc +++ b/chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer_unittest.cc @@ -10,6 +10,7 @@ #include "base/callback.h" #include "base/files/scoped_temp_dir.h" #include "base/logging.h" +#include "base/macros.h" #include "base/run_loop.h" #include "base/thread_task_runner_handle.h" #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.h" diff --git a/chrome/browser/sync_file_system/drive_backend/sync_engine.cc b/chrome/browser/sync_file_system/drive_backend/sync_engine.cc index 6fbd594..0e496cd 100644 --- a/chrome/browser/sync_file_system/drive_backend/sync_engine.cc +++ b/chrome/browser/sync_file_system/drive_backend/sync_engine.cc @@ -7,6 +7,7 @@ #include <vector> #include "base/bind.h" +#include "base/macros.h" #include "base/metrics/histogram.h" #include "base/thread_task_runner_handle.h" #include "base/threading/sequenced_worker_pool.h" diff --git a/chrome/browser/sync_file_system/drive_backend/sync_engine.h b/chrome/browser/sync_file_system/drive_backend/sync_engine.h index 720993e..0d9a874 100644 --- a/chrome/browser/sync_file_system/drive_backend/sync_engine.h +++ b/chrome/browser/sync_file_system/drive_backend/sync_engine.h @@ -8,6 +8,7 @@ #include <set> #include <string> +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" diff --git a/chrome/browser/sync_file_system/drive_backend/sync_engine_context.cc b/chrome/browser/sync_file_system/drive_backend/sync_engine_context.cc index 16f2c01..e26a0eb 100644 --- a/chrome/browser/sync_file_system/drive_backend/sync_engine_context.cc +++ b/chrome/browser/sync_file_system/drive_backend/sync_engine_context.cc @@ -4,7 +4,6 @@ #include "chrome/browser/sync_file_system/drive_backend/sync_engine_context.h" -#include "base/basictypes.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/sequenced_task_runner.h" diff --git a/chrome/browser/sync_file_system/drive_backend/sync_engine_context.h b/chrome/browser/sync_file_system/drive_backend/sync_engine_context.h index 8aaaf15..982ea36 100644 --- a/chrome/browser/sync_file_system/drive_backend/sync_engine_context.h +++ b/chrome/browser/sync_file_system/drive_backend/sync_engine_context.h @@ -5,7 +5,7 @@ #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_ENGINE_CONTEXT_H_ #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_ENGINE_CONTEXT_H_ -#include "base/basictypes.h" +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" diff --git a/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer.cc b/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer.cc index 5680e35..26dfd07 100644 --- a/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer.cc +++ b/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer.cc @@ -4,6 +4,8 @@ #include "chrome/browser/sync_file_system/drive_backend/sync_engine_initializer.h" +#include <stddef.h> + #include "base/bind.h" #include "base/callback.h" #include "base/logging.h" diff --git a/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer.h b/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer.h index ee7df71..d540690 100644 --- a/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer.h +++ b/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer.h @@ -5,8 +5,11 @@ #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_ENGINE_INITIALIZER_H_ #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_ENGINE_INITIALIZER_H_ +#include <stdint.h> + #include <string> +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/memory/scoped_vector.h" @@ -110,7 +113,7 @@ class SyncEngineInitializer : public SyncTask { scoped_ptr<MetadataDatabase> metadata_database_; ScopedVector<google_apis::FileResource> app_root_folders_; - int64 largest_change_id_; + int64_t largest_change_id_; std::string root_folder_id_; scoped_ptr<google_apis::FileResource> sync_root_folder_; diff --git a/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer_unittest.cc b/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer_unittest.cc index 079dc88..aac13d8 100644 --- a/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer_unittest.cc +++ b/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer_unittest.cc @@ -4,8 +4,12 @@ #include "chrome/browser/sync_file_system/drive_backend/sync_engine_initializer.h" +#include <stddef.h> +#include <stdint.h> + #include "base/bind.h" #include "base/files/scoped_temp_dir.h" +#include "base/macros.h" #include "base/run_loop.h" #include "base/thread_task_runner_handle.h" #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.h" @@ -29,7 +33,7 @@ namespace drive_backend { namespace { -const int64 kInitialLargestChangeID = 1234; +const int64_t kInitialLargestChangeID = 1234; } // namespace @@ -163,7 +167,7 @@ class SyncEngineInitializerTest : public testing::Test { } std::string GetSyncRootFolderID() { - int64 sync_root_tracker_id = metadata_database_->GetSyncRootTrackerID(); + int64_t sync_root_tracker_id = metadata_database_->GetSyncRootTrackerID(); FileTracker sync_root_tracker; EXPECT_TRUE(metadata_database_->FindTrackerByTrackerID( sync_root_tracker_id, &sync_root_tracker)); diff --git a/chrome/browser/sync_file_system/drive_backend/sync_engine_unittest.cc b/chrome/browser/sync_file_system/drive_backend/sync_engine_unittest.cc index c2cd8ca..84b47b7 100644 --- a/chrome/browser/sync_file_system/drive_backend/sync_engine_unittest.cc +++ b/chrome/browser/sync_file_system/drive_backend/sync_engine_unittest.cc @@ -4,6 +4,8 @@ #include "chrome/browser/sync_file_system/drive_backend/sync_engine.h" +#include <stddef.h> + #include "base/files/scoped_temp_dir.h" #include "base/macros.h" #include "base/run_loop.h" diff --git a/chrome/browser/sync_file_system/drive_backend/sync_task.h b/chrome/browser/sync_file_system/drive_backend/sync_task.h index d701684..670c214 100644 --- a/chrome/browser/sync_file_system/drive_backend/sync_task.h +++ b/chrome/browser/sync_file_system/drive_backend/sync_task.h @@ -5,6 +5,7 @@ #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_TASK_H_ #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_TASK_H_ +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/sync_file_system/sync_callbacks.h" diff --git a/chrome/browser/sync_file_system/drive_backend/sync_task_manager.cc b/chrome/browser/sync_file_system/drive_backend/sync_task_manager.cc index 16e1f9b..a576262 100644 --- a/chrome/browser/sync_file_system/drive_backend/sync_task_manager.cc +++ b/chrome/browser/sync_file_system/drive_backend/sync_task_manager.cc @@ -6,6 +6,7 @@ #include "base/bind.h" #include "base/location.h" +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/sequenced_task_runner.h" #include "chrome/browser/sync_file_system/drive_backend/sync_task.h" @@ -189,7 +190,7 @@ void SyncTaskManager::UpdateTaskBlocker( continuation); } -bool SyncTaskManager::IsRunningTask(int64 token_id) const { +bool SyncTaskManager::IsRunningTask(int64_t token_id) const { DCHECK(sequence_checker_.CalledOnValidSequencedThread()); // If the client is gone, all task should be aborted. diff --git a/chrome/browser/sync_file_system/drive_backend/sync_task_manager.h b/chrome/browser/sync_file_system/drive_backend/sync_task_manager.h index 6be0e7b..688c3d9 100644 --- a/chrome/browser/sync_file_system/drive_backend/sync_task_manager.h +++ b/chrome/browser/sync_file_system/drive_backend/sync_task_manager.h @@ -5,11 +5,15 @@ #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_TASK_MANAGER_H_ #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_TASK_MANAGER_H_ +#include <stddef.h> +#include <stdint.h> + #include <queue> #include <vector> #include "base/callback.h" #include "base/containers/scoped_ptr_hash_map.h" +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/sequence_checker.h" @@ -119,7 +123,7 @@ class SyncTaskManager { scoped_ptr<TaskBlocker> task_blocker, const Continuation& continuation); - bool IsRunningTask(int64 task_token_id) const; + bool IsRunningTask(int64_t task_token_id) const; void DetachFromSequence(); bool ShouldTrackTaskToken() const; @@ -128,7 +132,7 @@ class SyncTaskManager { struct PendingTask { base::Closure task; Priority priority; - int64 seq; + int64_t seq; PendingTask(); PendingTask(const base::Closure& task, Priority pri, int seq); @@ -176,7 +180,8 @@ class SyncTaskManager { // Owns running backgrounded SyncTask to cancel the task on SyncTaskManager // deletion. - base::ScopedPtrHashMap<int64, scoped_ptr<SyncTask>> running_background_tasks_; + base::ScopedPtrHashMap<int64_t, scoped_ptr<SyncTask>> + running_background_tasks_; size_t maximum_background_task_; @@ -185,8 +190,8 @@ class SyncTaskManager { std::priority_queue<PendingTask, std::vector<PendingTask>, PendingTaskComparator> pending_tasks_; - int64 pending_task_seq_; - int64 task_token_seq_; + int64_t pending_task_seq_; + int64_t task_token_seq_; // Absence of |token_| implies a task is running. Incoming tasks should // wait for the task to finish in |pending_tasks_| if |token_| is null. diff --git a/chrome/browser/sync_file_system/drive_backend/sync_task_manager_unittest.cc b/chrome/browser/sync_file_system/drive_backend/sync_task_manager_unittest.cc index 9bb3ee0..c7ee44e 100644 --- a/chrome/browser/sync_file_system/drive_backend/sync_task_manager_unittest.cc +++ b/chrome/browser/sync_file_system/drive_backend/sync_task_manager_unittest.cc @@ -2,12 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <stdint.h> + #include <deque> #include <string> -#include "base/basictypes.h" #include "base/bind.h" #include "base/location.h" +#include "base/macros.h" #include "base/memory/weak_ptr.h" #include "base/message_loop/message_loop.h" #include "base/run_loop.h" @@ -57,7 +59,7 @@ class TaskManagerClient : public SyncTaskManager::Client, public base::SupportsWeakPtr<TaskManagerClient> { public: - explicit TaskManagerClient(int64 maximum_background_task) + explicit TaskManagerClient(int64_t maximum_background_task) : maybe_schedule_next_task_count_(0), task_scheduled_count_(0), idle_task_scheduled_count_(0), @@ -169,9 +171,9 @@ class MultihopSyncTask : public ExclusiveTask { class BackgroundTask : public SyncTask { public: struct Stats { - int64 running_background_task; - int64 finished_task; - int64 max_parallel_task; + int64_t running_background_task; + int64_t finished_task; + int64_t max_parallel_task; Stats() : running_background_task(0), diff --git a/chrome/browser/sync_file_system/drive_backend/sync_task_token.cc b/chrome/browser/sync_file_system/drive_backend/sync_task_token.cc index b4d58bf..32cb4e4 100644 --- a/chrome/browser/sync_file_system/drive_backend/sync_task_token.cc +++ b/chrome/browser/sync_file_system/drive_backend/sync_task_token.cc @@ -13,9 +13,9 @@ namespace sync_file_system { namespace drive_backend { -const int64 SyncTaskToken::kTestingTaskTokenID = -1; -const int64 SyncTaskToken::kForegroundTaskTokenID = 0; -const int64 SyncTaskToken::kMinimumBackgroundTaskTokenID = 1; +const int64_t SyncTaskToken::kTestingTaskTokenID = -1; +const int64_t SyncTaskToken::kForegroundTaskTokenID = 0; +const int64_t SyncTaskToken::kMinimumBackgroundTaskTokenID = 1; // static scoped_ptr<SyncTaskToken> SyncTaskToken::CreateForTesting( @@ -44,7 +44,7 @@ scoped_ptr<SyncTaskToken> SyncTaskToken::CreateForForegroundTask( scoped_ptr<SyncTaskToken> SyncTaskToken::CreateForBackgroundTask( const base::WeakPtr<SyncTaskManager>& manager, base::SequencedTaskRunner* task_runner, - int64 token_id, + int64_t token_id, scoped_ptr<TaskBlocker> task_blocker) { return make_scoped_ptr(new SyncTaskToken( manager, @@ -144,15 +144,14 @@ scoped_ptr<TaskLogger::TaskLog> SyncTaskToken::PassTaskLog() { SyncTaskToken::SyncTaskToken( const base::WeakPtr<SyncTaskManager>& manager, const scoped_refptr<base::SequencedTaskRunner>& task_runner, - int64 token_id, + int64_t token_id, scoped_ptr<TaskBlocker> task_blocker, const SyncStatusCallback& callback) : manager_(manager), task_runner_(task_runner), token_id_(token_id), callback_(callback), - task_blocker_(task_blocker.Pass()) { -} + task_blocker_(task_blocker.Pass()) {} } // namespace drive_backend } // namespace sync_file_system diff --git a/chrome/browser/sync_file_system/drive_backend/sync_task_token.h b/chrome/browser/sync_file_system/drive_backend/sync_task_token.h index a32fd47..1304ed6 100644 --- a/chrome/browser/sync_file_system/drive_backend/sync_task_token.h +++ b/chrome/browser/sync_file_system/drive_backend/sync_task_token.h @@ -5,8 +5,11 @@ #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_TASK_TOKEN_H_ #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_TASK_TOKEN_H_ +#include <stdint.h> + #include "base/callback.h" #include "base/location.h" +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/sync_file_system/sync_callbacks.h" @@ -22,9 +25,9 @@ struct TaskBlocker; // should run exclusively, and held by SyncTaskManager when no task is running. class SyncTaskToken { public: - static const int64 kTestingTaskTokenID; - static const int64 kForegroundTaskTokenID; - static const int64 kMinimumBackgroundTaskTokenID; + static const int64_t kTestingTaskTokenID; + static const int64_t kForegroundTaskTokenID; + static const int64_t kMinimumBackgroundTaskTokenID; static scoped_ptr<SyncTaskToken> CreateForTesting( const SyncStatusCallback& callback); @@ -34,7 +37,7 @@ class SyncTaskToken { static scoped_ptr<SyncTaskToken> CreateForBackgroundTask( const base::WeakPtr<SyncTaskManager>& manager, base::SequencedTaskRunner* task_runner, - int64 token_id, + int64_t token_id, scoped_ptr<TaskBlocker> task_blocker); void UpdateTask(const tracked_objects::Location& location, @@ -54,7 +57,7 @@ class SyncTaskToken { const TaskBlocker* task_blocker() const; void clear_task_blocker(); - int64 token_id() const { return token_id_; } + int64_t token_id() const { return token_id_; } void InitializeTaskLog(const std::string& task_description); void FinalizeTaskLog(const std::string& result_description); @@ -67,14 +70,14 @@ class SyncTaskToken { private: SyncTaskToken(const base::WeakPtr<SyncTaskManager>& manager, const scoped_refptr<base::SequencedTaskRunner>& task_runner, - int64 token_id, + int64_t token_id, scoped_ptr<TaskBlocker> task_blocker, const SyncStatusCallback& callback); base::WeakPtr<SyncTaskManager> manager_; scoped_refptr<base::SequencedTaskRunner> task_runner_; tracked_objects::Location location_; - int64 token_id_; + int64_t token_id_; SyncStatusCallback callback_; scoped_ptr<TaskLogger::TaskLog> task_log_; diff --git a/chrome/browser/sync_file_system/drive_backend/sync_worker.h b/chrome/browser/sync_file_system/drive_backend/sync_worker.h index 7ae7606..45167b6 100644 --- a/chrome/browser/sync_file_system/drive_backend/sync_worker.h +++ b/chrome/browser/sync_file_system/drive_backend/sync_worker.h @@ -8,6 +8,7 @@ #include <string> #include "base/files/file_path.h" +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" diff --git a/chrome/browser/sync_file_system/drive_backend/sync_worker_interface.h b/chrome/browser/sync_file_system/drive_backend/sync_worker_interface.h index b053974..4590a4b 100644 --- a/chrome/browser/sync_file_system/drive_backend/sync_worker_interface.h +++ b/chrome/browser/sync_file_system/drive_backend/sync_worker_interface.h @@ -7,6 +7,7 @@ #include <string> +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "chrome/browser/sync_file_system/remote_file_sync_service.h" #include "chrome/browser/sync_file_system/sync_action.h" diff --git a/chrome/browser/sync_file_system/drive_backend/sync_worker_unittest.cc b/chrome/browser/sync_file_system/drive_backend/sync_worker_unittest.cc index 6bed5bf..a8754d2 100644 --- a/chrome/browser/sync_file_system/drive_backend/sync_worker_unittest.cc +++ b/chrome/browser/sync_file_system/drive_backend/sync_worker_unittest.cc @@ -6,6 +6,7 @@ #include "base/files/scoped_temp_dir.h" #include "base/location.h" +#include "base/macros.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/strings/stringprintf.h" diff --git a/chrome/browser/sync_file_system/drive_backend/task_dependency_manager.h b/chrome/browser/sync_file_system/drive_backend/task_dependency_manager.h index f856748..8641106 100644 --- a/chrome/browser/sync_file_system/drive_backend/task_dependency_manager.h +++ b/chrome/browser/sync_file_system/drive_backend/task_dependency_manager.h @@ -5,12 +5,15 @@ #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_TASK_DEPENDENCY_MANAGER_H_ #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_TASK_DEPENDENCY_MANAGER_H_ +#include <stdint.h> + #include <map> #include <set> #include <string> #include <vector> #include "base/files/file_path.h" +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "chrome/browser/sync_file_system/subtree_set.h" @@ -22,7 +25,7 @@ struct TaskBlocker { std::string app_id; std::vector<base::FilePath> paths; std::vector<std::string> file_ids; - std::vector<int64> tracker_ids; + std::vector<int64_t> tracker_ids; TaskBlocker(); ~TaskBlocker(); @@ -53,7 +56,7 @@ class TaskDependencyManager { bool running_exclusive_task_; std::map<std::string, SubtreeSet> paths_by_app_id_; std::set<std::string> file_ids_; - std::set<int64> tracker_ids_; + std::set<int64_t> tracker_ids_; DISALLOW_COPY_AND_ASSIGN(TaskDependencyManager); }; diff --git a/chrome/browser/sync_file_system/drive_backend/tracker_id_set.cc b/chrome/browser/sync_file_system/drive_backend/tracker_id_set.cc index 9fc4bba..0bb272d 100644 --- a/chrome/browser/sync_file_system/drive_backend/tracker_id_set.cc +++ b/chrome/browser/sync_file_system/drive_backend/tracker_id_set.cc @@ -22,7 +22,7 @@ void TrackerIDSet::Insert(const FileTracker& tracker) { InsertInactiveTracker(tracker.tracker_id()); } -void TrackerIDSet::InsertActiveTracker(int64 tracker_id) { +void TrackerIDSet::InsertActiveTracker(int64_t tracker_id) { DCHECK(tracker_id); DCHECK(!active_tracker_); @@ -30,14 +30,14 @@ void TrackerIDSet::InsertActiveTracker(int64 tracker_id) { tracker_ids_.insert(tracker_id); } -void TrackerIDSet::InsertInactiveTracker(int64 tracker_id) { +void TrackerIDSet::InsertInactiveTracker(int64_t tracker_id) { DCHECK(tracker_id); DCHECK_NE(active_tracker_, tracker_id); tracker_ids_.insert(tracker_id); } -void TrackerIDSet::Erase(int64 tracker_id) { +void TrackerIDSet::Erase(int64_t tracker_id) { DCHECK(ContainsKey(tracker_ids_, tracker_id)); if (active_tracker_ == tracker_id) @@ -45,13 +45,13 @@ void TrackerIDSet::Erase(int64 tracker_id) { tracker_ids_.erase(tracker_id); } -void TrackerIDSet::Activate(int64 tracker_id) { +void TrackerIDSet::Activate(int64_t tracker_id) { DCHECK(!active_tracker_); DCHECK(ContainsKey(tracker_ids_, tracker_id)); active_tracker_ = tracker_id; } -void TrackerIDSet::Deactivate(int64 tracker_id) { +void TrackerIDSet::Deactivate(int64_t tracker_id) { DCHECK_EQ(active_tracker_, tracker_id); DCHECK(ContainsKey(tracker_ids_, tracker_id)); active_tracker_ = 0; diff --git a/chrome/browser/sync_file_system/drive_backend/tracker_id_set.h b/chrome/browser/sync_file_system/drive_backend/tracker_id_set.h index 15f4470..15217d2 100644 --- a/chrome/browser/sync_file_system/drive_backend/tracker_id_set.h +++ b/chrome/browser/sync_file_system/drive_backend/tracker_id_set.h @@ -5,9 +5,11 @@ #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_TRACKER_ID_SET_H_ #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_TRACKER_ID_SET_H_ +#include <stddef.h> +#include <stdint.h> + #include <set> -#include "base/basictypes.h" namespace sync_file_system { namespace drive_backend { @@ -16,7 +18,7 @@ class FileTracker; class TrackerIDSet { public: - typedef std::set<int64> RawTrackerIDSet; + typedef std::set<int64_t> RawTrackerIDSet; typedef RawTrackerIDSet::iterator iterator; typedef RawTrackerIDSet::const_iterator const_iterator; @@ -25,13 +27,13 @@ class TrackerIDSet { bool has_active() const { return !!active_tracker_; } void Insert(const FileTracker& tracker); - void InsertActiveTracker(int64 tracker_id); - void InsertInactiveTracker(int64 tracker_id); - void Erase(int64 tracker_id); - void Activate(int64 tracker_id); - void Deactivate(int64 tracker_id); + void InsertActiveTracker(int64_t tracker_id); + void InsertInactiveTracker(int64_t tracker_id); + void Erase(int64_t tracker_id); + void Activate(int64_t tracker_id); + void Deactivate(int64_t tracker_id); - int64 active_tracker() const { return active_tracker_; } + int64_t active_tracker() const { return active_tracker_; } const RawTrackerIDSet& tracker_set() const { return tracker_ids_; } iterator begin() { return tracker_ids_.begin(); } @@ -42,7 +44,7 @@ class TrackerIDSet { size_t size() const { return tracker_ids_.size(); } private: - int64 active_tracker_; + int64_t active_tracker_; RawTrackerIDSet tracker_ids_; }; diff --git a/chrome/browser/sync_file_system/drive_backend/uninstall_app_task.cc b/chrome/browser/sync_file_system/drive_backend/uninstall_app_task.cc index 1a5bf6f..a6351aa 100644 --- a/chrome/browser/sync_file_system/drive_backend/uninstall_app_task.cc +++ b/chrome/browser/sync_file_system/drive_backend/uninstall_app_task.cc @@ -46,7 +46,7 @@ void UninstallAppTask::RunExclusive(const SyncStatusCallback& callback) { } DCHECK_EQ(RemoteFileSyncService::UNINSTALL_AND_PURGE_REMOTE, uninstall_flag_); - int64 sync_root_tracker_id = metadata_database()->GetSyncRootTrackerID(); + int64_t sync_root_tracker_id = metadata_database()->GetSyncRootTrackerID(); TrackerIDSet trackers; if (!metadata_database()->FindTrackersByParentAndTitle( sync_root_tracker_id, app_id_, &trackers) || @@ -75,7 +75,7 @@ void UninstallAppTask::RunExclusive(const SyncStatusCallback& callback) { } void UninstallAppTask::DidDeleteAppRoot(const SyncStatusCallback& callback, - int64 change_id, + int64_t change_id, google_apis::DriveApiErrorCode error) { SyncStatusCode status = DriveApiErrorCodeToSyncStatusCode(error); if (status != SYNC_STATUS_OK && diff --git a/chrome/browser/sync_file_system/drive_backend/uninstall_app_task.h b/chrome/browser/sync_file_system/drive_backend/uninstall_app_task.h index 2b9e0d7..0f2813d 100644 --- a/chrome/browser/sync_file_system/drive_backend/uninstall_app_task.h +++ b/chrome/browser/sync_file_system/drive_backend/uninstall_app_task.h @@ -5,8 +5,11 @@ #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_UNINSTALL_APP_TASK_H_ #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_UNINSTALL_APP_TASK_H_ +#include <stdint.h> + #include <string> +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/sync_file_system/drive_backend/sync_task.h" @@ -38,7 +41,7 @@ class UninstallAppTask : public ExclusiveTask { private: void DidDeleteAppRoot(const SyncStatusCallback& callback, - int64 change_id, + int64_t change_id, google_apis::DriveApiErrorCode error); bool IsContextReady(); @@ -49,7 +52,7 @@ class UninstallAppTask : public ExclusiveTask { std::string app_id_; UninstallFlag uninstall_flag_; - int64 app_root_tracker_id_; + int64_t app_root_tracker_id_; base::WeakPtrFactory<UninstallAppTask> weak_ptr_factory_; |
