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

Side by Side Diff: sync/engine/get_commit_ids.cc

Issue 25638003: sync: Implement per-type commit interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Small fixes from first review Created 7 years, 2 months 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 "sync/engine/get_commit_ids.h" 5 #include "sync/engine/get_commit_ids.h"
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // 43 //
44 // See the header file for an explanation of commit ordering. 44 // See the header file for an explanation of commit ordering.
45 void OrderCommitIds( 45 void OrderCommitIds(
46 syncable::BaseTransaction* trans, 46 syncable::BaseTransaction* trans,
47 size_t max_entries, 47 size_t max_entries,
48 const std::set<int64>& ready_unsynced_set, 48 const std::set<int64>& ready_unsynced_set,
49 std::vector<int64>* out); 49 std::vector<int64>* out);
50 50
51 } // namespace 51 } // namespace
52 52
53 void GetCommitIdsForType( 53 void GetCommitIdsForType(
Nicolas Zea 2013/10/09 00:17:39 why not just have this at the bottom of the file n
rlarocque 2013/10/09 20:00:19 This is also intended to avoid unnecessary diffs.
54 syncable::BaseTransaction* trans, 54 syncable::BaseTransaction* trans,
55 ModelType type, 55 ModelType type,
56 size_t max_entries, 56 size_t max_entries,
57 syncable::Directory::Metahandles* out) { 57 syncable::Directory::Metahandles* out) {
58 syncable::Directory* dir = trans->directory(); 58 syncable::Directory* dir = trans->directory();
59 59
60 // Gather the full set of unsynced items and store it in the session. They 60 // Gather the full set of unsynced items and store it in the session. They
61 // are not in the correct order for commit. 61 // are not in the correct order for commit.
62 std::set<int64> ready_unsynced_set; 62 std::set<int64> ready_unsynced_set;
63 syncable::Directory::Metahandles all_unsynced_handles; 63 syncable::Directory::Metahandles all_unsynced_handles;
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 499
500 // Add moves and creates, and prepend their uncommitted parents. 500 // Add moves and creates, and prepend their uncommitted parents.
501 traversal.AddCreatesAndMoves(ready_unsynced_set); 501 traversal.AddCreatesAndMoves(ready_unsynced_set);
502 502
503 // Add all deletes. 503 // Add all deletes.
504 traversal.AddDeletes(ready_unsynced_set); 504 traversal.AddDeletes(ready_unsynced_set);
505 } 505 }
506 506
507 } // namespace 507 } // namespace
508 508
509 void GetCommitIds(
510 syncable::BaseTransaction* trans,
511 ModelTypeSet requested_types,
512 size_t commit_batch_size,
513 sessions::OrderedCommitSet* ordered_commit_set) {
514 for (ModelTypeSet::Iterator it = requested_types.First();
515 it.Good(); it.Inc()) {
516 DCHECK_LE(ordered_commit_set->Size(), commit_batch_size);
517 if (ordered_commit_set->Size() >= commit_batch_size)
518 break;
519 size_t space_remaining = commit_batch_size - ordered_commit_set->Size();
520 syncable::Directory::Metahandles out;
521 GetCommitIdsForType(
522 trans,
523 it.Get(),
524 space_remaining,
525 &out);
526 ordered_commit_set->AddCommitItems(out, it.Get());
527 }
528 }
529
530 } // namespace syncer 509 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698