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

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

Issue 25638003: sync: Implement per-type commit interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile warning 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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_BUILD_COMMIT_COMMAND_H_ 5 #ifndef SYNC_ENGINE_BUILD_COMMIT_COMMAND_H_
6 #define SYNC_ENGINE_BUILD_COMMIT_COMMAND_H_ 6 #define SYNC_ENGINE_BUILD_COMMIT_COMMAND_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
11 #include "sync/base/sync_export.h" 11 #include "sync/base/sync_export.h"
12 #include "sync/engine/syncer_command.h" 12 #include "sync/engine/syncer_command.h"
13 #include "sync/internal_api/public/engine/model_safe_worker.h"
13 #include "sync/syncable/entry_kernel.h" 14 #include "sync/syncable/entry_kernel.h"
14 #include "sync/util/extensions_activity.h" 15 #include "sync/util/extensions_activity.h"
15 16
16 namespace syncer { 17 namespace syncer {
17 18
18 namespace sessions {
19 class OrderedCommitSet;
20 }
21
22 namespace syncable { 19 namespace syncable {
23 class Entry; 20 class Entry;
24 class BaseTransaction; 21 class BaseTransaction;
25 } 22 }
26 23
27 // A class that contains the code used to serialize a set of sync items into a 24 // A class that contains the code used to serialize a set of sync items into a
28 // protobuf commit message. This conversion process references the 25 // protobuf commit message. This conversion process references the
29 // syncable::Directory, which is why it must be called within the same 26 // syncable::Directory, which is why it must be called within the same
30 // transaction as the GetCommitIdsCommand that fetched the set of items to be 27 // transaction as the GetCommitIdsCommand that fetched the set of items to be
31 // committed. 28 // committed.
32 // 29 //
33 // See SyncerCommand documentation for more info. 30 // See SyncerCommand documentation for more info.
34 class SYNC_EXPORT_PRIVATE BuildCommitCommand : public SyncerCommand { 31 class SYNC_EXPORT_PRIVATE BuildCommitCommand : public SyncerCommand {
35 public: 32 public:
36 // The batch_commit_set parameter contains a set of references to the items
37 // that should be committed.
38 //
39 // The commit_message parameter is an output parameter which will contain the
40 // fully initialized commit message once ExecuteImpl() has been called.
41 BuildCommitCommand(
42 syncable::BaseTransaction* trans,
43 const sessions::OrderedCommitSet& batch_commit_set,
44 sync_pb::ClientToServerMessage* commit_message,
45 ExtensionsActivity::Records* extensions_activity_buffer);
46 virtual ~BuildCommitCommand();
47
48 // SyncerCommand implementation.
49 virtual SyncerError ExecuteImpl(sessions::SyncSession* session) OVERRIDE;
50
51 // Helper function that takes a snapshot of |meta_entry| and puts it into a 33 // Helper function that takes a snapshot of |meta_entry| and puts it into a
52 // protobuf suitable for use in a commit request message. 34 // protobuf suitable for use in a commit request message.
53 static void BuildCommitItem(const syncable::Entry& meta_entry, 35 static void BuildCommitItem(const syncable::Entry& meta_entry,
54 sync_pb::SyncEntity* sync_entry); 36 sync_pb::SyncEntity* sync_entry);
55 37
56 private: 38 // Adds bookmark extensions activity report to |message|.
57 FRIEND_TEST_ALL_PREFIXES(BuildCommitCommandTest, InterpolatePosition); 39 static void AddExtensionsActivityToMessage(
58 40 ExtensionsActivity* activity,
59 void AddExtensionsActivityToMessage(sessions::SyncSession* session, 41 ExtensionsActivity::Records* extensions_activity_buffer,
60 sync_pb::CommitMessage* message); 42 sync_pb::CommitMessage* message);
61 43
62 // Fills the config_params field of |message|. 44 // Fills the config_params field of |message|.
63 void AddClientConfigParamsToMessage(sessions::SyncSession* session, 45 static void AddClientConfigParamsToMessage(
64 sync_pb::CommitMessage* message); 46 ModelTypeSet enabled_types,
47 sync_pb::CommitMessage* message);
65 48
66 DISALLOW_COPY_AND_ASSIGN(BuildCommitCommand); 49 private:
67 50 DISALLOW_IMPLICIT_CONSTRUCTORS(BuildCommitCommand);
68 // A pointer to a valid transaction not owned by this class.
69 syncable::BaseTransaction* trans_;
70
71 // Input parameter; see constructor comment.
72 const sessions::OrderedCommitSet& batch_commit_set_;
73
74 // Output parameter; see constructor comment.
75 sync_pb::ClientToServerMessage* commit_message_;
76
77 ExtensionsActivity::Records* extensions_activity_buffer_;
78 }; 51 };
79 52
80 } // namespace syncer 53 } // namespace syncer
81 54
82 #endif // SYNC_ENGINE_BUILD_COMMIT_COMMAND_H_ 55 #endif // SYNC_ENGINE_BUILD_COMMIT_COMMAND_H_
OLDNEW
« no previous file with comments | « no previous file | sync/engine/build_commit_command.cc » ('j') | sync/engine/sync_directory_commit_contribution.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698