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

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: Added comment 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 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.
1501 switch (file_kind) {
1502 case FILE_KIND_UNSUPPORTED:
1503 return "unsupported";
1504 case FILE_KIND_FILE:
1505 return "file";
1506 case FILE_KIND_FOLDER:
1507 return "folder";
1508 }
1509
1510 NOTREACHED();
1511 return "unknown";
1512 }
1513
1514 scoped_ptr<base::ListValue> MetadataDatabase::DumpFiles(
1515 const std::string& app_id) {
1516 scoped_ptr<base::ListValue> files(new base::ListValue);
1517
1518 FileTracker app_root_tracker;
1519 if (!FindAppRootTracker(app_id, &app_root_tracker))
1520 return files.Pass();
1521
1522 std::vector<int64> stack;
1523 PushChildTrackersToContainer(
1524 trackers_by_parent_and_title_,
1525 app_root_tracker.tracker_id(),
1526 std::back_inserter(stack));
1527 while (!stack.empty()) {
1528 int64 tracker_id = stack.back();
1529 stack.pop_back();
1530 PushChildTrackersToContainer(
1531 trackers_by_parent_and_title_, tracker_id, std::back_inserter(stack));
1532
1533 FileTracker* tracker = tracker_by_id_[tracker_id];
1534 base::DictionaryValue* file = new DictionaryValue;
1535 base::FilePath path;
1536 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
1537 file->SetString("path", path.AsUTF8Unsafe());
1538 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.
1539 file->SetString("type", FileKindToString(
1540 tracker->synced_details().file_kind()));
1541
1542 base::DictionaryValue* details = new DictionaryValue;
1543 details->SetString("file_id", tracker->file_id());
1544 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.
1545 details->SetString("dirty", tracker->dirty() ? "true" : "false");
1546
1547 file->Set("details", details);
1548
1549 files->Append(file);
1550 }
1551
1552 return files.Pass();
1553 }
1554
1500 } // namespace drive_backend 1555 } // namespace drive_backend
1501 } // namespace sync_file_system 1556 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698