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

Side by Side Diff: chrome/browser/sync/glue/generic_change_processor.h

Issue 8274020: Revert 105404 - [Sync] Refactor non-frontend DTC to handle new API properly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_SYNC_GLUE_GENERIC_CHANGE_PROCESSOR_H_ 5 #ifndef CHROME_BROWSER_SYNC_GLUE_GENERIC_CHANGE_PROCESSOR_H_
6 #define CHROME_BROWSER_SYNC_GLUE_GENERIC_CHANGE_PROCESSOR_H_ 6 #define CHROME_BROWSER_SYNC_GLUE_GENERIC_CHANGE_PROCESSOR_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/threading/non_thread_safe.h"
14 #include "chrome/browser/sync/api/sync_change_processor.h" 12 #include "chrome/browser/sync/api/sync_change_processor.h"
15 #include "chrome/browser/sync/glue/change_processor.h" 13 #include "chrome/browser/sync/glue/change_processor.h"
16 14
17 class SyncData; 15 class SyncData;
18 class SyncableService; 16 class SyncableService;
19 17
20 typedef std::vector<SyncData> SyncDataList; 18 typedef std::vector<SyncData> SyncDataList;
21 19
22 namespace browser_sync { 20 namespace browser_sync {
23 21
24 // TODO(sync): deprecate all change processors and have them replaced by 22 // TODO(sync): deprecate all change processors and have them replaced by
25 // instances of this. 23 // instances of this.
26 // Datatype agnostic change processor. One instance of GenericChangeProcessor 24 // Datatype agnostic change processor. One instance of GenericChangeProcessor
27 // is created for each datatype and lives on the datatype's thread. It then 25 // is created for each datatype and lives on the datatype's thread. It then
28 // handles all interaction with the sync api, both translating pushes from the 26 // handles all interaction with the sync api, both translating pushes from the
29 // local service into transactions and receiving changes from the sync model, 27 // local service into transactions and receiving changes from the sync model,
30 // which then get converted into SyncChange's and sent to the local service. 28 // which then get converted into SyncChange's and sent to the local service.
31 //
32 // As a rule, the GenericChangeProcessor is not thread safe, and should only
33 // be used on the same thread in which it was created.
34 class GenericChangeProcessor : public ChangeProcessor, 29 class GenericChangeProcessor : public ChangeProcessor,
35 public SyncChangeProcessor, 30 public SyncChangeProcessor {
36 public base::NonThreadSafe {
37 public: 31 public:
38 // Create a change processor and connect it to the syncer. 32 GenericChangeProcessor(SyncableService* local_service,
39 GenericChangeProcessor(UnrecoverableErrorHandler* error_handler, 33 UnrecoverableErrorHandler* error_handler,
40 const base::WeakPtr<SyncableService>& local_service,
41 sync_api::UserShare* user_share); 34 sync_api::UserShare* user_share);
42 virtual ~GenericChangeProcessor(); 35 virtual ~GenericChangeProcessor();
43 36
44 // ChangeProcessor interface. 37 // ChangeProcessor interface.
45 // Build and store a list of all changes into |syncer_changes_|. 38 // Build and store a list of all changes into |syncer_changes_|.
46 virtual void ApplyChangesFromSyncModel( 39 virtual void ApplyChangesFromSyncModel(
47 const sync_api::BaseTransaction* trans, 40 const sync_api::BaseTransaction* trans,
48 const sync_api::ImmutableChangeRecordList& changes) OVERRIDE; 41 const sync_api::ImmutableChangeRecordList& changes) OVERRIDE;
49 // Passes |syncer_changes_|, built in ApplyChangesFromSyncModel, onto 42 // Passes |syncer_changes_|, built in ApplyChangesFromSyncModel, onto
50 // |local_service_| by way of it's ProcessSyncChanges method. 43 // |local_service_| by way of it's ProcessSyncChanges method.
51 virtual void CommitChangesFromSyncModel() OVERRIDE; 44 virtual void CommitChangesFromSyncModel() OVERRIDE;
52 45
53 // SyncChangeProcessor implementation. 46 // SyncChangeProcessor implementation.
54 virtual SyncError ProcessSyncChanges( 47 virtual SyncError ProcessSyncChanges(
55 const tracked_objects::Location& from_here, 48 const tracked_objects::Location& from_here,
56 const SyncChangeList& change_list) OVERRIDE; 49 const SyncChangeList& change_list) OVERRIDE;
57 50
58 // Fills |current_sync_data| with all the syncer data for the specified type. 51 // Fills |current_sync_data| with all the syncer data for the specified type.
59 SyncError GetSyncDataForType(syncable::ModelType type, 52 virtual SyncError GetSyncDataForType(syncable::ModelType type,
60 SyncDataList* current_sync_data); 53 SyncDataList* current_sync_data);
61 54
62 // Generic versions of AssociatorInterface methods. Called by 55 // Generic versions of AssociatorInterface methods. Called by
63 // SyncableServiceAdapter or the DataTypeController. 56 // SyncableServiceAdapter.
64 bool SyncModelHasUserCreatedNodes(syncable::ModelType type, 57 bool SyncModelHasUserCreatedNodes(syncable::ModelType type,
65 bool* has_nodes); 58 bool* has_nodes);
66 bool CryptoReadyIfNecessary(syncable::ModelType type); 59 bool CryptoReadyIfNecessary(syncable::ModelType type);
67
68 protected: 60 protected:
69 // ChangeProcessor interface. 61 // ChangeProcessor interface.
70 virtual void StartImpl(Profile* profile) OVERRIDE; // Does nothing. 62 virtual void StartImpl(Profile* profile) OVERRIDE; // Not implemented.
71 // Called from UI thread (as part of deactivating datatype), but does 63 virtual void StopImpl() OVERRIDE; // Not implemented.
72 // nothing and is guaranteed to still be alive, so it's okay. 64 virtual sync_api::UserShare* share_handle() OVERRIDE;
73 virtual void StopImpl() OVERRIDE; // Does nothing.
74 virtual sync_api::UserShare* share_handle() const OVERRIDE;
75
76 private: 65 private:
77 // The SyncableService this change processor will forward changes on to. 66 // The SyncableService this change processor will forward changes on to.
78 const base::WeakPtr<SyncableService> local_service_; 67 SyncableService* local_service_;
79 68
80 // The current list of changes received from the syncer. We buffer because 69 // The current list of changes received from the syncer. We buffer because
81 // we must ensure no syncapi transaction is held when we pass it on to 70 // we must ensure no syncapi transaction is held when we pass it on to
82 // |local_service_|. 71 // |local_service_|.
83 // Set in ApplyChangesFromSyncModel, consumed in CommitChangesFromSyncModel. 72 // Set in ApplyChangesFromSyncModel, consumed in CommitChangesFromSyncModel.
84 SyncChangeList syncer_changes_; 73 SyncChangeList syncer_changes_;
85 74
86 // Our handle to the sync model. Unlike normal ChangeProcessors, we need to 75 // Our handle to the sync model. Unlike normal ChangeProcessors, we need to
87 // be able to access the sync model before the change processor begins 76 // be able to access the sync model before the change processor begins
88 // listening to changes (the local_service_ will be interacting with us 77 // listening to changes (the local_service_ will be interacting with us
89 // when it starts up). As such we can't wait until Start(_) has been called, 78 // when it starts up). As such we can't wait until Start(_) has been called,
90 // and have to keep a local pointer to the user_share. 79 // and have to keep a local pointer to the user_share.
91 sync_api::UserShare* const share_handle_; 80 sync_api::UserShare* user_share_;
92
93 DISALLOW_COPY_AND_ASSIGN(GenericChangeProcessor);
94 }; 81 };
95 82
96 } // namespace browser_sync 83 } // namespace browser_sync
97 84
98 #endif // CHROME_BROWSER_SYNC_GLUE_GENERIC_CHANGE_PROCESSOR_H_ 85 #endif // CHROME_BROWSER_SYNC_GLUE_GENERIC_CHANGE_PROCESSOR_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/frontend_data_type_controller.cc ('k') | chrome/browser/sync/glue/generic_change_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698