| 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/local/local_file_change_tracker.h" | 5 #include "chrome/browser/sync_file_system/local/local_file_change_tracker.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <queue> | 8 #include <queue> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 return SYNC_STATUS_OK; | 485 return SYNC_STATUS_OK; |
| 486 | 486 |
| 487 std::string path = | 487 std::string path = |
| 488 storage::FilePathToString(base_path_.Append(kDatabaseName)); | 488 storage::FilePathToString(base_path_.Append(kDatabaseName)); |
| 489 leveldb::Options options; | 489 leveldb::Options options; |
| 490 options.max_open_files = 0; // Use minimum. | 490 options.max_open_files = 0; // Use minimum. |
| 491 options.create_if_missing = true; | 491 options.create_if_missing = true; |
| 492 options.reuse_logs = leveldb_env::kDefaultLogReuseOptionValue; | 492 options.reuse_logs = leveldb_env::kDefaultLogReuseOptionValue; |
| 493 if (env_override_) | 493 if (env_override_) |
| 494 options.env = env_override_; | 494 options.env = env_override_; |
| 495 leveldb::DB* db; | 495 leveldb::Status status = leveldb_env::OpenDB(options, path, &db_); |
| 496 leveldb::Status status = leveldb::DB::Open(options, path, &db); | |
| 497 UMA_HISTOGRAM_ENUMERATION("SyncFileSystem.TrackerDB.Open", | 496 UMA_HISTOGRAM_ENUMERATION("SyncFileSystem.TrackerDB.Open", |
| 498 leveldb_env::GetLevelDBStatusUMAValue(status), | 497 leveldb_env::GetLevelDBStatusUMAValue(status), |
| 499 leveldb_env::LEVELDB_STATUS_MAX); | 498 leveldb_env::LEVELDB_STATUS_MAX); |
| 500 if (status.ok()) { | 499 if (status.ok()) { |
| 501 db_.reset(db); | |
| 502 return SYNC_STATUS_OK; | 500 return SYNC_STATUS_OK; |
| 503 } | 501 } |
| 504 | 502 |
| 505 HandleError(FROM_HERE, status); | 503 HandleError(FROM_HERE, status); |
| 506 if (!status.IsCorruption()) | 504 if (!status.IsCorruption()) |
| 507 return LevelDBStatusToSyncStatusCode(status); | 505 return LevelDBStatusToSyncStatusCode(status); |
| 508 | 506 |
| 509 // Try to repair the corrupted DB. | 507 // Try to repair the corrupted DB. |
| 510 switch (recovery_option) { | 508 switch (recovery_option) { |
| 511 case FAIL_ON_CORRUPTION: | 509 case FAIL_ON_CORRUPTION: |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 if (!status.ok() && !status.IsNotFound()) { | 622 if (!status.ok() && !status.IsNotFound()) { |
| 625 HandleError(FROM_HERE, status); | 623 HandleError(FROM_HERE, status); |
| 626 db_status_ = LevelDBStatusToSyncStatusCode(status); | 624 db_status_ = LevelDBStatusToSyncStatusCode(status); |
| 627 db_.reset(); | 625 db_.reset(); |
| 628 return db_status_; | 626 return db_status_; |
| 629 } | 627 } |
| 630 return SYNC_STATUS_OK; | 628 return SYNC_STATUS_OK; |
| 631 } | 629 } |
| 632 | 630 |
| 633 } // namespace sync_file_system | 631 } // namespace sync_file_system |
| OLD | NEW |