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_ENGINE_GET_UPDATES_PROCESSOR_H_ | 5 #ifndef COMPONENTS_SYNC_ENGINE_IMPL_GET_UPDATES_PROCESSOR_H_ |
6 #define SYNC_ENGINE_GET_UPDATES_PROCESSOR_H_ | 6 #define COMPONENTS_SYNC_ENGINE_IMPL_GET_UPDATES_PROCESSOR_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "sync/base/sync_export.h" | 13 #include "components/sync/base/model_type.h" |
14 #include "sync/internal_api/public/base/model_type.h" | 14 #include "components/sync/base/sync_export.h" |
15 #include "sync/internal_api/public/engine/model_safe_worker.h" | 15 #include "components/sync/engine/model_safe_worker.h" |
16 #include "sync/protocol/sync.pb.h" | 16 #include "components/sync/protocol/sync.pb.h" |
17 #include "sync/sessions/model_type_registry.h" | 17 #include "components/sync/sessions_impl/model_type_registry.h" |
18 | 18 |
19 namespace sync_pb { | 19 namespace sync_pb { |
20 class GetUpdatesMessage; | 20 class GetUpdatesMessage; |
21 class GetUpdatesResponse; | 21 class GetUpdatesResponse; |
22 } // namespace sync_pb | 22 } // namespace sync_pb |
23 | 23 |
24 namespace syncer { | 24 namespace syncer { |
25 | 25 |
26 namespace sessions { | 26 namespace sessions { |
27 class StatusController; | 27 class StatusController; |
(...skipping 18 matching lines...) Expand all Loading... |
46 public: | 46 public: |
47 explicit GetUpdatesProcessor(UpdateHandlerMap* update_handler_map, | 47 explicit GetUpdatesProcessor(UpdateHandlerMap* update_handler_map, |
48 const GetUpdatesDelegate& delegate); | 48 const GetUpdatesDelegate& delegate); |
49 ~GetUpdatesProcessor(); | 49 ~GetUpdatesProcessor(); |
50 | 50 |
51 // Downloads and processes a batch of updates for the specified types. | 51 // Downloads and processes a batch of updates for the specified types. |
52 // | 52 // |
53 // Returns SYNCER_OK if the download succeeds, SERVER_MORE_TO_DOWNLOAD if the | 53 // Returns SYNCER_OK if the download succeeds, SERVER_MORE_TO_DOWNLOAD if the |
54 // download succeeded but there are still some updates left to fetch on the | 54 // download succeeded but there are still some updates left to fetch on the |
55 // server, or an appropriate error value in case of failure. | 55 // server, or an appropriate error value in case of failure. |
56 SyncerError DownloadUpdates( | 56 SyncerError DownloadUpdates(ModelTypeSet* request_types, |
57 ModelTypeSet* request_types, | 57 sessions::SyncSession* session, |
58 sessions::SyncSession* session, | 58 bool create_mobile_bookmarks_folder); |
59 bool create_mobile_bookmarks_folder); | |
60 | 59 |
61 // Applies any downloaded and processed updates. | 60 // Applies any downloaded and processed updates. |
62 void ApplyUpdates( | 61 void ApplyUpdates(ModelTypeSet gu_types, |
63 ModelTypeSet gu_types, | 62 sessions::StatusController* status_controller); |
64 sessions::StatusController* status_controller); | |
65 | 63 |
66 private: | 64 private: |
67 // Populates a GetUpdates request message with per-type information. | 65 // Populates a GetUpdates request message with per-type information. |
68 void PrepareGetUpdates( | 66 void PrepareGetUpdates(ModelTypeSet gu_types, |
69 ModelTypeSet gu_types, | 67 sync_pb::ClientToServerMessage* message); |
70 sync_pb::ClientToServerMessage* message); | |
71 | 68 |
72 // Sends the specified message to the server and stores the response in a | 69 // Sends the specified message to the server and stores the response in a |
73 // member of the |session|'s StatusController. | 70 // member of the |session|'s StatusController. |
74 SyncerError ExecuteDownloadUpdates(ModelTypeSet* request_types, | 71 SyncerError ExecuteDownloadUpdates(ModelTypeSet* request_types, |
75 sessions::SyncSession* session, | 72 sessions::SyncSession* session, |
76 sync_pb::ClientToServerMessage* msg); | 73 sync_pb::ClientToServerMessage* msg); |
77 | 74 |
78 // Helper function for processing responses from the server. Defined here for | 75 // Helper function for processing responses from the server. Defined here for |
79 // testing. | 76 // testing. |
80 SyncerError ProcessResponse(const sync_pb::GetUpdatesResponse& gu_response, | 77 SyncerError ProcessResponse(const sync_pb::GetUpdatesResponse& gu_response, |
81 ModelTypeSet proto_request_types, | 78 ModelTypeSet proto_request_types, |
82 sessions::StatusController* status); | 79 sessions::StatusController* status); |
83 | 80 |
84 // Processes a GetUpdates responses for each type. | 81 // Processes a GetUpdates responses for each type. |
85 syncer::SyncerError ProcessGetUpdatesResponse( | 82 syncer::SyncerError ProcessGetUpdatesResponse( |
86 ModelTypeSet gu_types, | 83 ModelTypeSet gu_types, |
87 const sync_pb::GetUpdatesResponse& gu_response, | 84 const sync_pb::GetUpdatesResponse& gu_response, |
88 sessions::StatusController* status_controller); | 85 sessions::StatusController* status_controller); |
89 | 86 |
90 static void CopyClientDebugInfo( | 87 static void CopyClientDebugInfo(sessions::DebugInfoGetter* debug_info_getter, |
91 sessions::DebugInfoGetter* debug_info_getter, | 88 sync_pb::DebugInfo* debug_info); |
92 sync_pb::DebugInfo* debug_info); | |
93 | 89 |
94 FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest, BookmarkNudge); | 90 FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest, BookmarkNudge); |
95 FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest, NotifyMany); | 91 FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest, NotifyMany); |
96 FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest, InitialSyncRequest); | 92 FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest, InitialSyncRequest); |
97 FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest, ConfigureTest); | 93 FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest, ConfigureTest); |
98 FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest, PollTest); | 94 FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest, PollTest); |
99 FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest, RetryTest); | 95 FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest, RetryTest); |
100 FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest, NudgeWithRetryTest); | 96 FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest, NudgeWithRetryTest); |
101 FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest, InvalidResponse); | 97 FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest, InvalidResponse); |
102 FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest, MoreToDownloadResponse); | 98 FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest, MoreToDownloadResponse); |
103 FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest, NormalResponseTest); | 99 FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest, NormalResponseTest); |
104 FRIEND_TEST_ALL_PREFIXES(DownloadUpdatesDebugInfoTest, | 100 FRIEND_TEST_ALL_PREFIXES(DownloadUpdatesDebugInfoTest, |
105 VerifyCopyClientDebugInfo_Empty); | 101 VerifyCopyClientDebugInfo_Empty); |
106 FRIEND_TEST_ALL_PREFIXES(DownloadUpdatesDebugInfoTest, VerifyCopyOverwrites); | 102 FRIEND_TEST_ALL_PREFIXES(DownloadUpdatesDebugInfoTest, VerifyCopyOverwrites); |
107 | 103 |
108 // A map of 'update handlers', one for each enabled type. | 104 // A map of 'update handlers', one for each enabled type. |
109 // This must be kept in sync with the routing info. Our temporary solution to | 105 // This must be kept in sync with the routing info. Our temporary solution to |
110 // that problem is to initialize this map in set_routing_info(). | 106 // that problem is to initialize this map in set_routing_info(). |
111 UpdateHandlerMap* update_handler_map_; | 107 UpdateHandlerMap* update_handler_map_; |
112 | 108 |
113 const GetUpdatesDelegate& delegate_; | 109 const GetUpdatesDelegate& delegate_; |
114 | 110 |
115 DISALLOW_COPY_AND_ASSIGN(GetUpdatesProcessor); | 111 DISALLOW_COPY_AND_ASSIGN(GetUpdatesProcessor); |
116 }; | 112 }; |
117 | 113 |
118 } // namespace syncer | 114 } // namespace syncer |
119 | 115 |
120 #endif // SYNC_ENGINE_GET_UPDATES_PROCESSOR_H_ | 116 #endif // COMPONENTS_SYNC_ENGINE_IMPL_GET_UPDATES_PROCESSOR_H_ |
OLD | NEW |