OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "chrome/browser/sync/engine/syncer.h" | 9 #include "chrome/browser/sync/engine/syncer.h" |
10 #include "chrome/browser/sync/engine/syncer_proto_util.h" | 10 #include "chrome/browser/sync/engine/syncer_proto_util.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 ClientToServerMessage::GET_UPDATES); | 32 ClientToServerMessage::GET_UPDATES); |
33 GetUpdatesMessage* get_updates = | 33 GetUpdatesMessage* get_updates = |
34 client_to_server_message.mutable_get_updates(); | 34 client_to_server_message.mutable_get_updates(); |
35 | 35 |
36 ScopedDirLookup dir(session->context()->directory_manager(), | 36 ScopedDirLookup dir(session->context()->directory_manager(), |
37 session->context()->account_name()); | 37 session->context()->account_name()); |
38 if (!dir.good()) { | 38 if (!dir.good()) { |
39 LOG(ERROR) << "Scoped dir lookup failed!"; | 39 LOG(ERROR) << "Scoped dir lookup failed!"; |
40 return; | 40 return; |
41 } | 41 } |
42 LOG(INFO) << "Getting updates from ts " << dir->last_sync_timestamp(); | 42 LOG(INFO) << "Getting updates from ts " << dir->last_download_timestamp(); |
43 get_updates->set_from_timestamp(dir->last_sync_timestamp()); | 43 get_updates->set_from_timestamp(dir->last_download_timestamp()); |
44 | 44 |
45 // We want folders for our associated types, always. If we were to set | 45 // We want folders for our associated types, always. If we were to set |
46 // this to false, the server would send just the non-container items | 46 // this to false, the server would send just the non-container items |
47 // (e.g. Bookmark URLs but not their containing folders). | 47 // (e.g. Bookmark URLs but not their containing folders). |
48 get_updates->set_fetch_folders(true); | 48 get_updates->set_fetch_folders(true); |
49 | 49 |
50 // Set the requested_types protobuf field so that we fetch all enabled types. | 50 // Set the requested_types protobuf field so that we fetch all enabled types. |
51 SetRequestedTypes(session->routing_info(), | 51 SetRequestedTypes(session->routing_info(), |
52 get_updates->mutable_requested_types()); | 52 get_updates->mutable_requested_types()); |
53 | 53 |
54 // Set GetUpdatesMessage.GetUpdatesCallerInfo information. | 54 // Set GetUpdatesMessage.GetUpdatesCallerInfo information. |
55 get_updates->mutable_caller_info()->set_source(session->TestAndSetSource()); | 55 get_updates->mutable_caller_info()->set_source(session->TestAndSetSource()); |
56 get_updates->mutable_caller_info()->set_notifications_enabled( | 56 get_updates->mutable_caller_info()->set_notifications_enabled( |
57 session->context()->notifications_enabled()); | 57 session->context()->notifications_enabled()); |
58 | 58 |
59 bool ok = SyncerProtoUtil::PostClientToServerMessage( | 59 bool ok = SyncerProtoUtil::PostClientToServerMessage( |
60 &client_to_server_message, | 60 &client_to_server_message, |
61 &update_response, | 61 &update_response, |
62 session); | 62 session); |
63 | 63 |
64 DLOG(INFO) << SyncerProtoUtil::ClientToServerResponseDebugString( | 64 DLOG(INFO) << SyncerProtoUtil::ClientToServerResponseDebugString( |
65 update_response); | 65 update_response); |
66 | 66 |
67 StatusController* status = session->status_controller(); | 67 StatusController* status = session->status_controller(); |
68 if (!ok) { | 68 if (!ok) { |
69 status->increment_num_consecutive_errors(); | 69 status->increment_num_consecutive_errors(); |
70 LOG(ERROR) << "PostClientToServerMessage() failed"; | 70 status->mutable_updates_response()->Clear(); |
| 71 LOG(ERROR) << "PostClientToServerMessage() failed during GetUpdates"; |
71 return; | 72 return; |
72 } | 73 } |
73 status->mutable_updates_response()->CopyFrom(update_response); | 74 status->mutable_updates_response()->CopyFrom(update_response); |
| 75 |
| 76 LOG(INFO) << "GetUpdates from ts " << get_updates->from_timestamp() |
| 77 << " returned " << update_response.get_updates().entries_size() |
| 78 << " updates."; |
74 } | 79 } |
75 | 80 |
76 void DownloadUpdatesCommand::SetRequestedTypes( | 81 void DownloadUpdatesCommand::SetRequestedTypes( |
77 const ModelSafeRoutingInfo& routing_info, | 82 const ModelSafeRoutingInfo& routing_info, |
78 sync_pb::EntitySpecifics* types) { | 83 sync_pb::EntitySpecifics* types) { |
79 // The datatypes which should be synced are dictated by the value of the | 84 // The datatypes which should be synced are dictated by the value of the |
80 // ModelSafeRoutingInfo. If a datatype is in the routing info map, it | 85 // ModelSafeRoutingInfo. If a datatype is in the routing info map, it |
81 // should be synced (even if it's GROUP_PASSIVE). | 86 // should be synced (even if it's GROUP_PASSIVE). |
82 int requested_type_count = 0; | 87 int requested_type_count = 0; |
83 for (ModelSafeRoutingInfo::const_iterator i = routing_info.begin(); | 88 for (ModelSafeRoutingInfo::const_iterator i = routing_info.begin(); |
84 i != routing_info.end(); | 89 i != routing_info.end(); |
85 ++i) { | 90 ++i) { |
86 requested_type_count++; | 91 requested_type_count++; |
87 syncable::AddDefaultExtensionValue(i->first, types); | 92 syncable::AddDefaultExtensionValue(i->first, types); |
88 } | 93 } |
89 DCHECK_LT(0, requested_type_count) << "Doing GetUpdates with empty filter."; | 94 DCHECK_LT(0, requested_type_count) << "Doing GetUpdates with empty filter."; |
90 } | 95 } |
91 | 96 |
92 } // namespace browser_sync | 97 } // namespace browser_sync |
OLD | NEW |