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 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 } | 592 } |
593 | 593 |
594 scoped_ptr<leveldb::Iterator> iter(db_->NewIterator(leveldb::ReadOptions())); | 594 scoped_ptr<leveldb::Iterator> iter(db_->NewIterator(leveldb::ReadOptions())); |
595 iter->SeekToFirst(); | 595 iter->SeekToFirst(); |
596 FileSystemURL url; | 596 FileSystemURL url; |
597 while (iter->Valid()) { | 597 while (iter->Valid()) { |
598 if (!DeserializeSyncableFileSystemURL(iter->key().ToString(), &url)) { | 598 if (!DeserializeSyncableFileSystemURL(iter->key().ToString(), &url)) { |
599 LOG(WARNING) << "Failed to deserialize an URL. " | 599 LOG(WARNING) << "Failed to deserialize an URL. " |
600 << "TrackerDB might be corrupted."; | 600 << "TrackerDB might be corrupted."; |
601 db_status_ = SYNC_DATABASE_ERROR_CORRUPTION; | 601 db_status_ = SYNC_DATABASE_ERROR_CORRUPTION; |
| 602 iter.reset(); // Must delete before closing the database. |
602 db_.reset(); | 603 db_.reset(); |
603 return db_status_; | 604 return db_status_; |
604 } | 605 } |
605 dirty_files->push(url); | 606 dirty_files->push(url); |
606 iter->Next(); | 607 iter->Next(); |
607 } | 608 } |
608 return SYNC_STATUS_OK; | 609 return SYNC_STATUS_OK; |
609 } | 610 } |
610 | 611 |
611 SyncStatusCode LocalFileChangeTracker::TrackerDB::WriteBatch( | 612 SyncStatusCode LocalFileChangeTracker::TrackerDB::WriteBatch( |
612 scoped_ptr<leveldb::WriteBatch> batch) { | 613 scoped_ptr<leveldb::WriteBatch> batch) { |
613 if (db_status_ != SYNC_STATUS_OK) | 614 if (db_status_ != SYNC_STATUS_OK) |
614 return db_status_; | 615 return db_status_; |
615 | 616 |
616 leveldb::Status status = db_->Write(leveldb::WriteOptions(), batch.get()); | 617 leveldb::Status status = db_->Write(leveldb::WriteOptions(), batch.get()); |
617 if (!status.ok() && !status.IsNotFound()) { | 618 if (!status.ok() && !status.IsNotFound()) { |
618 HandleError(FROM_HERE, status); | 619 HandleError(FROM_HERE, status); |
619 db_status_ = LevelDBStatusToSyncStatusCode(status); | 620 db_status_ = LevelDBStatusToSyncStatusCode(status); |
620 db_.reset(); | 621 db_.reset(); |
621 return db_status_; | 622 return db_status_; |
622 } | 623 } |
623 return SYNC_STATUS_OK; | 624 return SYNC_STATUS_OK; |
624 } | 625 } |
625 | 626 |
626 } // namespace sync_file_system | 627 } // namespace sync_file_system |
OLD | NEW |