diff options
author | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-17 23:21:59 +0000 |
---|---|---|
committer | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-17 23:21:59 +0000 |
commit | 2fdf6199cda564079bf743bf98e6c7b8205fc9c4 (patch) | |
tree | 26cb5feaaf3800771b98355450d0a1e37bb0753c /sync/engine/commit_processor.h | |
parent | 0e416c45ad5b75728e696b73651f444135c9748f (diff) | |
download | chromium_src-2fdf6199cda564079bf743bf98e6c7b8205fc9c4.zip chromium_src-2fdf6199cda564079bf743bf98e6c7b8205fc9c4.tar.gz chromium_src-2fdf6199cda564079bf743bf98e6c7b8205fc9c4.tar.bz2 |
sync: Introduce ModelTypeRegistry and helpers
Introduce the ModelTypeRegistry class and use it to manage the creation
of UpdateHandlers and CommitContributors. The ModelTypeRegistry also
gets some help from the newly introduced UpdaterList and CommitterList
classes.
This lets us move the verbose iteration logic out of the code that's
focused on building and executing commits and updates, which should make
those functions easier to read. It gives us more freedom to experiment
with other ways to manage the lists of commit contributors and update
handlers, should we choose to do so. It prevents us from leaking the
set of enabled types through the per-type maps.
This patch is one of the last in the stack related to building a
per-type abstraction into the sync engine, and also one of the first
steps towards implementing run-time enable and disable logic for the
new-style sync types.
BUG=278484
Review URL: https://codereview.chromium.org/93433006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245654 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/engine/commit_processor.h')
-rw-r--r-- | sync/engine/commit_processor.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/sync/engine/commit_processor.h b/sync/engine/commit_processor.h new file mode 100644 index 0000000..9ab0957 --- /dev/null +++ b/sync/engine/commit_processor.h @@ -0,0 +1,54 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef SYNC_ENGINE_COMMIT_PROCESSOR_H_ +#define SYNC_ENGINE_COMMIT_PROCESSOR_H_ + +#include <map> +#include <vector> + +#include "base/basictypes.h" +#include "sync/base/sync_export.h" +#include "sync/internal_api/public/base/model_type.h" +#include "sync/internal_api/public/engine/model_safe_worker.h" +#include "sync/sessions/model_type_registry.h" + +namespace syncer { + +namespace syncable { +class Directory; +} // namespace syncable + +class SyncDirectoryCommitContributor; +class SyncDirectoryCommitContribution; + +// This class manages the set of per-type committer objects. +// +// It owns these types and hides the details of iterating over all of them. +// Many methods allow the caller to specify a subset of types on which the +// operation is to be applied. It is a logic error if the supplied set of types +// contains a type which was not previously registered. +class SYNC_EXPORT_PRIVATE CommitProcessor { + public: + typedef std::map<ModelType, SyncDirectoryCommitContribution*> ContributionMap; + + explicit CommitProcessor(CommitContributorMap* commit_contributor_map); + ~CommitProcessor(); + + // Gathers a set of contributions to be used to populate a commit message. + void GatherCommitContributions( + ModelTypeSet commit_types, + size_t max_entries, + ContributionMap* contributions); + + private: + // A map of 'commit contributors', one for each enabled type. + CommitContributorMap* commit_contributor_map_; + + DISALLOW_COPY_AND_ASSIGN(CommitProcessor); +}; + +} // namespace syncer + +#endif // SYNC_ENGINE_COMMIT_PROCESSOR_H_ |