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

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

Issue 386030: Relieve SyncerSession,SyncCycleState, SyncProcessState, SyncerSession, Syncer... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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) 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"
11 #include "chrome/browser/sync/engine/syncproto.h" 11 #include "chrome/browser/sync/engine/syncproto.h"
12 #include "chrome/browser/sync/sessions/sync_session.h"
12 #include "chrome/browser/sync/syncable/directory_manager.h" 13 #include "chrome/browser/sync/syncable/directory_manager.h"
13 #include "chrome/browser/sync/util/sync_types.h" 14 #include "chrome/browser/sync/util/sync_types.h"
14 15
15 using syncable::ScopedDirLookup; 16 using syncable::ScopedDirLookup;
16 17
17 namespace browser_sync { 18 namespace browser_sync {
18 19 using sessions::StatusController;
20 using sessions::SyncSession;
19 using std::string; 21 using std::string;
20 22
21 DownloadUpdatesCommand::DownloadUpdatesCommand() {} 23 DownloadUpdatesCommand::DownloadUpdatesCommand() {}
22 DownloadUpdatesCommand::~DownloadUpdatesCommand() {} 24 DownloadUpdatesCommand::~DownloadUpdatesCommand() {}
23 25
24 void DownloadUpdatesCommand::ExecuteImpl(SyncerSession* session) { 26 void DownloadUpdatesCommand::ExecuteImpl(SyncSession* session) {
25 ClientToServerMessage client_to_server_message; 27 ClientToServerMessage client_to_server_message;
26 ClientToServerResponse update_response; 28 ClientToServerResponse update_response;
27 29
28 client_to_server_message.set_share(session->account_name()); 30 client_to_server_message.set_share(session->context()->account_name());
29 client_to_server_message.set_message_contents( 31 client_to_server_message.set_message_contents(
30 ClientToServerMessage::GET_UPDATES); 32 ClientToServerMessage::GET_UPDATES);
31 GetUpdatesMessage* get_updates = 33 GetUpdatesMessage* get_updates =
32 client_to_server_message.mutable_get_updates(); 34 client_to_server_message.mutable_get_updates();
33 35
34 ScopedDirLookup dir(session->dirman(), session->account_name()); 36 ScopedDirLookup dir(session->context()->directory_manager(),
37 session->context()->account_name());
35 if (!dir.good()) { 38 if (!dir.good()) {
36 LOG(ERROR) << "Scoped dir lookup failed!"; 39 LOG(ERROR) << "Scoped dir lookup failed!";
37 return; 40 return;
38 } 41 }
39 LOG(INFO) << "Getting updates from ts " << dir->last_sync_timestamp(); 42 LOG(INFO) << "Getting updates from ts " << dir->last_sync_timestamp();
40 get_updates->set_from_timestamp(dir->last_sync_timestamp()); 43 get_updates->set_from_timestamp(dir->last_sync_timestamp());
41 44
42 // Set GetUpdatesMessage.GetUpdatesCallerInfo information. 45 // Set GetUpdatesMessage.GetUpdatesCallerInfo information.
43 get_updates->mutable_caller_info()->set_source(session->TestAndSetSource()); 46 get_updates->mutable_caller_info()->set_source(session->TestAndSetSource());
44 get_updates->mutable_caller_info()->set_notifications_enabled( 47 get_updates->mutable_caller_info()->set_notifications_enabled(
45 session->notifications_enabled()); 48 session->context()->notifications_enabled());
46 49
47 bool ok = SyncerProtoUtil::PostClientToServerMessage( 50 bool ok = SyncerProtoUtil::PostClientToServerMessage(
48 &client_to_server_message, 51 &client_to_server_message,
49 &update_response, 52 &update_response,
50 session); 53 session);
51 54
55 StatusController* status = session->status_controller();
52 if (!ok) { 56 if (!ok) {
53 SyncerStatus status(session); 57 status->increment_num_consecutive_problem_get_updates();
54 status.increment_consecutive_problem_get_updates(); 58 status->increment_num_consecutive_errors();
55 status.increment_consecutive_errors();
56 LOG(ERROR) << "PostClientToServerMessage() failed"; 59 LOG(ERROR) << "PostClientToServerMessage() failed";
57 return; 60 return;
58 } 61 }
59 session->set_update_response(update_response); 62 status->mutable_updates_response()->CopyFrom(update_response);
60 } 63 }
61 64
62 } // namespace browser_sync 65 } // 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