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

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 Created 8 years, 6 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
« no previous file with comments | « sync/engine/commit.cc ('k') | sync/engine/get_commit_ids_command.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // A class that contains the code used to search the syncable::Directory for
24 // locally modified items that are ready to be committed to the server.
25 //
26 // See SyncerCommand documentation for more info.
23 class GetCommitIdsCommand : public SyncerCommand { 27 class GetCommitIdsCommand : public SyncerCommand {
24 friend class SyncerTest; 28 friend class SyncerTest;
25 29
26 public: 30 public:
27 explicit GetCommitIdsCommand(int commit_batch_size); 31 // The batch_size parameter is the maximum number of entries we are allowed
32 // to commit in a single batch. This value can be modified by the server.
33 //
34 // The ordered_commit_set parameter is an output parameter that will contain a
35 // set of items that are ready to commit. Its size shall not exceed the
36 // provided batch_size. This contents of this "set" will be ordered; see the
37 // comments in this class' implementation for details.
38 GetCommitIdsCommand(const size_t commit_batch_size,
39 sessions::OrderedCommitSet* ordered_commit_set);
28 virtual ~GetCommitIdsCommand(); 40 virtual ~GetCommitIdsCommand();
29 41
30 // SyncerCommand implementation. 42 // SyncerCommand implementation.
31 virtual SyncerError ExecuteImpl(sessions::SyncSession* session) OVERRIDE; 43 virtual SyncerError ExecuteImpl(sessions::SyncSession* session) OVERRIDE;
32 44
33 // Builds a vector of IDs that should be committed. 45 // Builds a vector of IDs that should be committed.
34 void BuildCommitIds(syncable::WriteTransaction* write_transaction, 46 void BuildCommitIds(syncable::WriteTransaction* write_transaction,
35 const ModelSafeRoutingInfo& routes, 47 const ModelSafeRoutingInfo& routes,
36 const std::set<int64>& ready_unsynced_set); 48 const std::set<int64>& ready_unsynced_set);
37 49
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // Return values: 98 // Return values:
87 // False: if there was an entry in conflict. 99 // False: if there was an entry in conflict.
88 // True: if all entries were checked for commit readiness and added to 100 // True: if all entries were checked for commit readiness and added to
89 // |result| as necessary. 101 // |result| as necessary.
90 bool AddItemThenPredecessors(syncable::BaseTransaction* trans, 102 bool AddItemThenPredecessors(syncable::BaseTransaction* trans,
91 const std::set<int64>& ready_unsynced_set, 103 const std::set<int64>& ready_unsynced_set,
92 const syncable::Entry& item, 104 const syncable::Entry& item,
93 sessions::OrderedCommitSet* result) const; 105 sessions::OrderedCommitSet* result) const;
94 106
95 // Appends all commit ready predecessors of |item|, followed by |item| itself, 107 // Appends all commit ready predecessors of |item|, followed by |item| itself,
96 // to |ordered_commit_set_|, iff item and all its predecessors not in 108 // to |commit_set|, iff item and all its predecessors not in conflict.
97 // conflict.
98 // Return values: 109 // Return values:
99 // False: if there was an entry in conflict. 110 // False: if there was an entry in conflict.
100 // True: if all entries were checked for commit readiness and added to 111 // True: if all entries were checked for commit readiness and added to
101 // |result| as necessary. 112 // |result| as necessary.
102 bool AddPredecessorsThenItem(syncable::BaseTransaction* trans, 113 bool AddPredecessorsThenItem(syncable::BaseTransaction* trans,
103 const ModelSafeRoutingInfo& routes, 114 const ModelSafeRoutingInfo& routes,
104 const std::set<int64>& ready_unsynced_set, 115 const std::set<int64>& ready_unsynced_set,
105 const syncable::Entry& item, 116 const syncable::Entry& item,
106 sessions::OrderedCommitSet* result) const; 117 sessions::OrderedCommitSet* commit_set) const;
107 118
108 bool IsCommitBatchFull() const; 119 bool IsCommitBatchFull() const;
109 120
110 void AddCreatesAndMoves(syncable::WriteTransaction* write_transaction, 121 void AddCreatesAndMoves(syncable::WriteTransaction* write_transaction,
111 const ModelSafeRoutingInfo& routes, 122 const ModelSafeRoutingInfo& routes,
112 const std::set<int64>& ready_unsynced_set); 123 const std::set<int64>& ready_unsynced_set);
113 124
114 void AddDeletes(syncable::WriteTransaction* write_transaction, 125 void AddDeletes(syncable::WriteTransaction* write_transaction,
115 const std::set<int64>& ready_unsynced_set); 126 const std::set<int64>& ready_unsynced_set);
116 127
117 scoped_ptr<sessions::OrderedCommitSet> ordered_commit_set_; 128 // Input parameter; see constructor comment.
129 const size_t requested_commit_batch_size_;
118 130
119 int requested_commit_batch_size_; 131 // Output parameter; see constructor comment.
132 sessions::OrderedCommitSet* commit_set_;
120 133
121 DISALLOW_COPY_AND_ASSIGN(GetCommitIdsCommand); 134 DISALLOW_COPY_AND_ASSIGN(GetCommitIdsCommand);
122 }; 135 };
123 136
124 } // namespace browser_sync 137 } // namespace browser_sync
125 138
126 #endif // SYNC_ENGINE_GET_COMMIT_IDS_COMMAND_H_ 139 #endif // SYNC_ENGINE_GET_COMMIT_IDS_COMMAND_H_
OLDNEW
« no previous file with comments | « sync/engine/commit.cc ('k') | sync/engine/get_commit_ids_command.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698