Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/metadata_database.cc

Issue 71183002: Implement SyncEngine::DumpFiles() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Check has_synced_details Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 base::FilePath path;
1522 if (tracker->active()) {
1523 BuildPathForTracker(tracker->tracker_id(), &path);
1524 } else {
1525 BuildPathForTracker(tracker->parent_tracker_id(), &path);
1526 if (tracker->has_synced_details())
1527 path = path.Append(tracker->synced_details().title());
1528 else
1529 path = path.Append("unknown");
1530 }
1531 file->SetString("path", path.AsUTF8Unsafe());
1532 file->SetString("title",
1533 tracker->has_synced_details() ? tracker->synced_details().title() : "");
1534 file->SetString("type", FileKindToString(
1535 tracker->synced_details().file_kind()));
tzik 2013/11/13 07:27:44 Accessing synced_details() has a side effect if ha
keishi 2013/11/13 07:47:03 Done.
1536
1537 base::DictionaryValue* details = new DictionaryValue;
1538 details->SetString("file_id", tracker->file_id());
1539 details->SetString("md5",
1540 tracker->has_synced_details() &&
1541 tracker->synced_details().file_kind() == FILE_KIND_FILE ?
1542 tracker->synced_details().md5() : "");
tzik 2013/11/13 07:27:44 Hmm, this is a bit hard to read. Could you use <c
keishi 2013/11/13 07:47:03 Done.
1543 details->SetString("active", tracker->active() ? "true" : "false");
1544 details->SetString("dirty", tracker->dirty() ? "true" : "false");
1545
1546 file->Set("details", details);
1547
1548 files->Append(file);
1549 }
1550
1551 return files.Pass();
1552 }
1553
1500 } // namespace drive_backend 1554 } // namespace drive_backend
1501 } // namespace sync_file_system 1555 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698