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

Unified Diff: chrome/browser/sync/glue/generic_change_processor.h

Issue 6995008: Implement new SyncAPI and convert Preferences to it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and fix compile Created 9 years, 7 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
« no previous file with comments | « chrome/browser/sync/glue/change_processor.h ('k') | chrome/browser/sync/glue/generic_change_processor.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/glue/generic_change_processor.h
diff --git a/chrome/browser/sync/glue/generic_change_processor.h b/chrome/browser/sync/glue/generic_change_processor.h
index a5547c24546f29c4f9c2cfa312384cd0405dac8f..1094d12a99505248a02ce3d65a8e5bb4d2eaf4b7 100644
--- a/chrome/browser/sync/glue/generic_change_processor.h
+++ b/chrome/browser/sync/glue/generic_change_processor.h
@@ -6,34 +6,77 @@
#define CHROME_BROWSER_SYNC_GLUE_GENERIC_CHANGE_PROCESSOR_H_
#pragma once
+#include <vector>
+
+#include "base/compiler_specific.h"
+#include "chrome/browser/sync/api/sync_change_processor.h"
#include "chrome/browser/sync/glue/change_processor.h"
+class SyncData;
class SyncableService;
+typedef std::vector<SyncData> SyncDataList;
+
namespace browser_sync {
-// TODO(sync): Have this become a SyncableService implementation and deprecate
-// ChangeProcessor.
-// For now, it acts as a dummy change processor that just passes all
-// ApplySyncChanges commands onto the local SyncableService..
-class GenericChangeProcessor : public ChangeProcessor {
+// TODO(sync): deprecate all change processors and have them replaced by
+// instances of this.
+// Datatype agnostic change processor. One instance of GenericChangeProcessor
+// is created for each datatype and lives on the datatype's thread. It then
+// handles all interaction with the sync api, both translating pushes from the
+// local service into transactions and receiving changes from the sync model,
+// which then get converted into SyncChange's and sent to the local service.
+class GenericChangeProcessor : public ChangeProcessor,
+ public SyncChangeProcessor {
public:
GenericChangeProcessor(SyncableService* local_service,
- UnrecoverableErrorHandler* error_handler);
+ UnrecoverableErrorHandler* error_handler,
+ sync_api::UserShare* user_share);
~GenericChangeProcessor();
// ChangeProcessor interface.
- // Just passes all arguments onto the |local_service_|
+ // Build and store a list of all changes into |syncer_changes_|.
virtual void ApplyChangesFromSyncModel(
const sync_api::BaseTransaction* trans,
const sync_api::SyncManager::ChangeRecord* changes,
- int change_count);
+ int change_count) OVERRIDE;
+ // Passes |syncer_changes_|, built in ApplyChangesFromSyncModel, onto
+ // |local_service_| by way of it's ProcessSyncChanges method.
+ virtual void CommitChangesFromSyncModel() OVERRIDE;
+
+ // SyncChangeProcessor implementation.
+ virtual void ProcessSyncChanges(const SyncChangeList& change_list) OVERRIDE;
+
+ // Fills |current_sync_data| with all the syncer data for the specified type.
+ virtual bool GetSyncDataForType(syncable::ModelType type,
+ SyncDataList* current_sync_data);
+
+ // Generic versions of AssociatorInterface methods. Called by
+ // SyncableServiceAdapter.
+ bool SyncModelHasUserCreatedNodes(syncable::ModelType type,
+ bool* has_nodes);
+ bool CryptoReadyIfNecessary(syncable::ModelType type);
protected:
// ChangeProcessor interface.
- virtual void StartImpl(Profile* profile); // Not implemented.
- virtual void StopImpl(); // Not implemented.
+ virtual void StartImpl(Profile* profile) OVERRIDE; // Not implemented.
+ virtual void StopImpl() OVERRIDE; // Not implemented.
+ virtual sync_api::UserShare* share_handle() OVERRIDE;
private:
+ // The SyncableService this change processor will forward changes on to.
SyncableService* local_service_;
+
+ // The current list of changes received from the syncer. We buffer because
+ // we must ensure no syncapi transaction is held when we pass it on to
+ // |local_service_|.
+ // Set in ApplyChangesFromSyncModel, consumed in CommitChangesFromSyncModel.
+ SyncChangeList syncer_changes_;
+
+ // Our handle to the sync model. Unlike normal ChangeProcessors, we need to
+ // be able to access the sync model before the change processor begins
+ // listening to changes (the local_service_ will be interacting with us
+ // when it starts up). As such we can't wait until Start(_) has been called,
+ // and have to keep a local pointer to the user_share.
+ sync_api::UserShare* user_share_;
};
} // namespace browser_sync
« no previous file with comments | « chrome/browser/sync/glue/change_processor.h ('k') | chrome/browser/sync/glue/generic_change_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698