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

Side by Side Diff: sync/engine/get_commit_ids_command.h

Issue 10210009: sync: Loop committing items without downloading updates (v2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, remove class, modify loop exit Created 8 years, 7 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef SYNC_ENGINE_GET_COMMIT_IDS_COMMAND_H_ 5 #ifndef SYNC_ENGINE_GET_COMMIT_IDS_COMMAND_H_
6 #define SYNC_ENGINE_GET_COMMIT_IDS_COMMAND_H_ 6 #define SYNC_ENGINE_GET_COMMIT_IDS_COMMAND_H_
7 #pragma once 7 #pragma once
8 8
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "sync/engine/syncer_command.h" 13 #include "sync/engine/syncer_command.h"
14 #include "sync/engine/syncer_util.h" 14 #include "sync/engine/syncer_util.h"
15 #include "sync/sessions/ordered_commit_set.h" 15 #include "sync/sessions/ordered_commit_set.h"
16 #include "sync/sessions/sync_session.h" 16 #include "sync/sessions/sync_session.h"
17 17
18 using std::pair; 18 using std::pair;
19 using std::vector; 19 using std::vector;
20 20
21 namespace browser_sync { 21 namespace browser_sync {
22 22
23 class GetCommitIdsCommand : public SyncerCommand { 23 class GetCommitIdsCommand : public SyncerCommand {
24 friend class SyncerTest; 24 friend class SyncerTest;
25 25
26 public: 26 public:
27 explicit GetCommitIdsCommand(int commit_batch_size); 27 GetCommitIdsCommand(size_t commit_batch_size,
28 sessions::OrderedCommitSet* ordered_commit_set,
29 size_t* unsynced_item_count);
tim (not reviewing) 2012/05/11 18:42:16 Comments would be nice here.
rlarocque 2012/05/14 23:10:43 Done.
28 virtual ~GetCommitIdsCommand(); 30 virtual ~GetCommitIdsCommand();
29 31
30 // SyncerCommand implementation. 32 // SyncerCommand implementation.
31 virtual SyncerError ExecuteImpl(sessions::SyncSession* session) OVERRIDE; 33 virtual SyncerError ExecuteImpl(sessions::SyncSession* session) OVERRIDE;
32 34
33 // Builds a vector of IDs that should be committed. 35 // Builds a vector of IDs that should be committed.
34 void BuildCommitIds(syncable::WriteTransaction* write_transaction, 36 void BuildCommitIds(syncable::WriteTransaction* write_transaction,
35 const ModelSafeRoutingInfo& routes, 37 const ModelSafeRoutingInfo& routes,
36 const std::set<int64>& ready_unsynced_set); 38 const std::set<int64>& ready_unsynced_set);
37 39
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // Return values: 88 // Return values:
87 // False: if there was an entry in conflict. 89 // False: if there was an entry in conflict.
88 // True: if all entries were checked for commit readiness and added to 90 // True: if all entries were checked for commit readiness and added to
89 // |result| as necessary. 91 // |result| as necessary.
90 bool AddItemThenPredecessors(syncable::BaseTransaction* trans, 92 bool AddItemThenPredecessors(syncable::BaseTransaction* trans,
91 const std::set<int64>& ready_unsynced_set, 93 const std::set<int64>& ready_unsynced_set,
92 const syncable::Entry& item, 94 const syncable::Entry& item,
93 sessions::OrderedCommitSet* result) const; 95 sessions::OrderedCommitSet* result) const;
94 96
95 // Appends all commit ready predecessors of |item|, followed by |item| itself, 97 // Appends all commit ready predecessors of |item|, followed by |item| itself,
96 // to |ordered_commit_set_|, iff item and all its predecessors not in 98 // to |commit_set|, iff item and all its predecessors not in conflict.
97 // conflict.
98 // Return values: 99 // Return values:
99 // False: if there was an entry in conflict. 100 // False: if there was an entry in conflict.
100 // True: if all entries were checked for commit readiness and added to 101 // True: if all entries were checked for commit readiness and added to
101 // |result| as necessary. 102 // |result| as necessary.
102 bool AddPredecessorsThenItem(syncable::BaseTransaction* trans, 103 bool AddPredecessorsThenItem(syncable::BaseTransaction* trans,
103 const ModelSafeRoutingInfo& routes, 104 const ModelSafeRoutingInfo& routes,
104 const std::set<int64>& ready_unsynced_set, 105 const std::set<int64>& ready_unsynced_set,
105 const syncable::Entry& item, 106 const syncable::Entry& item,
106 sessions::OrderedCommitSet* result) const; 107 sessions::OrderedCommitSet* commit_set) const;
107 108
108 bool IsCommitBatchFull() const; 109 bool IsCommitBatchFull() const;
109 110
110 void AddCreatesAndMoves(syncable::WriteTransaction* write_transaction, 111 void AddCreatesAndMoves(syncable::WriteTransaction* write_transaction,
111 const ModelSafeRoutingInfo& routes, 112 const ModelSafeRoutingInfo& routes,
112 const std::set<int64>& ready_unsynced_set); 113 const std::set<int64>& ready_unsynced_set);
113 114
114 void AddDeletes(syncable::WriteTransaction* write_transaction, 115 void AddDeletes(syncable::WriteTransaction* write_transaction,
115 const std::set<int64>& ready_unsynced_set); 116 const std::set<int64>& ready_unsynced_set);
116 117
117 scoped_ptr<sessions::OrderedCommitSet> ordered_commit_set_; 118 size_t requested_commit_batch_size_;
tim (not reviewing) 2012/05/11 18:42:16 const?
rlarocque 2012/05/14 23:10:43 Done.
118 119 sessions::OrderedCommitSet* commit_set_;
tim (not reviewing) 2012/05/11 18:42:16 Comments about ownership / lifetime wouldn't hurt.
rlarocque 2012/05/14 23:10:43 Done.
119 int requested_commit_batch_size_; 120 size_t* unsynced_item_count_;
120 121
121 DISALLOW_COPY_AND_ASSIGN(GetCommitIdsCommand); 122 DISALLOW_COPY_AND_ASSIGN(GetCommitIdsCommand);
122 }; 123 };
123 124
124 } // namespace browser_sync 125 } // namespace browser_sync
125 126
126 #endif // SYNC_ENGINE_GET_COMMIT_IDS_COMMAND_H_ 127 #endif // SYNC_ENGINE_GET_COMMIT_IDS_COMMAND_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698