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

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

Issue 7190001: [Sync] Split DirectoryChangeListener for thread-safety (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix copyright Created 9 years, 6 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) 2006-2009 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/post_commit_message_command.h" 5 #include "chrome/browser/sync/engine/post_commit_message_command.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/tracked.h"
9 #include "chrome/browser/sync/engine/syncer_proto_util.h" 10 #include "chrome/browser/sync/engine/syncer_proto_util.h"
10 #include "chrome/browser/sync/engine/syncproto.h" 11 #include "chrome/browser/sync/engine/syncproto.h"
11 #include "chrome/browser/sync/sessions/sync_session.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 14
14 using std::vector; 15 using std::vector;
15 16
16 namespace browser_sync { 17 namespace browser_sync {
17 18
18 PostCommitMessageCommand::PostCommitMessageCommand() {} 19 PostCommitMessageCommand::PostCommitMessageCommand() {}
19 PostCommitMessageCommand::~PostCommitMessageCommand() {} 20 PostCommitMessageCommand::~PostCommitMessageCommand() {}
20 21
21 void PostCommitMessageCommand::ExecuteImpl(sessions::SyncSession* session) { 22 void PostCommitMessageCommand::ExecuteImpl(sessions::SyncSession* session) {
22 if (session->status_controller()->commit_ids().empty()) 23 if (session->status_controller()->commit_ids().empty())
23 return; // Nothing to commit. 24 return; // Nothing to commit.
24 ClientToServerResponse response; 25 ClientToServerResponse response;
25 syncable::ScopedDirLookup dir(session->context()->directory_manager(), 26 syncable::ScopedDirLookup dir(session->context()->directory_manager(),
26 session->context()->account_name()); 27 session->context()->account_name());
27 if (!dir.good()) 28 if (!dir.good())
28 return; 29 return;
29 sessions::StatusController* status = session->status_controller(); 30 sessions::StatusController* status = session->status_controller();
30 if (!SyncerProtoUtil::PostClientToServerMessage(status->commit_message(), 31 if (!SyncerProtoUtil::PostClientToServerMessage(status->commit_message(),
31 &response, session)) { 32 &response, session)) {
32 // None of our changes got through. Clear the SYNCING bit which was 33 // None of our changes got through. Clear the SYNCING bit which was
33 // set to true during BuildCommitCommand, and which may still be true. 34 // set to true during BuildCommitCommand, and which may still be true.
34 // Not to be confused with IS_UNSYNCED, this bit is used to detect local 35 // Not to be confused with IS_UNSYNCED, this bit is used to detect local
35 // changes to items that happen during the server Commit operation. 36 // changes to items that happen during the server Commit operation.
36 status->increment_num_consecutive_errors(); 37 status->increment_num_consecutive_errors();
37 syncable::WriteTransaction trans(dir, syncable::SYNCER, __FILE__, __LINE__); 38 syncable::WriteTransaction trans(dir, syncable::SYNCER, FROM_HERE);
38 const vector<syncable::Id>& commit_ids = status->commit_ids(); 39 const vector<syncable::Id>& commit_ids = status->commit_ids();
39 for (size_t i = 0; i < commit_ids.size(); i++) { 40 for (size_t i = 0; i < commit_ids.size(); i++) {
40 syncable::MutableEntry entry(&trans, syncable::GET_BY_ID, commit_ids[i]); 41 syncable::MutableEntry entry(&trans, syncable::GET_BY_ID, commit_ids[i]);
41 entry.Put(syncable::SYNCING, false); 42 entry.Put(syncable::SYNCING, false);
42 } 43 }
43 return; 44 return;
44 } else { 45 } else {
45 status->set_items_committed(); 46 status->set_items_committed();
46 } 47 }
47 status->mutable_commit_response()->CopyFrom(response); 48 status->mutable_commit_response()->CopyFrom(response);
48 } 49 }
49 50
50 } // namespace browser_sync 51 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/conflict_resolver.cc ('k') | chrome/browser/sync/engine/process_commit_response_command.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698