| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.h" | 5 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <stack> | 8 #include <stack> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/location.h" | 14 #include "base/location.h" |
| 15 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
| 16 #include "base/message_loop/message_loop_proxy.h" | 16 #include "base/single_thread_task_runner.h" |
| 17 #include "base/sequenced_task_runner.h" | |
| 18 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
| 19 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 20 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 21 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
| 22 #include "base/task_runner_util.h" | 21 #include "base/task_runner_util.h" |
| 22 #include "base/thread_task_runner_handle.h" |
| 23 #include "base/threading/thread_restrictions.h" | 23 #include "base/threading/thread_restrictions.h" |
| 24 #include "chrome/browser/drive/drive_api_util.h" | 24 #include "chrome/browser/drive/drive_api_util.h" |
| 25 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.
h" | 25 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.
h" |
| 26 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_util.h" | 26 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_util.h" |
| 27 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h" | 27 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h" |
| 28 #include "chrome/browser/sync_file_system/drive_backend/metadata_database_index.
h" | 28 #include "chrome/browser/sync_file_system/drive_backend/metadata_database_index.
h" |
| 29 #include "chrome/browser/sync_file_system/drive_backend/metadata_database_index_
interface.h" | 29 #include "chrome/browser/sync_file_system/drive_backend/metadata_database_index_
interface.h" |
| 30 #include "chrome/browser/sync_file_system/drive_backend/metadata_db_migration_ut
il.h" | 30 #include "chrome/browser/sync_file_system/drive_backend/metadata_db_migration_ut
il.h" |
| 31 #include "chrome/browser/sync_file_system/logger.h" | 31 #include "chrome/browser/sync_file_system/logger.h" |
| 32 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" | 32 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 database_path, | 616 database_path, |
| 617 env_override))), | 617 env_override))), |
| 618 callback)); | 618 callback)); |
| 619 } | 619 } |
| 620 | 620 |
| 621 // static | 621 // static |
| 622 SyncStatusCode MetadataDatabase::CreateForTesting( | 622 SyncStatusCode MetadataDatabase::CreateForTesting( |
| 623 scoped_ptr<leveldb::DB> db, | 623 scoped_ptr<leveldb::DB> db, |
| 624 scoped_ptr<MetadataDatabase>* metadata_database_out) { | 624 scoped_ptr<MetadataDatabase>* metadata_database_out) { |
| 625 scoped_ptr<MetadataDatabase> metadata_database( | 625 scoped_ptr<MetadataDatabase> metadata_database( |
| 626 new MetadataDatabase(base::MessageLoopProxy::current(), | 626 new MetadataDatabase(base::ThreadTaskRunnerHandle::Get(), |
| 627 base::MessageLoopProxy::current(), | 627 base::ThreadTaskRunnerHandle::Get(), |
| 628 base::FilePath(), NULL)); | 628 base::FilePath(), NULL)); |
| 629 metadata_database->db_ = db.Pass(); | 629 metadata_database->db_ = db.Pass(); |
| 630 SyncStatusCode status = | 630 SyncStatusCode status = |
| 631 metadata_database->InitializeOnFileTaskRunner(); | 631 metadata_database->InitializeOnFileTaskRunner(); |
| 632 if (status == SYNC_STATUS_OK) | 632 if (status == SYNC_STATUS_OK) |
| 633 *metadata_database_out = metadata_database.Pass(); | 633 *metadata_database_out = metadata_database.Pass(); |
| 634 return status; | 634 return status; |
| 635 } | 635 } |
| 636 | 636 |
| 637 MetadataDatabase::~MetadataDatabase() { | 637 MetadataDatabase::~MetadataDatabase() { |
| (...skipping 1378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2016 index_->StoreFileMetadata(app_root_metadata.Pass(), batch); | 2016 index_->StoreFileMetadata(app_root_metadata.Pass(), batch); |
| 2017 index_->StoreFileTracker(app_root_tracker.Pass(), batch); | 2017 index_->StoreFileTracker(app_root_tracker.Pass(), batch); |
| 2018 } | 2018 } |
| 2019 | 2019 |
| 2020 void MetadataDatabase::DetachFromSequence() { | 2020 void MetadataDatabase::DetachFromSequence() { |
| 2021 worker_sequence_checker_.DetachFromSequence(); | 2021 worker_sequence_checker_.DetachFromSequence(); |
| 2022 } | 2022 } |
| 2023 | 2023 |
| 2024 } // namespace drive_backend | 2024 } // namespace drive_backend |
| 2025 } // namespace sync_file_system | 2025 } // namespace sync_file_system |
| OLD | NEW |