Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / sync / engine / commit.h
blobee81577944b3ffc5a2a79e8050a84d47f28dc5e7
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/sessions/nudge_tracker.h"
18 #include "sync/util/extensions_activity.h"
20 namespace syncer {
22 namespace sessions {
23 class StatusController;
24 class SyncSession;
27 class CommitProcessor;
28 class Syncer;
30 // This class wraps the actions related to building and executing a single
31 // commit operation.
33 // This class' most important responsibility is to manage the ContributionsMap.
34 // This class serves as a container for those objects. Although it would have
35 // been acceptable to let this class be a dumb container object, it turns out
36 // that there was no other convenient place to put the Init() and
37 // PostAndProcessCommitResponse() functions. So they ended up here.
38 class SYNC_EXPORT_PRIVATE Commit {
39 public:
40 Commit(
41 const std::map<ModelType, CommitContribution*>&
42 contributions,
43 const sync_pb::ClientToServerMessage& message,
44 ExtensionsActivity::Records extensions_activity_buffer);
46 // This destructor will DCHECK if CleanUp() has not been called.
47 ~Commit();
49 static Commit* Init(
50 ModelTypeSet requested_types,
51 ModelTypeSet enabled_types,
52 size_t max_entries,
53 const std::string& account_name,
54 const std::string& cache_guid,
55 CommitProcessor* commit_processor,
56 ExtensionsActivity* extensions_activity);
58 SyncerError PostAndProcessResponse(sessions::NudgeTracker* nudge_tracker,
59 sessions::SyncSession* session,
60 sessions::StatusController* status,
61 ExtensionsActivity* extensions_activity);
63 // Cleans up state associated with this commit. Must be called before the
64 // destructor.
65 void CleanUp();
67 private:
68 typedef std::map<ModelType, CommitContribution*> ContributionMap;
70 ContributionMap contributions_;
71 STLValueDeleter<ContributionMap> deleter_;
73 sync_pb::ClientToServerMessage message_;
74 sync_pb::ClientToServerResponse response_;
75 ExtensionsActivity::Records extensions_activity_buffer_;
77 // Debug only flag used to indicate if it's safe to destruct the object.
78 bool cleaned_up_;
81 } // namespace syncer
83 #endif // SYNC_ENGINE_COMMIT_H_