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 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 1594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1605 std::unique_ptr<base::DictionaryValue> file(new base::DictionaryValue); | 1605 std::unique_ptr<base::DictionaryValue> file(new base::DictionaryValue); |
1606 | 1606 |
1607 base::FilePath path = BuildDisplayPathForTracker(tracker); | 1607 base::FilePath path = BuildDisplayPathForTracker(tracker); |
1608 file->SetString("path", path.AsUTF8Unsafe()); | 1608 file->SetString("path", path.AsUTF8Unsafe()); |
1609 if (tracker.has_synced_details()) { | 1609 if (tracker.has_synced_details()) { |
1610 file->SetString("title", tracker.synced_details().title()); | 1610 file->SetString("title", tracker.synced_details().title()); |
1611 file->SetString("type", | 1611 file->SetString("type", |
1612 FileKindToString(tracker.synced_details().file_kind())); | 1612 FileKindToString(tracker.synced_details().file_kind())); |
1613 } | 1613 } |
1614 | 1614 |
1615 base::DictionaryValue* details = new base::DictionaryValue; | 1615 auto details = base::MakeUnique<base::DictionaryValue>(); |
1616 details->SetString("file_id", tracker.file_id()); | 1616 details->SetString("file_id", tracker.file_id()); |
1617 if (tracker.has_synced_details() && | 1617 if (tracker.has_synced_details() && |
1618 tracker.synced_details().file_kind() == FILE_KIND_FILE) | 1618 tracker.synced_details().file_kind() == FILE_KIND_FILE) |
1619 details->SetString("md5", tracker.synced_details().md5()); | 1619 details->SetString("md5", tracker.synced_details().md5()); |
1620 details->SetString("active", tracker.active() ? "true" : "false"); | 1620 details->SetString("active", tracker.active() ? "true" : "false"); |
1621 details->SetString("dirty", tracker.dirty() ? "true" : "false"); | 1621 details->SetString("dirty", tracker.dirty() ? "true" : "false"); |
1622 | 1622 |
1623 file->Set("details", details); | 1623 file->Set("details", std::move(details)); |
1624 | 1624 |
1625 files->Append(std::move(file)); | 1625 files->Append(std::move(file)); |
1626 } | 1626 } |
1627 | 1627 |
1628 return files; | 1628 return files; |
1629 } | 1629 } |
1630 | 1630 |
1631 std::unique_ptr<base::ListValue> MetadataDatabase::DumpDatabase() { | 1631 std::unique_ptr<base::ListValue> MetadataDatabase::DumpDatabase() { |
1632 std::unique_ptr<base::ListValue> list(new base::ListValue); | 1632 std::unique_ptr<base::ListValue> list(new base::ListValue); |
1633 list->Append(DumpTrackers()); | 1633 list->Append(DumpTrackers()); |
(...skipping 15 matching lines...) Expand all Loading... |
1649 | 1649 |
1650 // Append the first element for metadata. | 1650 // Append the first element for metadata. |
1651 std::unique_ptr<base::DictionaryValue> metadata(new base::DictionaryValue); | 1651 std::unique_ptr<base::DictionaryValue> metadata(new base::DictionaryValue); |
1652 const char *trackerKeys[] = { | 1652 const char *trackerKeys[] = { |
1653 "tracker_id", "path", "file_id", "tracker_kind", "app_id", | 1653 "tracker_id", "path", "file_id", "tracker_kind", "app_id", |
1654 "active", "dirty", "folder_listing", "demoted", | 1654 "active", "dirty", "folder_listing", "demoted", |
1655 "title", "kind", "md5", "etag", "missing", "change_id", | 1655 "title", "kind", "md5", "etag", "missing", "change_id", |
1656 }; | 1656 }; |
1657 std::vector<std::string> key_strings( | 1657 std::vector<std::string> key_strings( |
1658 trackerKeys, trackerKeys + arraysize(trackerKeys)); | 1658 trackerKeys, trackerKeys + arraysize(trackerKeys)); |
1659 base::ListValue* keys = new base::ListValue; | 1659 auto keys = base::MakeUnique<base::ListValue>(); |
1660 keys->AppendStrings(key_strings); | 1660 keys->AppendStrings(key_strings); |
1661 metadata->SetString("title", "Trackers"); | 1661 metadata->SetString("title", "Trackers"); |
1662 metadata->Set("keys", keys); | 1662 metadata->Set("keys", std::move(keys)); |
1663 trackers->Append(std::move(metadata)); | 1663 trackers->Append(std::move(metadata)); |
1664 | 1664 |
1665 // Append tracker data. | 1665 // Append tracker data. |
1666 std::vector<int64_t> tracker_ids(index_->GetAllTrackerIDs()); | 1666 std::vector<int64_t> tracker_ids(index_->GetAllTrackerIDs()); |
1667 for (std::vector<int64_t>::const_iterator itr = tracker_ids.begin(); | 1667 for (std::vector<int64_t>::const_iterator itr = tracker_ids.begin(); |
1668 itr != tracker_ids.end(); ++itr) { | 1668 itr != tracker_ids.end(); ++itr) { |
1669 const int64_t tracker_id = *itr; | 1669 const int64_t tracker_id = *itr; |
1670 FileTracker tracker; | 1670 FileTracker tracker; |
1671 if (!index_->GetFileTracker(tracker_id, &tracker)) { | 1671 if (!index_->GetFileTracker(tracker_id, &tracker)) { |
1672 NOTREACHED(); | 1672 NOTREACHED(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1711 std::unique_ptr<base::ListValue> files(new base::ListValue); | 1711 std::unique_ptr<base::ListValue> files(new base::ListValue); |
1712 | 1712 |
1713 // Append the first element for metadata. | 1713 // Append the first element for metadata. |
1714 std::unique_ptr<base::DictionaryValue> metadata(new base::DictionaryValue); | 1714 std::unique_ptr<base::DictionaryValue> metadata(new base::DictionaryValue); |
1715 const char *fileKeys[] = { | 1715 const char *fileKeys[] = { |
1716 "file_id", "title", "type", "md5", "etag", "missing", | 1716 "file_id", "title", "type", "md5", "etag", "missing", |
1717 "change_id", "parents" | 1717 "change_id", "parents" |
1718 }; | 1718 }; |
1719 std::vector<std::string> key_strings( | 1719 std::vector<std::string> key_strings( |
1720 fileKeys, fileKeys + arraysize(fileKeys)); | 1720 fileKeys, fileKeys + arraysize(fileKeys)); |
1721 base::ListValue* keys = new base::ListValue; | 1721 auto keys = base::MakeUnique<base::ListValue>(); |
1722 keys->AppendStrings(key_strings); | 1722 keys->AppendStrings(key_strings); |
1723 metadata->SetString("title", "Metadata"); | 1723 metadata->SetString("title", "Metadata"); |
1724 metadata->Set("keys", keys); | 1724 metadata->Set("keys", std::move(keys)); |
1725 files->Append(std::move(metadata)); | 1725 files->Append(std::move(metadata)); |
1726 | 1726 |
1727 // Append metadata data. | 1727 // Append metadata data. |
1728 std::vector<std::string> metadata_ids(index_->GetAllMetadataIDs()); | 1728 std::vector<std::string> metadata_ids(index_->GetAllMetadataIDs()); |
1729 for (std::vector<std::string>::const_iterator itr = metadata_ids.begin(); | 1729 for (std::vector<std::string>::const_iterator itr = metadata_ids.begin(); |
1730 itr != metadata_ids.end(); ++itr) { | 1730 itr != metadata_ids.end(); ++itr) { |
1731 const std::string& file_id = *itr; | 1731 const std::string& file_id = *itr; |
1732 FileMetadata file; | 1732 FileMetadata file; |
1733 if (!index_->GetFileMetadata(file_id, &file)) { | 1733 if (!index_->GetFileMetadata(file_id, &file)) { |
1734 NOTREACHED(); | 1734 NOTREACHED(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1805 return false; | 1805 return false; |
1806 | 1806 |
1807 if (!parents.empty()) | 1807 if (!parents.empty()) |
1808 return false; | 1808 return false; |
1809 | 1809 |
1810 return true; | 1810 return true; |
1811 } | 1811 } |
1812 | 1812 |
1813 } // namespace drive_backend | 1813 } // namespace drive_backend |
1814 } // namespace sync_file_system | 1814 } // namespace sync_file_system |
OLD | NEW |