• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef SYNC_ENGINE_DOWNLOAD_H_
6 #define SYNC_ENGINE_DOWNLOAD_H_
7 
8 #include "sync/base/sync_export.h"
9 #include "sync/engine/sync_directory_update_handler.h"
10 #include "sync/internal_api/public/base/model_type.h"
11 #include "sync/internal_api/public/util/syncer_error.h"
12 #include "sync/protocol/sync.pb.h"
13 
14 namespace sync_pb {
15 class DebugInfo;
16 }  // namespace sync_pb
17 
18 namespace syncer {
19 
20 namespace sessions {
21 class DebugInfoGetter;
22 class NudgeTracker;
23 class StatusController;
24 class SyncSession;
25 }  // namespace sessions
26 
27 namespace download {
28 
29 // This function executes a single GetUpdate request and stores the response in
30 // the session's StatusController.  It constructs the type of request used to
31 // keep types in sync when in normal mode.
32 SYNC_EXPORT_PRIVATE void BuildNormalDownloadUpdates(
33     sessions::SyncSession* session,
34     bool create_mobile_bookmarks_folder,
35     ModelTypeSet request_types,
36     const sessions::NudgeTracker& nudge_tracker,
37     sync_pb::ClientToServerMessage* client_to_server_message);
38 
39 // Helper function.  Defined here for testing.
40 SYNC_EXPORT_PRIVATE void BuildNormalDownloadUpdatesImpl(
41     ModelTypeSet proto_request_types,
42     UpdateHandlerMap* update_handler_map,
43     const sessions::NudgeTracker& nudge_tracker,
44     sync_pb::GetUpdatesMessage* get_updates);
45 
46 // This function executes a single GetUpdate request and stores the response in
47 // the session's StatusController.  It constructs the type of request used to
48 // initialize a type for the first time.
49 SYNC_EXPORT_PRIVATE void BuildDownloadUpdatesForConfigure(
50     sessions::SyncSession* session,
51     bool create_mobile_bookmarks_folder,
52     sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source,
53     ModelTypeSet request_types,
54     sync_pb::ClientToServerMessage* client_to_server_message);
55 
56 // Helper function.  Defined here for testing.
57 SYNC_EXPORT_PRIVATE void BuildDownloadUpdatesForConfigureImpl(
58     ModelTypeSet proto_request_types,
59     UpdateHandlerMap* update_handler_map,
60     sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source,
61     sync_pb::GetUpdatesMessage* get_updates);
62 
63 // This function executes a single GetUpdate request and stores the response in
64 // the session's status controller.  It constructs the type of request used for
65 // periodic polling.
66 SYNC_EXPORT_PRIVATE void BuildDownloadUpdatesForPoll(
67     sessions::SyncSession* session,
68     bool create_mobile_bookmarks_folder,
69     ModelTypeSet request_types,
70     sync_pb::ClientToServerMessage* client_to_server_message);
71 
72 // Helper function.  Defined here for testing.
73 SYNC_EXPORT_PRIVATE void BuildDownloadUpdatesForPollImpl(
74     ModelTypeSet proto_request_types,
75     UpdateHandlerMap* update_handler_map,
76     sync_pb::GetUpdatesMessage* get_updates);
77 
78 // Sends the specified message to the server and stores the response in a member
79 // of the |session|'s StatusController.
80 SYNC_EXPORT_PRIVATE SyncerError
81     ExecuteDownloadUpdates(ModelTypeSet request_types,
82                            sessions::SyncSession* session,
83                            sync_pb::ClientToServerMessage* msg);
84 
85 // Helper function for processing responses from the server.
86 // Defined here for testing.
87 SYNC_EXPORT_PRIVATE SyncerError ProcessResponse(
88     const sync_pb::GetUpdatesResponse& gu_response,
89     ModelTypeSet proto_request_types,
90     UpdateHandlerMap* handler_map,
91     sessions::StatusController* status);
92 
93 // Helper function to copy client debug info from debug_info_getter to
94 // debug_info.  Defined here for testing.
95 SYNC_EXPORT_PRIVATE void CopyClientDebugInfo(
96     sessions::DebugInfoGetter* debug_info_getter,
97     sync_pb::DebugInfo* debug_info);
98 
99 }  // namespace download
100 
101 }  // namespace syncer
102 
103 #endif  // SYNC_ENGINE_DOWNLOAD_H_
104