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 1479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1490 base::PostTaskAndReplyWithResult( | 1490 base::PostTaskAndReplyWithResult( |
1491 task_runner_.get(), | 1491 task_runner_.get(), |
1492 FROM_HERE, | 1492 FROM_HERE, |
1493 base::Bind(&leveldb::DB::Write, | 1493 base::Bind(&leveldb::DB::Write, |
1494 base::Unretained(db_.get()), | 1494 base::Unretained(db_.get()), |
1495 leveldb::WriteOptions(), | 1495 leveldb::WriteOptions(), |
1496 base::Owned(batch.release())), | 1496 base::Owned(batch.release())), |
1497 base::Bind(&AdaptLevelDBStatusToSyncStatusCode, callback)); | 1497 base::Bind(&AdaptLevelDBStatusToSyncStatusCode, callback)); |
1498 } | 1498 } |
1499 | 1499 |
| 1500 scoped_ptr<base::ListValue> MetadataDatabase::DumpFiles( |
| 1501 const std::string& app_id) { |
| 1502 scoped_ptr<base::ListValue> files(new base::ListValue); |
| 1503 |
| 1504 FileTracker app_root_tracker; |
| 1505 if (!FindAppRootTracker(app_id, &app_root_tracker)) |
| 1506 return files.Pass(); |
| 1507 |
| 1508 std::vector<int64> stack; |
| 1509 PushChildTrackersToContainer( |
| 1510 trackers_by_parent_and_title_, |
| 1511 app_root_tracker.tracker_id(), |
| 1512 std::back_inserter(stack)); |
| 1513 while (!stack.empty()) { |
| 1514 int64 tracker_id = stack.back(); |
| 1515 stack.pop_back(); |
| 1516 PushChildTrackersToContainer( |
| 1517 trackers_by_parent_and_title_, tracker_id, std::back_inserter(stack)); |
| 1518 |
| 1519 FileTracker* tracker = tracker_by_id_[tracker_id]; |
| 1520 base::DictionaryValue* file = new DictionaryValue; |
| 1521 |
| 1522 base::FilePath path; |
| 1523 if (tracker->active()) { |
| 1524 BuildPathForTracker(tracker->tracker_id(), &path); |
| 1525 } else { |
| 1526 BuildPathForTracker(tracker->parent_tracker_id(), &path); |
| 1527 if (tracker->has_synced_details()) { |
| 1528 path = path.Append( |
| 1529 base::FilePath::FromUTF8Unsafe(tracker->synced_details().title())); |
| 1530 } else { |
| 1531 path = path.Append(FILE_PATH_LITERAL("unknown")); |
| 1532 } |
| 1533 } |
| 1534 file->SetString("path", path.AsUTF8Unsafe()); |
| 1535 if (tracker->has_synced_details()) { |
| 1536 file->SetString("title", tracker->synced_details().title()); |
| 1537 file->SetString("type", |
| 1538 FileKindToString(tracker->synced_details().file_kind())); |
| 1539 } |
| 1540 |
| 1541 base::DictionaryValue* details = new DictionaryValue; |
| 1542 details->SetString("file_id", tracker->file_id()); |
| 1543 if (tracker->has_synced_details() && |
| 1544 tracker->synced_details().file_kind() == FILE_KIND_FILE) |
| 1545 details->SetString("md5",tracker->synced_details().md5()); |
| 1546 details->SetString("active", tracker->active() ? "true" : "false"); |
| 1547 details->SetString("dirty", tracker->dirty() ? "true" : "false"); |
| 1548 |
| 1549 file->Set("details", details); |
| 1550 |
| 1551 files->Append(file); |
| 1552 } |
| 1553 |
| 1554 return files.Pass(); |
| 1555 } |
| 1556 |
1500 } // namespace drive_backend | 1557 } // namespace drive_backend |
1501 } // namespace sync_file_system | 1558 } // namespace sync_file_system |
OLD | NEW |