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

Side by Side Diff: sync/internal_api/sync_core_proxy_impl.h

Issue 280983002: Implement sync in the NonBlockingTypeProcessor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add some comments Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 SYNC_INTERNAL_API_SYNC_CORE_PROXY_IMPL_H_ 5 #ifndef SYNC_INTERNAL_API_SYNC_CORE_PROXY_IMPL_H_
6 #define SYNC_INTERNAL_API_SYNC_CORE_PROXY_IMPL_H_ 6 #define SYNC_INTERNAL_API_SYNC_CORE_PROXY_IMPL_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/sequenced_task_runner.h" 10 #include "base/sequenced_task_runner.h"
11 #include "sync/base/sync_export.h" 11 #include "sync/base/sync_export.h"
12 #include "sync/internal_api/public/base/model_type.h" 12 #include "sync/internal_api/public/base/model_type.h"
13 #include "sync/internal_api/public/sync_core_proxy.h" 13 #include "sync/internal_api/public/sync_core_proxy.h"
14 14
15 namespace syncer { 15 namespace syncer {
16 16
17 class SyncCore; 17 class SyncCore;
18 class NonBlockingTypeProcessor; 18 class NonBlockingTypeProcessor;
19 struct DataTypeState;
19 20
20 // Encapsulates a reference to the sync core and the thread it's running on. 21 // Encapsulates a reference to the sync core and the thread it's running on.
21 // Used by sync's data types to connect with the sync core. 22 // Used by sync's data types to connect with the sync core.
22 // 23 //
23 // It is epxected that this object will be copied to and used on many different 24 // It is epxected that this object will be copied to and used on many different
24 // threads. It is small and safe to pass by value. 25 // threads. It is small and safe to pass by value.
25 class SYNC_EXPORT_PRIVATE SyncCoreProxyImpl : public SyncCoreProxy { 26 class SYNC_EXPORT_PRIVATE SyncCoreProxyImpl : public SyncCoreProxy {
26 public: 27 public:
27 SyncCoreProxyImpl( 28 SyncCoreProxyImpl(
28 scoped_refptr<base::SequencedTaskRunner> sync_task_runner, 29 scoped_refptr<base::SequencedTaskRunner> sync_task_runner,
29 base::WeakPtr<SyncCore> sync_core); 30 base::WeakPtr<SyncCore> sync_core);
30 virtual ~SyncCoreProxyImpl(); 31 virtual ~SyncCoreProxyImpl();
31 32
32 // Attempts to connect a non-blocking type to the sync core. 33 // Attempts to connect a non-blocking type to the sync core.
33 // 34 //
34 // This may fail under some unusual circumstances, like shutdown. Due to the 35 // This may fail under some unusual circumstances, like shutdown. Due to the
35 // nature of WeakPtrs and cross-thread communication, the caller will be 36 // nature of WeakPtrs and cross-thread communication, the caller will be
36 // unable to distinguish a slow success from failure. 37 // unable to distinguish a slow success from failure.
37 // 38 //
38 // Must be called from the thread where the data type lives. 39 // Must be called from the thread where the data type lives.
39 virtual void ConnectTypeToCore( 40 virtual void ConnectTypeToCore(
40 syncer::ModelType type, 41 syncer::ModelType type,
42 const DataTypeState& data_type_state,
41 base::WeakPtr<NonBlockingTypeProcessor> type_processor) OVERRIDE; 43 base::WeakPtr<NonBlockingTypeProcessor> type_processor) OVERRIDE;
42 44
43 // Disables syncing for the given type on the sync thread. 45 // Disables syncing for the given type on the sync thread.
44 virtual void Disconnect(syncer::ModelType type) OVERRIDE; 46 virtual void Disconnect(syncer::ModelType type) OVERRIDE;
45 47
46 virtual scoped_ptr<SyncCoreProxy> Clone() const OVERRIDE; 48 virtual scoped_ptr<SyncCoreProxy> Clone() const OVERRIDE;
47 49
48 private: 50 private:
49 // A SequencedTaskRunner representing the thread where the SyncCore lives. 51 // A SequencedTaskRunner representing the thread where the SyncCore lives.
50 scoped_refptr<base::SequencedTaskRunner> sync_task_runner_; 52 scoped_refptr<base::SequencedTaskRunner> sync_task_runner_;
51 53
52 // The SyncCore this object is wrapping. 54 // The SyncCore this object is wrapping.
53 base::WeakPtr<SyncCore> sync_core_; 55 base::WeakPtr<SyncCore> sync_core_;
54 }; 56 };
55 57
56 } // namespace syncer 58 } // namespace syncer
57 59
58 #endif // SYNC_INTERNAL_API_SYNC_CORE_PROXY_IMPL_H_ 60 #endif // SYNC_INTERNAL_API_SYNC_CORE_PROXY_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698