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

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

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

Powered by Google App Engine
This is Rietveld 408576698