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

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

Issue 10662035: [Sync] Put everything in sync/api into csync namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix comments Created 8 years, 6 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 class SyncData; 20 class SyncData;
20 class SyncableService; 21 class SyncableService;
21 22
22 typedef std::vector<SyncData> SyncDataList; 23 typedef std::vector<csync::SyncData> SyncDataList;
24 } // namespace csync
23 25
24 namespace browser_sync { 26 namespace browser_sync {
25 27
26 // TODO(sync): deprecate all change processors and have them replaced by 28 // TODO(sync): deprecate all change processors and have them replaced by
27 // instances of this. 29 // instances of this.
28 // Datatype agnostic change processor. One instance of GenericChangeProcessor 30 // Datatype agnostic change processor. One instance of GenericChangeProcessor
29 // 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
30 // 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
31 // local service into transactions and receiving changes from the sync model, 33 // local service into transactions and receiving changes from the sync model,
32 // 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.
33 // 35 //
34 // 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
35 // be used on the same thread in which it was created. 37 // be used on the same thread in which it was created.
36 class GenericChangeProcessor : public ChangeProcessor, 38 class GenericChangeProcessor : public ChangeProcessor,
37 public SyncChangeProcessor, 39 public csync::SyncChangeProcessor,
38 public base::NonThreadSafe { 40 public base::NonThreadSafe {
39 public: 41 public:
40 // Create a change processor and connect it to the syncer. 42 // Create a change processor and connect it to the syncer.
41 GenericChangeProcessor(DataTypeErrorHandler* error_handler, 43 GenericChangeProcessor(
42 const base::WeakPtr<SyncableService>& local_service, 44 DataTypeErrorHandler* error_handler,
43 csync::UserShare* user_share); 45 const base::WeakPtr<csync::SyncableService>& local_service,
46 csync::UserShare* user_share);
44 virtual ~GenericChangeProcessor(); 47 virtual ~GenericChangeProcessor();
45 48
46 // ChangeProcessor interface. 49 // ChangeProcessor interface.
47 // Build and store a list of all changes into |syncer_changes_|. 50 // Build and store a list of all changes into |syncer_changes_|.
48 virtual void ApplyChangesFromSyncModel( 51 virtual void ApplyChangesFromSyncModel(
49 const csync::BaseTransaction* trans, 52 const csync::BaseTransaction* trans,
50 const csync::ImmutableChangeRecordList& changes) OVERRIDE; 53 const csync::ImmutableChangeRecordList& changes) OVERRIDE;
51 // Passes |syncer_changes_|, built in ApplyChangesFromSyncModel, onto 54 // Passes |syncer_changes_|, built in ApplyChangesFromSyncModel, onto
52 // |local_service_| by way of its ProcessSyncChanges method. 55 // |local_service_| by way of its ProcessSyncChanges method.
53 virtual void CommitChangesFromSyncModel() OVERRIDE; 56 virtual void CommitChangesFromSyncModel() OVERRIDE;
54 57
55 // SyncChangeProcessor implementation. 58 // csync::SyncChangeProcessor implementation.
56 virtual SyncError ProcessSyncChanges( 59 virtual csync::SyncError ProcessSyncChanges(
57 const tracked_objects::Location& from_here, 60 const tracked_objects::Location& from_here,
58 const SyncChangeList& change_list) OVERRIDE; 61 const csync::SyncChangeList& change_list) OVERRIDE;
59 62
60 // 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.
61 virtual SyncError GetSyncDataForType(syncable::ModelType type, 64 virtual csync::SyncError GetSyncDataForType(syncable::ModelType type,
62 SyncDataList* current_sync_data); 65 csync::SyncDataList* current_sync_data);
63 66
64 // Generic versions of AssociatorInterface methods. Called by 67 // Generic versions of AssociatorInterface methods. Called by
65 // SyncableServiceAdapter or the DataTypeController. 68 // csync::SyncableServiceAdapter or the DataTypeController.
66 virtual bool SyncModelHasUserCreatedNodes(syncable::ModelType type, 69 virtual bool SyncModelHasUserCreatedNodes(syncable::ModelType type,
67 bool* has_nodes); 70 bool* has_nodes);
68 virtual bool CryptoReadyIfNecessary(syncable::ModelType type); 71 virtual bool CryptoReadyIfNecessary(syncable::ModelType type);
69 72
70 protected: 73 protected:
71 // ChangeProcessor interface. 74 // ChangeProcessor interface.
72 virtual void StartImpl(Profile* profile) OVERRIDE; // Does nothing. 75 virtual void StartImpl(Profile* profile) OVERRIDE; // Does nothing.
73 // Called from UI thread (as part of deactivating datatype), but does 76 // Called from UI thread (as part of deactivating datatype), but does
74 // 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.
75 virtual void StopImpl() OVERRIDE; // Does nothing. 78 virtual void StopImpl() OVERRIDE; // Does nothing.
76 virtual csync::UserShare* share_handle() const OVERRIDE; 79 virtual csync::UserShare* share_handle() const OVERRIDE;
77 80
78 private: 81 private:
79 // The SyncableService this change processor will forward changes on to. 82 // The SyncableService this change processor will forward changes on to.
80 const base::WeakPtr<SyncableService> local_service_; 83 const base::WeakPtr<csync::SyncableService> local_service_;
81 84
82 // 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
83 // 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
84 // |local_service_|. 87 // |local_service_|.
85 // Set in ApplyChangesFromSyncModel, consumed in CommitChangesFromSyncModel. 88 // Set in ApplyChangesFromSyncModel, consumed in CommitChangesFromSyncModel.
86 SyncChangeList syncer_changes_; 89 csync::SyncChangeList syncer_changes_;
87 90
88 // 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
89 // 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
90 // listening to changes (the local_service_ will be interacting with us 93 // listening to changes (the local_service_ will be interacting with us
91 // 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,
92 // and have to keep a local pointer to the user_share. 95 // and have to keep a local pointer to the user_share.
93 csync::UserShare* const share_handle_; 96 csync::UserShare* const share_handle_;
94 97
95 DISALLOW_COPY_AND_ASSIGN(GenericChangeProcessor); 98 DISALLOW_COPY_AND_ASSIGN(GenericChangeProcessor);
96 }; 99 };
97 100
98 } // namespace browser_sync 101 } // namespace browser_sync
99 102
100 #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