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

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

Issue 8637006: [Sync] Make syncer commands avoid posting tasks on threads with no work to do (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments, add tests Created 9 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) 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/process_commit_response_command.h" 5 #include "chrome/browser/sync/engine/process_commit_response_command.h"
6 6
7 #include <cstddef>
7 #include <set> 8 #include <set>
8 #include <string> 9 #include <string>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/basictypes.h" 12 #include "base/basictypes.h"
12 #include "base/location.h" 13 #include "base/location.h"
13 #include "chrome/browser/sync/engine/syncer_proto_util.h" 14 #include "chrome/browser/sync/engine/syncer_proto_util.h"
14 #include "chrome/browser/sync/engine/syncer_util.h" 15 #include "chrome/browser/sync/engine/syncer_util.h"
15 #include "chrome/browser/sync/engine/syncproto.h" 16 #include "chrome/browser/sync/engine/syncproto.h"
16 #include "chrome/browser/sync/sessions/sync_session.h" 17 #include "chrome/browser/sync/sessions/sync_session.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 void IncrementErrorCounters(StatusController* status) { 53 void IncrementErrorCounters(StatusController* status) {
53 status->increment_num_consecutive_errors(); 54 status->increment_num_consecutive_errors();
54 } 55 }
55 void ResetErrorCounters(StatusController* status) { 56 void ResetErrorCounters(StatusController* status) {
56 status->set_num_consecutive_errors(0); 57 status->set_num_consecutive_errors(0);
57 } 58 }
58 59
59 ProcessCommitResponseCommand::ProcessCommitResponseCommand() {} 60 ProcessCommitResponseCommand::ProcessCommitResponseCommand() {}
60 ProcessCommitResponseCommand::~ProcessCommitResponseCommand() {} 61 ProcessCommitResponseCommand::~ProcessCommitResponseCommand() {}
61 62
63 std::set<ModelSafeGroup> ProcessCommitResponseCommand::GetGroupsToChange(
64 const sessions::SyncSession& session) const {
65 std::set<ModelSafeGroup> groups_with_commits;
66 syncable::ScopedDirLookup dir(session.context()->directory_manager(),
67 session.context()->account_name());
68 if (!dir.good()) {
69 LOG(ERROR) << "Scoped dir lookup failed!";
70 return groups_with_commits;
71 }
72
73 syncable::ReadTransaction trans(FROM_HERE, dir);
74 const StatusController& status = session.status_controller();
75 for (size_t i = 0; i < status.commit_ids().size(); ++i) {
76 groups_with_commits.insert(
77 GetGroupForModelType(status.GetUnrestrictedCommitModelTypeAt(i),
78 session.routing_info()));
79 }
80
81 return groups_with_commits;
82 }
83
62 bool ProcessCommitResponseCommand::ModelNeutralExecuteImpl( 84 bool ProcessCommitResponseCommand::ModelNeutralExecuteImpl(
63 sessions::SyncSession* session) { 85 sessions::SyncSession* session) {
64 ScopedDirLookup dir(session->context()->directory_manager(), 86 ScopedDirLookup dir(session->context()->directory_manager(),
65 session->context()->account_name()); 87 session->context()->account_name());
66 if (!dir.good()) { 88 if (!dir.good()) {
67 LOG(ERROR) << "Scoped dir lookup failed!"; 89 LOG(ERROR) << "Scoped dir lookup failed!";
68 return false; 90 return false;
69 } 91 }
70 92
71 const StatusController& status = session->status_controller(); 93 const StatusController& status = session->status_controller();
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 // been recursively deleted. 507 // been recursively deleted.
486 // TODO(nick): Here, commit_message.deleted() would be more correct than 508 // TODO(nick): Here, commit_message.deleted() would be more correct than
487 // local_entry->Get(IS_DEL). For example, an item could be renamed, and then 509 // local_entry->Get(IS_DEL). For example, an item could be renamed, and then
488 // deleted during the commit of the rename. Unit test & fix. 510 // deleted during the commit of the rename. Unit test & fix.
489 if (local_entry->Get(IS_DIR) && local_entry->Get(IS_DEL)) { 511 if (local_entry->Get(IS_DIR) && local_entry->Get(IS_DEL)) {
490 deleted_folders->insert(local_entry->Get(ID)); 512 deleted_folders->insert(local_entry->Get(ID));
491 } 513 }
492 } 514 }
493 515
494 } // namespace browser_sync 516 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698