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

Unified Diff: sync/sessions/model_type_registry.h

Issue 93433006: sync: Introduce ModelTypeRegistry and helpers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Renames and moves 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 side-by-side diff with in-line comments
Download patch
Index: sync/sessions/model_type_registry.h
diff --git a/sync/sessions/model_type_registry.h b/sync/sessions/model_type_registry.h
new file mode 100644
index 0000000000000000000000000000000000000000..46a53c0bfa2b3f6278aac89c4f9716fe0e12c19e
--- /dev/null
+++ b/sync/sessions/model_type_registry.h
@@ -0,0 +1,68 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
tim (not reviewing) 2014/01/16 18:28:22 nit, remove the (c)
rlarocque 2014/01/16 20:28:42 Done.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYNC_ENGINE_MODEL_TYPE_REGISTRY_H_
+#define SYNC_ENGINE_MODEL_TYPE_REGISTRY_H_
+
+#include <map>
+
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/stl_util.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"
+
+namespace syncer {
+
+namespace syncable {
+class Directory;
+} // namespace syncable
+
+class SyncDirectoryUpdateHandler;
+class SyncDirectoryCommitContributor;
+
+typedef std::map<ModelType, SyncDirectoryUpdateHandler*> UpdateHandlerMap;
+typedef std::map<ModelType, SyncDirectoryCommitContributor*>
+ CommitContributorMap;
+
+// Keeps track of the sets of active update handlers and commit contributors.
+class SYNC_EXPORT_PRIVATE ModelTypeRegistry {
+ public:
+ ModelTypeRegistry(
+ const std::vector<ModelSafeWorker*>& workers,
+ syncable::Directory* directory);
+ ~ModelTypeRegistry();
+
+ // Sets the set of enabled types.
+ void SetEnabledDirectoryTypes(const ModelSafeRoutingInfo& routing_info);
+
+ // Simple getters.
+ UpdateHandlerMap* update_handler_map();
+ CommitContributorMap* commit_contributor_map();
+
+ private:
+ // Classes to manage the types hooked up to receive and commit sync data.
+ UpdateHandlerMap update_handler_map_;
+ CommitContributorMap commit_contributor_map_;
+
+ // Deleter for the |update_handler_map_|.
+ STLValueDeleter<UpdateHandlerMap> update_handler_deleter_;
+
+ // Deleter for the |commit_contributor_map_|.
+ STLValueDeleter<CommitContributorMap> commit_contributor_deleter_;
+
+ // The known ModelSafeWorkers.
+ std::map<ModelSafeGroup, scoped_refptr<ModelSafeWorker> > workers_map_;
+
+ // The directory. Not owned.
+ syncable::Directory* directory_;
+
+ DISALLOW_COPY_AND_ASSIGN(ModelTypeRegistry);
+};
+
+} // namespace syncer
+
+#endif // SYNC_ENGINE_MODEL_TYPE_REGISTRY_H_
+

Powered by Google App Engine
This is Rietveld 408576698