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/protocol/sync.pb.h" | 12 #include "components/sync/protocol/sync.pb.h" |
13 #include "components/sync/sessions_impl/model_type_registry.h" | 13 #include "components/sync/sessions_impl/model_type_registry.h" |
14 #include "components/sync/sessions_impl/nudge_tracker.h" | 14 #include "components/sync/sessions_impl/nudge_tracker.h" |
15 #include "components/sync/sessions_impl/status_controller.h" | 15 #include "components/sync/sessions_impl/status_controller.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 dependends 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 SYNC_EXPORT 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 depende on GetUpdates request type. |
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(ModelTypeSet gu_types, |
36 sessions::StatusController* status, | 36 sessions::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 SYNC_EXPORT NormalGetUpdatesDelegate : public GetUpdatesDelegate { | 45 class NormalGetUpdatesDelegate : public GetUpdatesDelegate { |
46 public: | 46 public: |
47 explicit NormalGetUpdatesDelegate( | 47 explicit NormalGetUpdatesDelegate( |
48 const sessions::NudgeTracker& nudge_tracker); | 48 const sessions::NudgeTracker& nudge_tracker); |
49 ~NormalGetUpdatesDelegate() override; | 49 ~NormalGetUpdatesDelegate() override; |
50 | 50 |
51 // Uses the member NudgeTracker to populate some fields of this GU message. | 51 // Uses the member NudgeTracker to populate some fields of this GU message. |
52 void HelpPopulateGuMessage( | 52 void HelpPopulateGuMessage( |
53 sync_pb::GetUpdatesMessage* get_updates) const override; | 53 sync_pb::GetUpdatesMessage* get_updates) const override; |
54 | 54 |
55 // Applies pending updates on the appropriate data type threads. | 55 // Applies pending updates on the appropriate data type threads. |
56 void ApplyUpdates(ModelTypeSet gu_types, | 56 void ApplyUpdates(ModelTypeSet gu_types, |
57 sessions::StatusController* status, | 57 sessions::StatusController* status, |
58 UpdateHandlerMap* update_handler_map) const override; | 58 UpdateHandlerMap* update_handler_map) const override; |
59 | 59 |
60 std::unique_ptr<ProtocolEvent> GetNetworkRequestEvent( | 60 std::unique_ptr<ProtocolEvent> GetNetworkRequestEvent( |
61 base::Time timestamp, | 61 base::Time timestamp, |
62 const sync_pb::ClientToServerMessage& request) const override; | 62 const sync_pb::ClientToServerMessage& request) const override; |
63 | 63 |
64 private: | 64 private: |
65 const sessions::NudgeTracker& nudge_tracker_; | 65 const sessions::NudgeTracker& nudge_tracker_; |
66 | 66 |
67 DISALLOW_COPY_AND_ASSIGN(NormalGetUpdatesDelegate); | 67 DISALLOW_COPY_AND_ASSIGN(NormalGetUpdatesDelegate); |
68 }; | 68 }; |
69 | 69 |
70 // Functionality specific to the configure GetUpdate request. | 70 // Functionality specific to the configure GetUpdate request. |
71 class SYNC_EXPORT ConfigureGetUpdatesDelegate : public GetUpdatesDelegate { | 71 class ConfigureGetUpdatesDelegate : public GetUpdatesDelegate { |
72 public: | 72 public: |
73 ConfigureGetUpdatesDelegate( | 73 ConfigureGetUpdatesDelegate( |
74 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source); | 74 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source); |
75 ~ConfigureGetUpdatesDelegate() override; | 75 ~ConfigureGetUpdatesDelegate() override; |
76 | 76 |
77 // Sets the 'source' and 'origin' fields for this request. | 77 // Sets the 'source' and 'origin' fields for this request. |
78 void HelpPopulateGuMessage( | 78 void HelpPopulateGuMessage( |
79 sync_pb::GetUpdatesMessage* get_updates) const override; | 79 sync_pb::GetUpdatesMessage* get_updates) const override; |
80 | 80 |
81 // Applies updates passively (ie. on the sync thread). | 81 // Applies updates passively (ie. on the sync thread). |
(...skipping 11 matching lines...) Expand all Loading... |
93 private: | 93 private: |
94 static sync_pb::SyncEnums::GetUpdatesOrigin ConvertConfigureSourceToOrigin( | 94 static sync_pb::SyncEnums::GetUpdatesOrigin ConvertConfigureSourceToOrigin( |
95 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source); | 95 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source); |
96 | 96 |
97 const sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source_; | 97 const sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source_; |
98 | 98 |
99 DISALLOW_COPY_AND_ASSIGN(ConfigureGetUpdatesDelegate); | 99 DISALLOW_COPY_AND_ASSIGN(ConfigureGetUpdatesDelegate); |
100 }; | 100 }; |
101 | 101 |
102 // Functionality specific to the poll GetUpdate request. | 102 // Functionality specific to the poll GetUpdate request. |
103 class SYNC_EXPORT PollGetUpdatesDelegate : public GetUpdatesDelegate { | 103 class PollGetUpdatesDelegate : public GetUpdatesDelegate { |
104 public: | 104 public: |
105 PollGetUpdatesDelegate(); | 105 PollGetUpdatesDelegate(); |
106 ~PollGetUpdatesDelegate() override; | 106 ~PollGetUpdatesDelegate() override; |
107 | 107 |
108 // Sets the 'source' and 'origin' to indicate this is a poll request. | 108 // Sets the 'source' and 'origin' to indicate this is a poll request. |
109 void HelpPopulateGuMessage( | 109 void HelpPopulateGuMessage( |
110 sync_pb::GetUpdatesMessage* get_updates) const override; | 110 sync_pb::GetUpdatesMessage* get_updates) const override; |
111 | 111 |
112 // Applies updates on the appropriate data type thread. | 112 // Applies updates on the appropriate data type thread. |
113 void ApplyUpdates(ModelTypeSet gu_types, | 113 void ApplyUpdates(ModelTypeSet gu_types, |
114 sessions::StatusController* status, | 114 sessions::StatusController* status, |
115 UpdateHandlerMap* update_handler_map) const override; | 115 UpdateHandlerMap* update_handler_map) const override; |
116 | 116 |
117 std::unique_ptr<ProtocolEvent> GetNetworkRequestEvent( | 117 std::unique_ptr<ProtocolEvent> GetNetworkRequestEvent( |
118 base::Time timestamp, | 118 base::Time timestamp, |
119 const sync_pb::ClientToServerMessage& request) const override; | 119 const sync_pb::ClientToServerMessage& request) const override; |
120 | 120 |
121 private: | 121 private: |
122 DISALLOW_COPY_AND_ASSIGN(PollGetUpdatesDelegate); | 122 DISALLOW_COPY_AND_ASSIGN(PollGetUpdatesDelegate); |
123 }; | 123 }; |
124 | 124 |
125 } // namespace syncer | 125 } // namespace syncer |
126 | 126 |
127 #endif // SYNC_ENGINE_IMPL_GET_UPDATES_DELEGATE_H_ | 127 #endif // SYNC_ENGINE_IMPL_GET_UPDATES_DELEGATE_H_ |
OLD | NEW |