| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef SYNC_ENGINE_COMMIT_H_ | |
| 6 #define SYNC_ENGINE_COMMIT_H_ | |
| 7 | |
| 8 #include <stddef.h> | |
| 9 | |
| 10 #include <map> | |
| 11 #include <memory> | |
| 12 #include <string> | |
| 13 | |
| 14 #include "base/macros.h" | |
| 15 #include "sync/base/sync_export.h" | |
| 16 #include "sync/engine/commit_contribution.h" | |
| 17 #include "sync/internal_api/public/base/model_type.h" | |
| 18 #include "sync/internal_api/public/engine/model_safe_worker.h" | |
| 19 #include "sync/internal_api/public/util/syncer_error.h" | |
| 20 #include "sync/protocol/sync.pb.h" | |
| 21 #include "sync/sessions/nudge_tracker.h" | |
| 22 #include "sync/util/extensions_activity.h" | |
| 23 | |
| 24 namespace syncer { | |
| 25 | |
| 26 namespace sessions { | |
| 27 class StatusController; | |
| 28 class SyncSession; | |
| 29 } | |
| 30 | |
| 31 class CommitProcessor; | |
| 32 class Syncer; | |
| 33 | |
| 34 // This class wraps the actions related to building and executing a single | |
| 35 // commit operation. | |
| 36 // | |
| 37 // This class' most important responsibility is to manage the ContributionsMap. | |
| 38 // This class serves as a container for those objects. Although it would have | |
| 39 // been acceptable to let this class be a dumb container object, it turns out | |
| 40 // that there was no other convenient place to put the Init() and | |
| 41 // PostAndProcessCommitResponse() functions. So they ended up here. | |
| 42 class SYNC_EXPORT Commit { | |
| 43 public: | |
| 44 typedef std::map<ModelType, std::unique_ptr<CommitContribution>> | |
| 45 ContributionMap; | |
| 46 | |
| 47 Commit(ContributionMap contributions, | |
| 48 const sync_pb::ClientToServerMessage& message, | |
| 49 ExtensionsActivity::Records extensions_activity_buffer); | |
| 50 | |
| 51 // This destructor will DCHECK if CleanUp() has not been called. | |
| 52 ~Commit(); | |
| 53 | |
| 54 static Commit* Init(ModelTypeSet requested_types, | |
| 55 ModelTypeSet enabled_types, | |
| 56 size_t max_entries, | |
| 57 const std::string& account_name, | |
| 58 const std::string& cache_guid, | |
| 59 bool cookie_jar_mismatch, | |
| 60 bool cookie_jar_empty, | |
| 61 CommitProcessor* commit_processor, | |
| 62 ExtensionsActivity* extensions_activity); | |
| 63 | |
| 64 SyncerError PostAndProcessResponse(sessions::NudgeTracker* nudge_tracker, | |
| 65 sessions::SyncSession* session, | |
| 66 sessions::StatusController* status, | |
| 67 ExtensionsActivity* extensions_activity); | |
| 68 | |
| 69 // Cleans up state associated with this commit. Must be called before the | |
| 70 // destructor. | |
| 71 void CleanUp(); | |
| 72 | |
| 73 private: | |
| 74 ContributionMap contributions_; | |
| 75 | |
| 76 sync_pb::ClientToServerMessage message_; | |
| 77 sync_pb::ClientToServerResponse response_; | |
| 78 ExtensionsActivity::Records extensions_activity_buffer_; | |
| 79 | |
| 80 // Debug only flag used to indicate if it's safe to destruct the object. | |
| 81 bool cleaned_up_; | |
| 82 | |
| 83 DISALLOW_COPY_AND_ASSIGN(Commit); | |
| 84 }; | |
| 85 | |
| 86 } // namespace syncer | |
| 87 | |
| 88 #endif // SYNC_ENGINE_COMMIT_H_ | |
| OLD | NEW |