Convert DLOG/DVLOG messages in chrome.dial to VLOG.
[chromium-blink-merge.git] / sync / engine / commit.h
blob993bd87203bac7dfeecf1db24a0dbc0b631f46fc
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
3 // found in the LICENSE file.
5 #ifndef SYNC_ENGINE_COMMIT_H_
6 #define SYNC_ENGINE_COMMIT_H_
8 #include <map>
10 #include "base/stl_util.h"
11 #include "sync/base/sync_export.h"
12 #include "sync/engine/commit_contribution.h"
13 #include "sync/internal_api/public/base/model_type.h"
14 #include "sync/internal_api/public/engine/model_safe_worker.h"
15 #include "sync/internal_api/public/util/syncer_error.h"
16 #include "sync/protocol/sync.pb.h"
17 #include "sync/util/extensions_activity.h"
19 namespace syncer {
21 namespace sessions {
22 class StatusController;
23 class SyncSession;
26 class CommitProcessor;
27 class Syncer;
29 // This class wraps the actions related to building and executing a single
30 // commit operation.
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
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
36 // PostAndProcessCommitResponse() functions. So they ended up here.
37 class SYNC_EXPORT_PRIVATE Commit {
38 public:
39 Commit(
40 const std::map<ModelType, CommitContribution*>&
41 contributions,
42 const sync_pb::ClientToServerMessage& message,
43 ExtensionsActivity::Records extensions_activity_buffer);
45 // This destructor will DCHECK if CleanUp() has not been called.
46 ~Commit();
48 static Commit* Init(
49 ModelTypeSet requested_types,
50 ModelTypeSet enabled_types,
51 size_t max_entries,
52 const std::string& account_name,
53 const std::string& cache_guid,
54 CommitProcessor* commit_processor,
55 ExtensionsActivity* extensions_activity);
57 SyncerError PostAndProcessResponse(
58 sessions::SyncSession* session,
59 sessions::StatusController* status,
60 ExtensionsActivity* extensions_activity);
62 // Cleans up state associated with this commit. Must be called before the
63 // destructor.
64 void CleanUp();
66 private:
67 typedef std::map<ModelType, CommitContribution*> ContributionMap;
69 ContributionMap contributions_;
70 STLValueDeleter<ContributionMap> deleter_;
72 sync_pb::ClientToServerMessage message_;
73 sync_pb::ClientToServerResponse response_;
74 ExtensionsActivity::Records extensions_activity_buffer_;
76 // Debug only flag used to indicate if it's safe to destruct the object.
77 bool cleaned_up_;
80 } // namespace syncer
82 #endif // SYNC_ENGINE_COMMIT_H_