Chromium Code Reviews| 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 COMPONENTS_SYNC_ENGINE_IMPL_GET_UPDATES_DELEGATE_H_ | 5 #ifndef COMPONENTS_SYNC_ENGINE_IMPL_GET_UPDATES_DELEGATE_H_ |
| 6 #define COMPONENTS_SYNC_ENGINE_IMPL_GET_UPDATES_DELEGATE_H_ | 6 #define COMPONENTS_SYNC_ENGINE_IMPL_GET_UPDATES_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "components/sync/engine/events/protocol_event.h" | 11 #include "components/sync/engine/events/protocol_event.h" |
| 12 #include "components/sync/engine_impl/cycle/nudge_tracker.h" | 12 #include "components/sync/engine_impl/cycle/nudge_tracker.h" |
| 13 #include "components/sync/engine_impl/cycle/status_controller.h" | 13 #include "components/sync/engine_impl/cycle/status_controller.h" |
| 14 #include "components/sync/engine_impl/model_type_registry.h" | 14 #include "components/sync/engine_impl/model_type_registry.h" |
| 15 #include "components/sync/protocol/sync.pb.h" | 15 #include "components/sync/protocol/sync.pb.h" |
| 16 | 16 |
| 17 namespace syncer { | 17 namespace syncer { |
| 18 | 18 |
| 19 class GetUpdatesProcessor; | 19 class GetUpdatesProcessor; |
| 20 | 20 |
| 21 // Interface for GetUpdates functionality that dependends on the requested | 21 // Interface for GetUpdates functionality that depends on the requested |
| 22 // GetUpdate type (normal, configuration, poll). The GetUpdatesProcessor is | 22 // GetUpdate type (normal, configuration, poll). The GetUpdatesProcessor is |
| 23 // given an appropriate GetUpdatesDelegate to handle type specific functionality | 23 // given an appropriate GetUpdatesDelegate to handle type specific functionality |
| 24 // on construction. | 24 // on construction. |
| 25 class GetUpdatesDelegate { | 25 class GetUpdatesDelegate { |
| 26 public: | 26 public: |
| 27 GetUpdatesDelegate(); | 27 GetUpdatesDelegate(); |
| 28 virtual ~GetUpdatesDelegate() = 0; | 28 virtual ~GetUpdatesDelegate() = 0; |
| 29 | 29 |
| 30 // Populates GetUpdate message fields that depende on GetUpdates request type. | 30 // Populates GetUpdate message fields that depends on GetUpdates request type. |
|
Patrick Noland
2017/05/01 18:08:13
[nit] "depend on"
skym
2017/05/01 20:52:35
Done.
| |
| 31 virtual void HelpPopulateGuMessage( | 31 virtual void HelpPopulateGuMessage( |
| 32 sync_pb::GetUpdatesMessage* get_updates) const = 0; | 32 sync_pb::GetUpdatesMessage* get_updates) const = 0; |
| 33 | 33 |
| 34 // Applies pending updates to non-control types. | 34 // Applies pending updates to non-control types. |
| 35 virtual void ApplyUpdates(ModelTypeSet gu_types, | 35 virtual void ApplyUpdates(const ModelTypeSet& gu_types, |
| 36 StatusController* status, | 36 StatusController* status, |
| 37 UpdateHandlerMap* update_handler_map) const = 0; | 37 UpdateHandlerMap* update_handler_map) const = 0; |
| 38 | 38 |
| 39 virtual std::unique_ptr<ProtocolEvent> GetNetworkRequestEvent( | 39 virtual std::unique_ptr<ProtocolEvent> GetNetworkRequestEvent( |
| 40 base::Time timestamp, | 40 base::Time timestamp, |
| 41 const sync_pb::ClientToServerMessage& request) const = 0; | 41 const sync_pb::ClientToServerMessage& request) const = 0; |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 // Functionality specific to the normal GetUpdate request. | 44 // Functionality specific to the normal GetUpdate request. |
| 45 class NormalGetUpdatesDelegate : public GetUpdatesDelegate { | 45 class NormalGetUpdatesDelegate : public GetUpdatesDelegate { |
| 46 public: | 46 public: |
| 47 explicit NormalGetUpdatesDelegate(const NudgeTracker& nudge_tracker); | 47 explicit NormalGetUpdatesDelegate(const NudgeTracker& nudge_tracker); |
| 48 ~NormalGetUpdatesDelegate() override; | 48 ~NormalGetUpdatesDelegate() override; |
| 49 | 49 |
| 50 // Uses the member NudgeTracker to populate some fields of this GU message. | 50 // Uses the member NudgeTracker to populate some fields of this GU message. |
| 51 void HelpPopulateGuMessage( | 51 void HelpPopulateGuMessage( |
| 52 sync_pb::GetUpdatesMessage* get_updates) const override; | 52 sync_pb::GetUpdatesMessage* get_updates) const override; |
| 53 | 53 |
| 54 // Applies pending updates on the appropriate data type threads. | 54 // Applies pending updates on the appropriate data type threads. |
| 55 void ApplyUpdates(ModelTypeSet gu_types, | 55 void ApplyUpdates(const ModelTypeSet& gu_types, |
| 56 StatusController* status, | 56 StatusController* status, |
| 57 UpdateHandlerMap* update_handler_map) const override; | 57 UpdateHandlerMap* update_handler_map) const override; |
| 58 | 58 |
| 59 std::unique_ptr<ProtocolEvent> GetNetworkRequestEvent( | 59 std::unique_ptr<ProtocolEvent> GetNetworkRequestEvent( |
| 60 base::Time timestamp, | 60 base::Time timestamp, |
| 61 const sync_pb::ClientToServerMessage& request) const override; | 61 const sync_pb::ClientToServerMessage& request) const override; |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 const NudgeTracker& nudge_tracker_; | 64 const NudgeTracker& nudge_tracker_; |
| 65 | 65 |
| 66 DISALLOW_COPY_AND_ASSIGN(NormalGetUpdatesDelegate); | 66 DISALLOW_COPY_AND_ASSIGN(NormalGetUpdatesDelegate); |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 // Functionality specific to the configure GetUpdate request. | 69 // Functionality specific to the configure GetUpdate request. |
| 70 class ConfigureGetUpdatesDelegate : public GetUpdatesDelegate { | 70 class ConfigureGetUpdatesDelegate : public GetUpdatesDelegate { |
| 71 public: | 71 public: |
| 72 ConfigureGetUpdatesDelegate( | 72 ConfigureGetUpdatesDelegate( |
| 73 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source); | 73 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source); |
| 74 ~ConfigureGetUpdatesDelegate() override; | 74 ~ConfigureGetUpdatesDelegate() override; |
| 75 | 75 |
| 76 // Sets the 'source' and 'origin' fields for this request. | 76 // Sets the 'source' and 'origin' fields for this request. |
| 77 void HelpPopulateGuMessage( | 77 void HelpPopulateGuMessage( |
| 78 sync_pb::GetUpdatesMessage* get_updates) const override; | 78 sync_pb::GetUpdatesMessage* get_updates) const override; |
| 79 | 79 |
| 80 // Applies updates passively (ie. on the sync thread). | 80 // Applies updates passively (i.e. on the sync thread). |
| 81 // | 81 // |
| 82 // This is safe only if the ChangeProcessor is not listening to changes at | 82 // This is safe only if the ChangeProcessor is not listening to changes at |
| 83 // this time. | 83 // this time. |
| 84 void ApplyUpdates(ModelTypeSet gu_types, | 84 void ApplyUpdates(const ModelTypeSet& gu_types, |
| 85 StatusController* status, | 85 StatusController* status, |
| 86 UpdateHandlerMap* update_handler_map) const override; | 86 UpdateHandlerMap* update_handler_map) const override; |
| 87 | 87 |
| 88 std::unique_ptr<ProtocolEvent> GetNetworkRequestEvent( | 88 std::unique_ptr<ProtocolEvent> GetNetworkRequestEvent( |
| 89 base::Time timestamp, | 89 base::Time timestamp, |
| 90 const sync_pb::ClientToServerMessage& request) const override; | 90 const sync_pb::ClientToServerMessage& request) const override; |
| 91 | 91 |
| 92 private: | 92 private: |
| 93 static sync_pb::SyncEnums::GetUpdatesOrigin ConvertConfigureSourceToOrigin( | 93 static sync_pb::SyncEnums::GetUpdatesOrigin ConvertConfigureSourceToOrigin( |
| 94 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source); | 94 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source); |
| 95 | 95 |
| 96 const sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source_; | 96 const sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source_; |
| 97 | 97 |
| 98 DISALLOW_COPY_AND_ASSIGN(ConfigureGetUpdatesDelegate); | 98 DISALLOW_COPY_AND_ASSIGN(ConfigureGetUpdatesDelegate); |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 // Functionality specific to the poll GetUpdate request. | 101 // Functionality specific to the poll GetUpdate request. |
| 102 class PollGetUpdatesDelegate : public GetUpdatesDelegate { | 102 class PollGetUpdatesDelegate : public GetUpdatesDelegate { |
| 103 public: | 103 public: |
| 104 PollGetUpdatesDelegate(); | 104 PollGetUpdatesDelegate(); |
| 105 ~PollGetUpdatesDelegate() override; | 105 ~PollGetUpdatesDelegate() override; |
| 106 | 106 |
| 107 // Sets the 'source' and 'origin' to indicate this is a poll request. | 107 // Sets the 'source' and 'origin' to indicate this is a poll request. |
| 108 void HelpPopulateGuMessage( | 108 void HelpPopulateGuMessage( |
| 109 sync_pb::GetUpdatesMessage* get_updates) const override; | 109 sync_pb::GetUpdatesMessage* get_updates) const override; |
| 110 | 110 |
| 111 // Applies updates on the appropriate data type thread. | 111 // Applies updates on the appropriate data type thread. |
| 112 void ApplyUpdates(ModelTypeSet gu_types, | 112 void ApplyUpdates(const ModelTypeSet& gu_types, |
| 113 StatusController* status, | 113 StatusController* status, |
| 114 UpdateHandlerMap* update_handler_map) const override; | 114 UpdateHandlerMap* update_handler_map) const override; |
| 115 | 115 |
| 116 std::unique_ptr<ProtocolEvent> GetNetworkRequestEvent( | 116 std::unique_ptr<ProtocolEvent> GetNetworkRequestEvent( |
| 117 base::Time timestamp, | 117 base::Time timestamp, |
| 118 const sync_pb::ClientToServerMessage& request) const override; | 118 const sync_pb::ClientToServerMessage& request) const override; |
| 119 | 119 |
| 120 private: | 120 private: |
| 121 DISALLOW_COPY_AND_ASSIGN(PollGetUpdatesDelegate); | 121 DISALLOW_COPY_AND_ASSIGN(PollGetUpdatesDelegate); |
| 122 }; | 122 }; |
| 123 | 123 |
| 124 } // namespace syncer | 124 } // namespace syncer |
| 125 | 125 |
| 126 #endif // COMPONENTS_SYNC_ENGINE_IMPL_GET_UPDATES_DELEGATE_H_ | 126 #endif // COMPONENTS_SYNC_ENGINE_IMPL_GET_UPDATES_DELEGATE_H_ |
| OLD | NEW |