| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "sync/engine/directory_commit_contribution.h" | 5 #include "sync/engine/directory_commit_contribution.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "sync/internal_api/public/base/attachment_id_proto.h" | 8 #include "sync/internal_api/public/base/attachment_id_proto.h" |
| 9 #include "sync/sessions/status_controller.h" | 9 #include "sync/sessions/status_controller.h" |
| 10 #include "sync/syncable/entry.h" | 10 #include "sync/syncable/entry.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 } | 31 } |
| 32 | 32 |
| 33 void TearDown() override { dir_maker_.TearDown(); } | 33 void TearDown() override { dir_maker_.TearDown(); } |
| 34 | 34 |
| 35 protected: | 35 protected: |
| 36 int64 CreateUnsyncedItemWithAttachments( | 36 int64 CreateUnsyncedItemWithAttachments( |
| 37 syncable::WriteTransaction* trans, | 37 syncable::WriteTransaction* trans, |
| 38 ModelType type, | 38 ModelType type, |
| 39 const std::string& tag, | 39 const std::string& tag, |
| 40 const sync_pb::AttachmentMetadata& attachment_metadata) { | 40 const sync_pb::AttachmentMetadata& attachment_metadata) { |
| 41 syncable::Entry parent_entry(trans, syncable::GET_TYPE_ROOT, type); | 41 // For bookmarks specify the Bookmarks root folder as the parent; |
| 42 syncable::MutableEntry entry( | 42 // for other types leave the parent ID empty |
| 43 trans, | 43 syncable::Id parent_id; |
| 44 syncable::CREATE, | 44 if (type == BOOKMARKS) { |
| 45 type, | 45 syncable::Entry parent_entry(trans, syncable::GET_TYPE_ROOT, type); |
| 46 parent_entry.GetId(), | 46 parent_id = parent_entry.GetId(); |
| 47 tag); | 47 } |
| 48 |
| 49 syncable::MutableEntry entry(trans, syncable::CREATE, type, parent_id, tag); |
| 48 if (attachment_metadata.record_size() > 0) { | 50 if (attachment_metadata.record_size() > 0) { |
| 49 entry.PutAttachmentMetadata(attachment_metadata); | 51 entry.PutAttachmentMetadata(attachment_metadata); |
| 50 } | 52 } |
| 51 entry.PutIsUnsynced(true); | 53 entry.PutIsUnsynced(true); |
| 52 return entry.GetMetahandle(); | 54 return entry.GetMetahandle(); |
| 53 } | 55 } |
| 54 | 56 |
| 55 int64 CreateUnsyncedItem(syncable::WriteTransaction* trans, | 57 int64 CreateUnsyncedItem(syncable::WriteTransaction* trans, |
| 56 ModelType type, | 58 ModelType type, |
| 57 const std::string& tag) { | 59 const std::string& tag) { |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 syncable::Entry a3(&trans, syncable::GET_BY_HANDLE, art3_handle); | 495 syncable::Entry a3(&trans, syncable::GET_BY_HANDLE, art3_handle); |
| 494 EXPECT_FALSE(a3.GetId().ServerKnows()); | 496 EXPECT_FALSE(a3.GetId().ServerKnows()); |
| 495 EXPECT_FALSE(a3.GetSyncing()); | 497 EXPECT_FALSE(a3.GetSyncing()); |
| 496 EXPECT_EQ(0, a3.GetServerVersion()); | 498 EXPECT_EQ(0, a3.GetServerVersion()); |
| 497 } | 499 } |
| 498 | 500 |
| 499 art_cc->CleanUp(); | 501 art_cc->CleanUp(); |
| 500 } | 502 } |
| 501 | 503 |
| 502 } // namespace syncer | 504 } // namespace syncer |
| OLD | NEW |