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

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

Issue 93433006: sync: Introduce ModelTypeRegistry and helpers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More review fixes Created 6 years, 11 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 | « no previous file | sync/engine/commit.cc » ('j') | sync/engine/committer_list.h » ('J')
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_COMMIT_H_ 5 #ifndef SYNC_ENGINE_COMMIT_H_
6 #define SYNC_ENGINE_COMMIT_H_ 6 #define SYNC_ENGINE_COMMIT_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "sync/base/sync_export.h" 11 #include "sync/base/sync_export.h"
12 #include "sync/engine/sync_directory_commit_contribution.h" 12 #include "sync/engine/sync_directory_commit_contribution.h"
13 #include "sync/engine/sync_directory_commit_contributor.h"
14 #include "sync/internal_api/public/base/model_type.h" 13 #include "sync/internal_api/public/base/model_type.h"
15 #include "sync/internal_api/public/engine/model_safe_worker.h" 14 #include "sync/internal_api/public/engine/model_safe_worker.h"
16 #include "sync/internal_api/public/util/syncer_error.h" 15 #include "sync/internal_api/public/util/syncer_error.h"
17 #include "sync/protocol/sync.pb.h" 16 #include "sync/protocol/sync.pb.h"
18 #include "sync/util/extensions_activity.h" 17 #include "sync/util/extensions_activity.h"
19 18
20 namespace syncer { 19 namespace syncer {
21 20
22 namespace sessions { 21 namespace sessions {
23 class StatusController; 22 class StatusController;
24 class SyncSession; 23 class SyncSession;
25 } 24 }
26 25
26 class CommitterList;
27 class Syncer; 27 class Syncer;
28 28
29 // This class wraps the actions related to building and executing a single 29 // This class wraps the actions related to building and executing a single
30 // commit operation. 30 // commit operation.
31 // 31 //
32 // This class' most important responsibility is to manage the ContributionsMap. 32 // This class' most important responsibility is to manage the ContributionsMap.
33 // This class serves as a container for those objects. Although it would have 33 // This class serves as a container for those objects. Although it would have
34 // been acceptable to let this class be a dumb container object, it turns out 34 // been acceptable to let this class be a dumb container object, it turns out
35 // that there was no other convenient place to put the Init() and 35 // that there was no other convenient place to put the Init() and
36 // PostAndProcessCommitResponse() functions. So they ended up here. 36 // PostAndProcessCommitResponse() functions. So they ended up here.
37 class SYNC_EXPORT_PRIVATE Commit { 37 class SYNC_EXPORT_PRIVATE Commit {
38 public: 38 public:
39 Commit( 39 Commit(
40 const std::map<ModelType, SyncDirectoryCommitContribution*>& 40 const std::map<ModelType, SyncDirectoryCommitContribution*>&
41 contributions, 41 contributions,
42 const sync_pb::ClientToServerMessage& message, 42 const sync_pb::ClientToServerMessage& message,
43 ExtensionsActivity::Records extensions_activity_buffer); 43 ExtensionsActivity::Records extensions_activity_buffer);
44 44
45 // This destructor will DCHECK if CleanUp() has not been called. 45 // This destructor will DCHECK if CleanUp() has not been called.
46 ~Commit(); 46 ~Commit();
47 47
48 static Commit* Init( 48 static Commit* Init(
49 ModelTypeSet requested_types, 49 ModelTypeSet requested_types,
50 ModelTypeSet enabled_types,
50 size_t max_entries, 51 size_t max_entries,
51 const std::string& account_name, 52 const std::string& account_name,
52 const std::string& cache_guid, 53 const std::string& cache_guid,
53 CommitContributorMap* contributor_map, 54 CommitterList* committer_list,
54 ExtensionsActivity* extensions_activity); 55 ExtensionsActivity* extensions_activity);
55 56
56 SyncerError PostAndProcessResponse( 57 SyncerError PostAndProcessResponse(
57 sessions::SyncSession* session, 58 sessions::SyncSession* session,
58 sessions::StatusController* status, 59 sessions::StatusController* status,
59 ExtensionsActivity* extensions_activity); 60 ExtensionsActivity* extensions_activity);
60 61
61 // Cleans up state associated with this commit. Must be called before the 62 // Cleans up state associated with this commit. Must be called before the
62 // destructor. 63 // destructor.
63 void CleanUp(); 64 void CleanUp();
64 65
65 private: 66 private:
66 typedef std::map<ModelType, SyncDirectoryCommitContribution*> ContributionMap; 67 typedef std::map<ModelType, SyncDirectoryCommitContribution*> ContributionMap;
67 68
68 ContributionMap contributions_; 69 ContributionMap contributions_;
69 STLValueDeleter<ContributionMap> deleter_; 70 STLValueDeleter<ContributionMap> deleter_;
70 71
71 sync_pb::ClientToServerMessage message_; 72 sync_pb::ClientToServerMessage message_;
72 sync_pb::ClientToServerResponse response_; 73 sync_pb::ClientToServerResponse response_;
73 ExtensionsActivity::Records extensions_activity_buffer_; 74 ExtensionsActivity::Records extensions_activity_buffer_;
74 75
75 // Debug only flag used to indicate if it's safe to destruct the object. 76 // Debug only flag used to indicate if it's safe to destruct the object.
76 bool cleaned_up_; 77 bool cleaned_up_;
77 }; 78 };
78 79
79 } // namespace syncer 80 } // namespace syncer
80 81
81 #endif // SYNC_ENGINE_COMMIT_H_ 82 #endif // SYNC_ENGINE_COMMIT_H_
OLDNEW
« no previous file with comments | « no previous file | sync/engine/commit.cc » ('j') | sync/engine/committer_list.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698