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

Side by Side Diff: chrome/browser/sync/glue/shared_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_SHARED_CHANGE_PROCESSOR_H_ 5 #ifndef CHROME_BROWSER_SYNC_GLUE_SHARED_CHANGE_PROCESSOR_H_
6 #define CHROME_BROWSER_SYNC_GLUE_SHARED_CHANGE_PROCESSOR_H_ 6 #define CHROME_BROWSER_SYNC_GLUE_SHARED_CHANGE_PROCESSOR_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/message_loop_proxy.h" 12 #include "base/message_loop_proxy.h"
13 #include "base/synchronization/lock.h" 13 #include "base/synchronization/lock.h"
14 #include "chrome/browser/sync/glue/data_type_error_handler.h" 14 #include "chrome/browser/sync/glue/data_type_error_handler.h"
15 #include "sync/api/sync_change_processor.h" 15 #include "sync/api/sync_change_processor.h"
16 #include "sync/api/sync_error.h" 16 #include "sync/api/sync_error.h"
17 #include "sync/api/sync_error_factory.h" 17 #include "sync/api/sync_error_factory.h"
18 #include "sync/internal_api/public/engine/model_safe_worker.h" 18 #include "sync/internal_api/public/engine/model_safe_worker.h"
19 19
20 class ProfileSyncComponentsFactory; 20 class ProfileSyncComponentsFactory;
21 class ProfileSyncService; 21 class ProfileSyncService;
22 22
23 namespace csync { 23 namespace syncer {
24 class SyncData; 24 class SyncData;
25 class SyncableService; 25 class SyncableService;
26 26
27 typedef std::vector<csync::SyncData> SyncDataList; 27 typedef std::vector<syncer::SyncData> SyncDataList;
28 } // namespace 28 } // namespace
29 29
30 namespace browser_sync { 30 namespace browser_sync {
31 31
32 class GenericChangeProcessor; 32 class GenericChangeProcessor;
33 class DataTypeErrorHandler; 33 class DataTypeErrorHandler;
34 34
35 // A ref-counted wrapper around a GenericChangeProcessor for use with datatypes 35 // A ref-counted wrapper around a GenericChangeProcessor for use with datatypes
36 // that don't live on the UI thread. 36 // that don't live on the UI thread.
37 // 37 //
(...skipping 12 matching lines...) Expand all
50 // 50 //
51 // We use virtual methods so that we can use mock's in testing. 51 // We use virtual methods so that we can use mock's in testing.
52 class SharedChangeProcessor 52 class SharedChangeProcessor
53 : public base::RefCountedThreadSafe<SharedChangeProcessor> { 53 : public base::RefCountedThreadSafe<SharedChangeProcessor> {
54 public: 54 public:
55 // Create an uninitialized SharedChangeProcessor (to be later connected). 55 // Create an uninitialized SharedChangeProcessor (to be later connected).
56 SharedChangeProcessor(); 56 SharedChangeProcessor();
57 57
58 // Connect to the Syncer and prepare to handle changes for |type|. Will 58 // Connect to the Syncer and prepare to handle changes for |type|. Will
59 // create and store a new GenericChangeProcessor and return a weak pointer to 59 // create and store a new GenericChangeProcessor and return a weak pointer to
60 // the csync::SyncableService associated with |type|. 60 // the syncer::SyncableService associated with |type|.
61 // Note: If this SharedChangeProcessor has been disconnected, or the 61 // Note: If this SharedChangeProcessor has been disconnected, or the
62 // csync::SyncableService was not alive, will return a null weak pointer. 62 // syncer::SyncableService was not alive, will return a null weak pointer.
63 virtual base::WeakPtr<csync::SyncableService> Connect( 63 virtual base::WeakPtr<syncer::SyncableService> Connect(
64 ProfileSyncComponentsFactory* sync_factory, 64 ProfileSyncComponentsFactory* sync_factory,
65 ProfileSyncService* sync_service, 65 ProfileSyncService* sync_service,
66 DataTypeErrorHandler* error_handler, 66 DataTypeErrorHandler* error_handler,
67 syncable::ModelType type); 67 syncable::ModelType type);
68 68
69 // Disconnects from the generic change processor. May be called from any 69 // Disconnects from the generic change processor. May be called from any
70 // thread. After this, all attempts to interact with the change processor by 70 // thread. After this, all attempts to interact with the change processor by
71 // |local_service_| are dropped and return errors. The syncer will be safe to 71 // |local_service_| are dropped and return errors. The syncer will be safe to
72 // shut down from the point of view of this datatype. 72 // shut down from the point of view of this datatype.
73 // Note: Once disconnected, you cannot reconnect without creating a new 73 // Note: Once disconnected, you cannot reconnect without creating a new
74 // SharedChangeProcessor. 74 // SharedChangeProcessor.
75 // Returns: true if we were previously succesfully connected, false if we were 75 // Returns: true if we were previously succesfully connected, false if we were
76 // already disconnected. 76 // already disconnected.
77 virtual bool Disconnect(); 77 virtual bool Disconnect();
78 78
79 // GenericChangeProcessor stubs (with disconnect support). 79 // GenericChangeProcessor stubs (with disconnect support).
80 // Should only be called on the same thread the datatype resides. 80 // Should only be called on the same thread the datatype resides.
81 virtual csync::SyncError GetSyncData(csync::SyncDataList* current_sync_data); 81 virtual syncer::SyncError GetSyncData(
82 virtual csync::SyncError ProcessSyncChanges( 82 syncer::SyncDataList* current_sync_data);
83 virtual syncer::SyncError ProcessSyncChanges(
83 const tracked_objects::Location& from_here, 84 const tracked_objects::Location& from_here,
84 const csync::SyncChangeList& change_list); 85 const syncer::SyncChangeList& change_list);
85 virtual bool SyncModelHasUserCreatedNodes(bool* has_nodes); 86 virtual bool SyncModelHasUserCreatedNodes(bool* has_nodes);
86 virtual bool CryptoReadyIfNecessary(); 87 virtual bool CryptoReadyIfNecessary();
87 88
88 // Register |generic_change_processor_| as the change processor for the 89 // Register |generic_change_processor_| as the change processor for the
89 // current type on |model_safe_group|. 90 // current type on |model_safe_group|.
90 // Does nothing if |disconnected_| is true. 91 // Does nothing if |disconnected_| is true.
91 virtual void ActivateDataType(csync::ModelSafeGroup model_safe_group); 92 virtual void ActivateDataType(syncer::ModelSafeGroup model_safe_group);
92 93
93 virtual csync::SyncError CreateAndUploadError( 94 virtual syncer::SyncError CreateAndUploadError(
94 const tracked_objects::Location& location, 95 const tracked_objects::Location& location,
95 const std::string& message); 96 const std::string& message);
96 97
97 protected: 98 protected:
98 friend class base::RefCountedThreadSafe<SharedChangeProcessor>; 99 friend class base::RefCountedThreadSafe<SharedChangeProcessor>;
99 virtual ~SharedChangeProcessor(); 100 virtual ~SharedChangeProcessor();
100 101
101 private: 102 private:
102 // Monitor lock for this object. All methods that interact with the change 103 // Monitor lock for this object. All methods that interact with the change
103 // processor must aquire this lock and check whether we're disconnected or 104 // processor must aquire this lock and check whether we're disconnected or
(...skipping 17 matching lines...) Expand all
121 GenericChangeProcessor* generic_change_processor_; 122 GenericChangeProcessor* generic_change_processor_;
122 123
123 DataTypeErrorHandler* error_handler_; 124 DataTypeErrorHandler* error_handler_;
124 125
125 DISALLOW_COPY_AND_ASSIGN(SharedChangeProcessor); 126 DISALLOW_COPY_AND_ASSIGN(SharedChangeProcessor);
126 }; 127 };
127 128
128 } // namespace browser_sync 129 } // namespace browser_sync
129 130
130 #endif // CHROME_BROWSER_SYNC_GLUE_SHARED_CHANGE_PROCESSOR_H_ 131 #endif // CHROME_BROWSER_SYNC_GLUE_SHARED_CHANGE_PROCESSOR_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/session_model_associator_unittest.cc ('k') | chrome/browser/sync/glue/shared_change_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698