| 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" |
| (...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 const SyncStatusCallback& callback) { | 829 const SyncStatusCallback& callback) { |
| 830 scoped_ptr<leveldb::WriteBatch> batch(new leveldb::WriteBatch); | 830 scoped_ptr<leveldb::WriteBatch> batch(new leveldb::WriteBatch); |
| 831 | 831 |
| 832 scoped_ptr<FileMetadata> file( | 832 scoped_ptr<FileMetadata> file( |
| 833 CreateFileMetadataFromFileResource( | 833 CreateFileMetadataFromFileResource( |
| 834 GetLargestKnownChangeID(), resource)); | 834 GetLargestKnownChangeID(), resource)); |
| 835 UpdateByFileMetadata(FROM_HERE, file.Pass(), batch.get()); | 835 UpdateByFileMetadata(FROM_HERE, file.Pass(), batch.get()); |
| 836 WriteToDatabase(batch.Pass(), callback); | 836 WriteToDatabase(batch.Pass(), callback); |
| 837 } | 837 } |
| 838 | 838 |
| 839 void MetadataDatabase::UpdateByFileResourceList( |
| 840 ScopedVector<google_apis::FileResource> resources, |
| 841 const SyncStatusCallback& callback) { |
| 842 scoped_ptr<leveldb::WriteBatch> batch(new leveldb::WriteBatch); |
| 843 |
| 844 for (size_t i = 0; i < resources.size(); ++i) { |
| 845 scoped_ptr<FileMetadata> file( |
| 846 CreateFileMetadataFromFileResource( |
| 847 GetLargestKnownChangeID(), *resources[i])); |
| 848 UpdateByFileMetadata(FROM_HERE, file.Pass(), batch.get()); |
| 849 } |
| 850 WriteToDatabase(batch.Pass(), callback); |
| 851 } |
| 852 |
| 839 void MetadataDatabase::UpdateByDeletedRemoteFile( | 853 void MetadataDatabase::UpdateByDeletedRemoteFile( |
| 840 const std::string& file_id, | 854 const std::string& file_id, |
| 841 const SyncStatusCallback& callback) { | 855 const SyncStatusCallback& callback) { |
| 842 scoped_ptr<leveldb::WriteBatch> batch(new leveldb::WriteBatch); | 856 scoped_ptr<leveldb::WriteBatch> batch(new leveldb::WriteBatch); |
| 843 scoped_ptr<FileMetadata> file( | 857 scoped_ptr<FileMetadata> file( |
| 844 CreateDeletedFileMetadata(GetLargestKnownChangeID(), file_id)); | 858 CreateDeletedFileMetadata(GetLargestKnownChangeID(), file_id)); |
| 845 UpdateByFileMetadata(FROM_HERE, file.Pass(), batch.get()); | 859 UpdateByFileMetadata(FROM_HERE, file.Pass(), batch.get()); |
| 846 WriteToDatabase(batch.Pass(), callback); | 860 WriteToDatabase(batch.Pass(), callback); |
| 847 } | 861 } |
| 848 | 862 |
| (...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1786 int64 change_id) { | 1800 int64 change_id) { |
| 1787 FileByID::const_iterator found = file_by_id_.find(file_id); | 1801 FileByID::const_iterator found = file_by_id_.find(file_id); |
| 1788 if (found == file_by_id_.end()) | 1802 if (found == file_by_id_.end()) |
| 1789 return false; | 1803 return false; |
| 1790 DCHECK(found->second->has_details()); | 1804 DCHECK(found->second->has_details()); |
| 1791 return found->second->details().change_id() >= change_id; | 1805 return found->second->details().change_id() >= change_id; |
| 1792 } | 1806 } |
| 1793 | 1807 |
| 1794 } // namespace drive_backend | 1808 } // namespace drive_backend |
| 1795 } // namespace sync_file_system | 1809 } // namespace sync_file_system |
| OLD | NEW |