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

Side by Side Diff: chrome/browser/sync/engine/build_commit_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/build_commit_command.h" 5 #include "chrome/browser/sync/engine/build_commit_command.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
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_util.h" 13 #include "chrome/browser/sync/engine/syncer_util.h"
14 #include "chrome/browser/sync/engine/syncproto.h" 14 #include "chrome/browser/sync/engine/syncproto.h"
15 #include "chrome/browser/sync/syncable/syncable.h" 15 #include "chrome/browser/sync/syncable/syncable.h"
16 #include "chrome/browser/sync/syncable/syncable_changes_version.h" 16 #include "chrome/browser/sync/syncable/syncable_changes_version.h"
17 #include "chrome/browser/sync/util/sync_types.h" 17 #include "chrome/browser/sync/util/sync_types.h"
18 18
19 using std::set; 19 using std::set;
20 using std::string; 20 using std::string;
21 using std::vector; 21 using std::vector;
22 using syncable::ExtendedAttribute; 22 using syncable::ExtendedAttribute;
23 using syncable::Id; 23 using syncable::Id;
24 using syncable::MutableEntry; 24 using syncable::MutableEntry;
25 using syncable::Name;
26 25
27 namespace browser_sync { 26 namespace browser_sync {
28 27
29 BuildCommitCommand::BuildCommitCommand() {} 28 BuildCommitCommand::BuildCommitCommand() {}
30 BuildCommitCommand::~BuildCommitCommand() {} 29 BuildCommitCommand::~BuildCommitCommand() {}
31 30
32 void BuildCommitCommand::AddExtensionsActivityToMessage( 31 void BuildCommitCommand::AddExtensionsActivityToMessage(
33 SyncerSession* session, CommitMessage* message) { 32 SyncerSession* session, CommitMessage* message) {
34 const ExtensionsActivityMonitor::Records& records = 33 const ExtensionsActivityMonitor::Records& records =
35 session->extensions_activity(); 34 session->extensions_activity();
(...skipping 23 matching lines...) Expand all
59 SyncEntity* sync_entry = 58 SyncEntity* sync_entry =
60 static_cast<SyncEntity*>(commit_message->add_entries()); 59 static_cast<SyncEntity*>(commit_message->add_entries());
61 sync_entry->set_id(id); 60 sync_entry->set_id(id);
62 MutableEntry meta_entry(session->write_transaction(), 61 MutableEntry meta_entry(session->write_transaction(),
63 syncable::GET_BY_ID, 62 syncable::GET_BY_ID,
64 id); 63 id);
65 CHECK(meta_entry.good()); 64 CHECK(meta_entry.good());
66 // This is the only change we make to the entry in this function. 65 // This is the only change we make to the entry in this function.
67 meta_entry.Put(syncable::SYNCING, true); 66 meta_entry.Put(syncable::SYNCING, true);
68 67
69 Name name = meta_entry.GetName(); 68 PathString name = meta_entry.Get(syncable::NON_UNIQUE_NAME);
70 CHECK(!name.value().empty()); // Make sure this isn't an update. 69 CHECK(!name.empty()); // Make sure this isn't an update.
71 sync_entry->set_name(name.value()); 70 sync_entry->set_name(name);
72 // Set the non_unique_name if we have one. If we do, the server ignores 71
72 // Set the non_unique_name. If we do, the server ignores
73 // the |name| value (using |non_unique_name| instead), and will return 73 // the |name| value (using |non_unique_name| instead), and will return
74 // in the CommitResponse a unique name if one is generated. Even though 74 // in the CommitResponse a unique name if one is generated.
75 // we could get away with only sending |name|, we send both because it 75 // We send both because it may aid in logging.
76 // may aid in logging. 76 sync_entry->set_non_unique_name(name);
77 if (name.value() != name.non_unique_value()) { 77
78 sync_entry->set_non_unique_name(name.non_unique_value());
79 }
80 // Deleted items with negative parent ids can be a problem so we set the 78 // Deleted items with negative parent ids can be a problem so we set the
81 // parent to 0. (TODO(sync): Still true in protocol?). 79 // parent to 0. (TODO(sync): Still true in protocol?).
82 Id new_parent_id; 80 Id new_parent_id;
83 if (meta_entry.Get(syncable::IS_DEL) && 81 if (meta_entry.Get(syncable::IS_DEL) &&
84 !meta_entry.Get(syncable::PARENT_ID).ServerKnows()) { 82 !meta_entry.Get(syncable::PARENT_ID).ServerKnows()) {
85 new_parent_id = session->write_transaction()->root_id(); 83 new_parent_id = session->write_transaction()->root_id();
86 } else { 84 } else {
87 new_parent_id = meta_entry.Get(syncable::PARENT_ID); 85 new_parent_id = meta_entry.Get(syncable::PARENT_ID);
88 } 86 }
89 sync_entry->set_parent_id(new_parent_id); 87 sync_entry->set_parent_id(new_parent_id);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 SyncerProtoUtil::CopyBlobIntoProtoBytes( 144 SyncerProtoUtil::CopyBlobIntoProtoBytes(
147 meta_entry.Get(syncable::BOOKMARK_FAVICON), 145 meta_entry.Get(syncable::BOOKMARK_FAVICON),
148 bookmark->mutable_bookmark_favicon()); 146 bookmark->mutable_bookmark_favicon());
149 } 147 }
150 } 148 }
151 } 149 }
152 session->set_commit_message(message); 150 session->set_commit_message(message);
153 } 151 }
154 152
155 } // namespace browser_sync 153 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698