Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: chrome/browser/sync/engine/download_updates_command.cc

Issue 9036003: Avoid useless SYNC_CYCLE_CONTINUATION sync cycle (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "chrome/browser/sync/engine/download_updates_command.h" 5 #include "chrome/browser/sync/engine/download_updates_command.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "chrome/browser/sync/engine/syncer.h" 10 #include "chrome/browser/sync/engine/syncer.h"
(...skipping 12 matching lines...) Expand all
23 using sessions::SyncSession; 23 using sessions::SyncSession;
24 using std::string; 24 using std::string;
25 using syncable::FIRST_REAL_MODEL_TYPE; 25 using syncable::FIRST_REAL_MODEL_TYPE;
26 using syncable::MODEL_TYPE_COUNT; 26 using syncable::MODEL_TYPE_COUNT;
27 using syncable::ModelTypeSet; 27 using syncable::ModelTypeSet;
28 using syncable::ModelTypeSetToString; 28 using syncable::ModelTypeSetToString;
29 29
30 DownloadUpdatesCommand::DownloadUpdatesCommand() {} 30 DownloadUpdatesCommand::DownloadUpdatesCommand() {}
31 DownloadUpdatesCommand::~DownloadUpdatesCommand() {} 31 DownloadUpdatesCommand::~DownloadUpdatesCommand() {}
32 32
33 void DownloadUpdatesCommand::ExecuteImpl(SyncSession* session) { 33 SyncerError DownloadUpdatesCommand::ExecuteImpl(SyncSession* session) {
34 ClientToServerMessage client_to_server_message; 34 ClientToServerMessage client_to_server_message;
35 ClientToServerResponse update_response; 35 ClientToServerResponse update_response;
36 36
37 client_to_server_message.set_share(session->context()->account_name()); 37 client_to_server_message.set_share(session->context()->account_name());
38 client_to_server_message.set_message_contents( 38 client_to_server_message.set_message_contents(
39 ClientToServerMessage::GET_UPDATES); 39 ClientToServerMessage::GET_UPDATES);
40 GetUpdatesMessage* get_updates = 40 GetUpdatesMessage* get_updates =
41 client_to_server_message.mutable_get_updates(); 41 client_to_server_message.mutable_get_updates();
42 if (CommandLine::ForCurrentProcess()->HasSwitch( 42 if (CommandLine::ForCurrentProcess()->HasSwitch(
43 switches::kCreateMobileBookmarksFolder)) { 43 switches::kCreateMobileBookmarksFolder)) {
44 get_updates->set_include_syncable_bookmarks(true); 44 get_updates->set_include_syncable_bookmarks(true);
45 } 45 }
46 46
47 ScopedDirLookup dir(session->context()->directory_manager(), 47 ScopedDirLookup dir(session->context()->directory_manager(),
48 session->context()->account_name()); 48 session->context()->account_name());
49 if (!dir.good()) { 49 if (!dir.good()) {
50 LOG(ERROR) << "Scoped dir lookup failed!"; 50 LOG(ERROR) << "Scoped dir lookup failed!";
51 return; 51 return DIRECTORY_LOOKUP_FAILED;
52 } 52 }
53 53
54 // Request updates for all enabled types. 54 // Request updates for all enabled types.
55 const ModelTypeSet enabled_types = 55 const ModelTypeSet enabled_types =
56 GetRoutingInfoTypes(session->routing_info()); 56 GetRoutingInfoTypes(session->routing_info());
57 DVLOG(1) << "Getting updates for types " 57 DVLOG(1) << "Getting updates for types "
58 << ModelTypeSetToString(enabled_types); 58 << ModelTypeSetToString(enabled_types);
59 DCHECK(!enabled_types.Empty()); 59 DCHECK(!enabled_types.Empty());
60 60
61 const syncable::ModelTypePayloadMap& type_payload_map = 61 const syncable::ModelTypePayloadMap& type_payload_map =
(...skipping 22 matching lines...) Expand all
84 session->TestAndSetSource().updates_source); 84 session->TestAndSetSource().updates_source);
85 get_updates->mutable_caller_info()->set_notifications_enabled( 85 get_updates->mutable_caller_info()->set_notifications_enabled(
86 session->context()->notifications_enabled()); 86 session->context()->notifications_enabled());
87 87
88 SyncerProtoUtil::AddRequestBirthday(dir, &client_to_server_message); 88 SyncerProtoUtil::AddRequestBirthday(dir, &client_to_server_message);
89 89
90 DebugInfo* debug_info = client_to_server_message.mutable_debug_info(); 90 DebugInfo* debug_info = client_to_server_message.mutable_debug_info();
91 91
92 AppendClientDebugInfoIfNeeded(session, debug_info); 92 AppendClientDebugInfoIfNeeded(session, debug_info);
93 93
94 bool ok = SyncerProtoUtil::PostClientToServerMessage( 94 SyncerError result = SyncerProtoUtil::PostClientToServerMessage(
95 client_to_server_message, 95 client_to_server_message,
96 &update_response, 96 &update_response,
97 session); 97 session);
98 98
99 DVLOG(2) << SyncerProtoUtil::ClientToServerResponseDebugString( 99 DVLOG(2) << SyncerProtoUtil::ClientToServerResponseDebugString(
100 update_response); 100 update_response);
101 101
102 StatusController* status = session->mutable_status_controller(); 102 StatusController* status = session->mutable_status_controller();
103 status->set_updates_request_types(enabled_types); 103 status->set_updates_request_types(enabled_types);
104 if (!ok) { 104 if (result != NO_ERROR) {
105 status->increment_num_consecutive_errors(); 105 status->increment_num_consecutive_errors();
106 status->mutable_updates_response()->Clear(); 106 status->mutable_updates_response()->Clear();
107 LOG(ERROR) << "PostClientToServerMessage() failed during GetUpdates"; 107 LOG(ERROR) << "PostClientToServerMessage() failed during GetUpdates";
108 return; 108 return result;
109 } 109 }
110 110
111 status->mutable_updates_response()->CopyFrom(update_response); 111 status->mutable_updates_response()->CopyFrom(update_response);
112 112
113 DVLOG(1) << "GetUpdates " 113 DVLOG(1) << "GetUpdates "
114 << " returned " << update_response.get_updates().entries_size() 114 << " returned " << update_response.get_updates().entries_size()
115 << " updates and indicated " 115 << " updates and indicated "
116 << update_response.get_updates().changes_remaining() 116 << update_response.get_updates().changes_remaining()
117 << " updates left on server."; 117 << " updates left on server.";
118 return result;
118 } 119 }
119 120
120 void DownloadUpdatesCommand::AppendClientDebugInfoIfNeeded( 121 void DownloadUpdatesCommand::AppendClientDebugInfoIfNeeded(
121 sessions::SyncSession* session, 122 sessions::SyncSession* session,
122 DebugInfo* debug_info) { 123 DebugInfo* debug_info) {
123 // We want to send the debug info only once per sync cycle. Check if it has 124 // We want to send the debug info only once per sync cycle. Check if it has
124 // already been sent. 125 // already been sent.
125 if (!session->status_controller().debug_info_sent()) { 126 if (!session->status_controller().debug_info_sent()) {
126 DVLOG(1) << "Sending client debug info ..."; 127 DVLOG(1) << "Sending client debug info ...";
127 // could be null in some unit tests. 128 // could be null in some unit tests.
128 if (session->context()->debug_info_getter()) { 129 if (session->context()->debug_info_getter()) {
129 session->context()->debug_info_getter()->GetAndClearDebugInfo( 130 session->context()->debug_info_getter()->GetAndClearDebugInfo(
130 debug_info); 131 debug_info);
131 } 132 }
132 session->mutable_status_controller()->set_debug_info_sent(); 133 session->mutable_status_controller()->set_debug_info_sent();
133 } 134 }
134 } 135 }
135 136
136 137
137 } // namespace browser_sync 138 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/download_updates_command.h ('k') | chrome/browser/sync/engine/get_commit_ids_command.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698