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

Side by Side Diff: chrome/browser/sync/internal_api/write_node.cc

Issue 7970018: sync: we can't lookup empty client tag nodes, so don't allow creating them (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 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
« no previous file with comments | « chrome/browser/sync/internal_api/syncapi_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/internal_api/write_node.h" 5 #include "chrome/browser/sync/internal_api/write_node.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/sync/engine/nigori_util.h" 10 #include "chrome/browser/sync/engine/nigori_util.h"
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 // Create a new node with default properties and a client defined unique tag, 387 // Create a new node with default properties and a client defined unique tag,
388 // and bind this WriteNode to it. 388 // and bind this WriteNode to it.
389 // Return true on success. If the tag exists in the database, then 389 // Return true on success. If the tag exists in the database, then
390 // we will attempt to undelete the node. 390 // we will attempt to undelete the node.
391 // TODO(chron): Code datatype into hash tag. 391 // TODO(chron): Code datatype into hash tag.
392 // TODO(chron): Is model type ever lost? 392 // TODO(chron): Is model type ever lost?
393 bool WriteNode::InitUniqueByCreation(syncable::ModelType model_type, 393 bool WriteNode::InitUniqueByCreation(syncable::ModelType model_type,
394 const BaseNode& parent, 394 const BaseNode& parent,
395 const std::string& tag) { 395 const std::string& tag) {
396 DCHECK(!entry_) << "Init called twice"; 396 DCHECK(!entry_) << "Init called twice";
397 if (tag.empty()) {
398 LOG(WARNING) << "InitUniqueByCreation failed due to empty tag.";
399 return false;
400 }
397 401
398 const std::string hash = GenerateSyncableHash(model_type, tag); 402 const std::string hash = GenerateSyncableHash(model_type, tag);
399 403
400 syncable::Id parent_id = parent.GetEntry()->Get(syncable::ID); 404 syncable::Id parent_id = parent.GetEntry()->Get(syncable::ID);
401 405
402 // Start out with a dummy name. We expect 406 // Start out with a dummy name. We expect
403 // the caller to set a meaningful name after creation. 407 // the caller to set a meaningful name after creation.
404 string dummy(kDefaultNameForNewNodes); 408 string dummy(kDefaultNameForNewNodes);
405 409
406 // Check if we have this locally and need to undelete it. 410 // Check if we have this locally and need to undelete it.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 sync_pb::BookmarkSpecifics new_value = GetBookmarkSpecifics(); 521 sync_pb::BookmarkSpecifics new_value = GetBookmarkSpecifics();
518 new_value.set_favicon(bytes.empty() ? NULL : &bytes[0], bytes.size()); 522 new_value.set_favicon(bytes.empty() ? NULL : &bytes[0], bytes.size());
519 SetBookmarkSpecifics(new_value); 523 SetBookmarkSpecifics(new_value);
520 } 524 }
521 525
522 void WriteNode::MarkForSyncing() { 526 void WriteNode::MarkForSyncing() {
523 syncable::MarkForSyncing(entry_); 527 syncable::MarkForSyncing(entry_);
524 } 528 }
525 529
526 } // namespace sync_api 530 } // namespace sync_api
OLDNEW
« no previous file with comments | « chrome/browser/sync/internal_api/syncapi_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698