| OLD | NEW |
| 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_TEST_ENGINE_INJECTABLE_SYNC_CONTEXT_PROXY_H_ | 5 #ifndef SYNC_TEST_ENGINE_INJECTABLE_SYNC_CONTEXT_PROXY_H_ |
| 6 #define SYNC_TEST_ENGINE_INJECTABLE_SYNC_CONTEXT_PROXY_H_ | 6 #define SYNC_TEST_ENGINE_INJECTABLE_SYNC_CONTEXT_PROXY_H_ |
| 7 | 7 |
| 8 #include "sync/internal_api/public/base/model_type.h" | 8 #include "sync/internal_api/public/base/model_type.h" |
| 9 #include "sync/internal_api/public/non_blocking_sync_common.h" | 9 #include "sync/internal_api/public/non_blocking_sync_common.h" |
| 10 #include "sync/internal_api/public/sync_context_proxy.h" | 10 #include "sync/internal_api/public/sync_context_proxy.h" |
| 11 | 11 |
| 12 namespace syncer_v2 { | 12 namespace syncer_v2 { |
| 13 | 13 |
| 14 class ModelTypeProcessor; | 14 class ModelTypeProcessor; |
| 15 class CommitQueue; | 15 class CommitQueue; |
| 16 | 16 |
| 17 // A SyncContextProxy implementation that, when a connection request is made, | 17 // A SyncContextProxy implementation that, when a connection request is made, |
| 18 // initalizes a connection to a previously injected ModelTypeProcessor. | 18 // initalizes a connection to a previously injected ModelTypeProcessor. |
| 19 class InjectableSyncContextProxy : public SyncContextProxy { | 19 class InjectableSyncContextProxy : public SyncContextProxy { |
| 20 public: | 20 public: |
| 21 explicit InjectableSyncContextProxy(CommitQueue* queue); | 21 explicit InjectableSyncContextProxy(CommitQueue* queue); |
| 22 ~InjectableSyncContextProxy() override; | 22 ~InjectableSyncContextProxy() override; |
| 23 | 23 |
| 24 void ConnectTypeToSync( | 24 void ConnectTypeToSync( |
| 25 syncer::ModelType type, | 25 syncer::ModelType type, |
| 26 const DataTypeState& data_type_state, | 26 scoped_ptr<ActivationContext> activation_context) override; |
| 27 const UpdateResponseDataList& pending_updates, | |
| 28 const base::WeakPtr<ModelTypeProcessor>& type_processor) override; | |
| 29 void Disconnect(syncer::ModelType type) override; | 27 void Disconnect(syncer::ModelType type) override; |
| 30 scoped_ptr<SyncContextProxy> Clone() const override; | 28 scoped_ptr<SyncContextProxy> Clone() const override; |
| 31 | 29 |
| 32 CommitQueue* GetQueue(); | 30 CommitQueue* GetQueue(); |
| 33 | 31 |
| 34 private: | 32 private: |
| 35 // A flag to ensure ConnectTypeToSync is called at most once. | 33 // A flag to ensure ConnectTypeToSync is called at most once. |
| 36 bool is_worker_connected_; | 34 bool is_worker_connected_; |
| 37 | 35 |
| 38 // The ModelTypeProcessor's contract expects that it gets to own this object, | 36 // The ModelTypeProcessor's contract expects that it gets to own this object, |
| 39 // so we can retain only a non-owned pointer to it. | 37 // so we can retain only a non-owned pointer to it. |
| 40 // | 38 // |
| 41 // This is very unsafe, but we can get away with it since these tests are not | 39 // This is very unsafe, but we can get away with it since these tests are not |
| 42 // exercising the proxy <-> worker connection code. | 40 // exercising the proxy <-> worker connection code. |
| 43 CommitQueue* queue_; | 41 CommitQueue* queue_; |
| 44 }; | 42 }; |
| 45 | 43 |
| 46 } // namespace syncer | 44 } // namespace syncer |
| 47 | 45 |
| 48 #endif // SYNC_TEST_ENGINE_INJECTABLE_SYNC_CONTEXT_PROXY_H_ | 46 #endif // SYNC_TEST_ENGINE_INJECTABLE_SYNC_CONTEXT_PROXY_H_ |
| OLD | NEW |