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

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

Issue 371029: Remove unique naming. (Closed)
Patch Set: Ready and about to go in! 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
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/process_commit_response_command.h" 5 #include "chrome/browser/sync/engine/process_commit_response_command.h"
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "chrome/browser/sync/engine/syncer_proto_util.h" 11 #include "chrome/browser/sync/engine/syncer_proto_util.h"
12 #include "chrome/browser/sync/engine/syncer_session.h" 12 #include "chrome/browser/sync/engine/syncer_session.h"
13 #include "chrome/browser/sync/engine/syncer_status.h" 13 #include "chrome/browser/sync/engine/syncer_status.h"
14 #include "chrome/browser/sync/engine/syncer_util.h" 14 #include "chrome/browser/sync/engine/syncer_util.h"
15 #include "chrome/browser/sync/engine/syncproto.h" 15 #include "chrome/browser/sync/engine/syncproto.h"
16 #include "chrome/browser/sync/syncable/directory_manager.h" 16 #include "chrome/browser/sync/syncable/directory_manager.h"
17 #include "chrome/browser/sync/syncable/syncable.h" 17 #include "chrome/browser/sync/syncable/syncable.h"
18 18
19 using syncable::ScopedDirLookup; 19 using syncable::ScopedDirLookup;
20 using syncable::WriteTransaction; 20 using syncable::WriteTransaction;
21 using syncable::MutableEntry; 21 using syncable::MutableEntry;
22 using syncable::Entry; 22 using syncable::Entry;
23 using syncable::Name;
24 using syncable::SyncName;
25 using syncable::DBName;
26 23
27 using std::set; 24 using std::set;
28 using std::vector; 25 using std::vector;
29 26
30 using syncable::BASE_VERSION; 27 using syncable::BASE_VERSION;
31 using syncable::GET_BY_ID; 28 using syncable::GET_BY_ID;
32 using syncable::ID; 29 using syncable::ID;
33 using syncable::IS_DEL; 30 using syncable::IS_DEL;
34 using syncable::IS_DIR; 31 using syncable::IS_DIR;
35 using syncable::IS_UNAPPLIED_UPDATE; 32 using syncable::IS_UNAPPLIED_UPDATE;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 ProcessSingleCommitResponse(&trans, cr.entryresponse(i), 114 ProcessSingleCommitResponse(&trans, cr.entryresponse(i),
118 commit_ids[i], 115 commit_ids[i],
119 &conflicting_new_folder_ids, 116 &conflicting_new_folder_ids,
120 &deleted_folders, session); 117 &deleted_folders, session);
121 switch (response_type) { 118 switch (response_type) {
122 case CommitResponse::INVALID_MESSAGE: 119 case CommitResponse::INVALID_MESSAGE:
123 ++error_commits; 120 ++error_commits;
124 break; 121 break;
125 case CommitResponse::CONFLICT: 122 case CommitResponse::CONFLICT:
126 ++conflicting_commits; 123 ++conflicting_commits;
124 // This is important to activate conflict resolution.
127 session->AddCommitConflict(commit_ids[i]); 125 session->AddCommitConflict(commit_ids[i]);
128 break; 126 break;
129 case CommitResponse::SUCCESS: 127 case CommitResponse::SUCCESS:
130 // TODO(sync): worry about sync_rate_ rate calc? 128 // TODO(sync): worry about sync_rate_ rate calc?
131 ++successes; 129 ++successes;
132 status.increment_successful_commits(); 130 status.increment_successful_commits();
133 break; 131 break;
134 case CommitResponse::OVER_QUOTA: 132 case CommitResponse::OVER_QUOTA:
135 over_quota = true; 133 over_quota = true;
136 // We handle over quota like a retry, which is same as transient. 134 // We handle over quota like a retry, which is same as transient.
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 } 330 }
333 if (local_entry->Get(IS_DIR) && local_entry->Get(IS_DEL)) { 331 if (local_entry->Get(IS_DIR) && local_entry->Get(IS_DEL)) {
334 deleted_folders->insert(local_entry->Get(ID)); 332 deleted_folders->insert(local_entry->Get(ID));
335 } 333 }
336 } 334 }
337 335
338 void ProcessCommitResponseCommand::PerformCommitTimeNameAside( 336 void ProcessCommitResponseCommand::PerformCommitTimeNameAside(
339 syncable::WriteTransaction* trans, 337 syncable::WriteTransaction* trans,
340 const CommitResponse_EntryResponse& server_entry, 338 const CommitResponse_EntryResponse& server_entry,
341 syncable::MutableEntry* local_entry) { 339 syncable::MutableEntry* local_entry) {
342 Name old_name(local_entry->GetName()); 340 PathString old_name = local_entry->Get(syncable::NON_UNIQUE_NAME);
343 341 const string server_name =
344 // Ensure that we don't collide with an existing entry.
345 SyncName server_name =
346 SyncerProtoUtil::NameFromCommitEntryResponse(server_entry); 342 SyncerProtoUtil::NameFromCommitEntryResponse(server_entry);
347 343
348 LOG(INFO) << "Server provided committed name:" << server_name.value(); 344 if (!server_name.empty() && old_name != server_name) {
349 if (!server_name.value().empty() && 345 LOG(INFO) << "Server commit moved aside entry: " << old_name
350 static_cast<SyncName&>(old_name) != server_name) { 346 << " to new name " << server_name;
351 LOG(INFO) << "Server name differs from local name, attempting"
352 << " commit time name aside.";
353
354 DBName db_name(server_name.value());
355 db_name.MakeOSLegal();
356
357 // This is going to produce ~1 names instead of (Edited) names.
358 // Since this should be EXTREMELY rare, we do this for now.
359 db_name.MakeNoncollidingForEntry(trans, local_entry->Get(SERVER_PARENT_ID),
360 local_entry);
361
362 CHECK(!db_name.empty());
363
364 LOG(INFO) << "Server commit moved aside entry: " << old_name.db_value()
365 << " to new name " << db_name;
366
367 // Should be safe since we're in a "commit lock." 347 // Should be safe since we're in a "commit lock."
368 local_entry->PutName(Name::FromDBNameAndSyncName(db_name, server_name)); 348 local_entry->Put(syncable::NON_UNIQUE_NAME, server_name);
369 } 349 }
370 } 350 }
371 351
372 } // namespace browser_sync 352 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/get_commit_ids_command.h ('k') | chrome/browser/sync/engine/process_updates_command.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698