Chromium Code Reviews| Index: chrome/browser/sync_file_system/drive_backend/metadata_database.cc |
| diff --git a/chrome/browser/sync_file_system/drive_backend/metadata_database.cc b/chrome/browser/sync_file_system/drive_backend/metadata_database.cc |
| index eb276fce76dfb15c8c9ce8bccbfbbf5ae35e6b57..1c13422a0944b280230eda8fa2d735e6ad0acc08 100644 |
| --- a/chrome/browser/sync_file_system/drive_backend/metadata_database.cc |
| +++ b/chrome/browser/sync_file_system/drive_backend/metadata_database.cc |
| @@ -1497,5 +1497,60 @@ void MetadataDatabase::WriteToDatabase(scoped_ptr<leveldb::WriteBatch> batch, |
| base::Bind(&AdaptLevelDBStatusToSyncStatusCode, callback)); |
| } |
| +std::string FileKindToString(FileKind file_kind) { |
|
nhiroki
2013/11/13 06:36:59
How about moving this somewhere else (e.g. drive_b
keishi
2013/11/13 07:10:59
Done.
|
| + switch (file_kind) { |
| + case FILE_KIND_UNSUPPORTED: |
| + return "unsupported"; |
| + case FILE_KIND_FILE: |
| + return "file"; |
| + case FILE_KIND_FOLDER: |
| + return "folder"; |
| + } |
| + |
| + NOTREACHED(); |
| + return "unknown"; |
| +} |
| + |
| +scoped_ptr<base::ListValue> MetadataDatabase::DumpFiles( |
| + const std::string& app_id) { |
| + scoped_ptr<base::ListValue> files(new base::ListValue); |
| + |
| + FileTracker app_root_tracker; |
| + if (!FindAppRootTracker(app_id, &app_root_tracker)) |
| + return files.Pass(); |
| + |
| + std::vector<int64> stack; |
| + PushChildTrackersToContainer( |
| + trackers_by_parent_and_title_, |
| + app_root_tracker.tracker_id(), |
| + std::back_inserter(stack)); |
| + while (!stack.empty()) { |
| + int64 tracker_id = stack.back(); |
| + stack.pop_back(); |
| + PushChildTrackersToContainer( |
| + trackers_by_parent_and_title_, tracker_id, std::back_inserter(stack)); |
| + |
| + FileTracker* tracker = tracker_by_id_[tracker_id]; |
| + base::DictionaryValue* file = new DictionaryValue; |
| + base::FilePath path; |
| + BuildPathForTracker(tracker->tracker_id(), &path); |
|
tzik
2013/11/13 06:16:25
This will fail if the tracker is inactive.
Could y
keishi
2013/11/13 07:10:59
I'm guessing we'll want to know where inactive tra
nhiroki
2013/11/13 08:50:04
(Not related to this CL) I think it'd be nice if w
|
| + file->SetString("path", path.AsUTF8Unsafe()); |
| + file->SetString("title", tracker->synced_details().title()); |
|
tzik
2013/11/13 06:16:25
Newly added inactive tracker doesn't have synced_d
keishi
2013/11/13 07:10:59
Done.
|
| + file->SetString("type", FileKindToString( |
| + tracker->synced_details().file_kind())); |
| + |
| + base::DictionaryValue* details = new DictionaryValue; |
| + details->SetString("file_id", tracker->file_id()); |
| + details->SetString("md5", tracker->synced_details().md5()); |
|
tzik
2013/11/13 06:16:25
Could you put this only when synced_details()->fil
keishi
2013/11/13 07:10:59
Done.
|
| + details->SetString("dirty", tracker->dirty() ? "true" : "false"); |
| + |
| + file->Set("details", details); |
| + |
| + files->Append(file); |
| + } |
| + |
| + return files.Pass(); |
| +} |
| + |
| } // namespace drive_backend |
| } // namespace sync_file_system |