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

Side by Side Diff: sync/syncable/model_neutral_mutable_entry.cc

Issue 867793003: Remove dependency on server generated type root folders (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added extra comment about existing type root folder. Created 5 years, 10 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
« no previous file with comments | « sync/syncable/model_neutral_mutable_entry.h ('k') | sync/syncable/model_type.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/syncable/model_neutral_mutable_entry.h" 5 #include "sync/syncable/model_neutral_mutable_entry.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "sync/internal_api/public/base/unique_position.h" 9 #include "sync/internal_api/public/base/unique_position.h"
10 #include "sync/syncable/directory.h" 10 #include "sync/syncable/directory.h"
(...skipping 26 matching lines...) Expand all
37 // We match the database defaults here 37 // We match the database defaults here
38 kernel->put(BASE_VERSION, CHANGES_VERSION); 38 kernel->put(BASE_VERSION, CHANGES_VERSION);
39 if (!trans->directory()->InsertEntry(trans, kernel.get())) { 39 if (!trans->directory()->InsertEntry(trans, kernel.get())) {
40 return; // Failed inserting. 40 return; // Failed inserting.
41 } 41 }
42 trans->TrackChangesTo(kernel.get()); 42 trans->TrackChangesTo(kernel.get());
43 43
44 kernel_ = kernel.release(); 44 kernel_ = kernel.release();
45 } 45 }
46 46
47 ModelNeutralMutableEntry::ModelNeutralMutableEntry(BaseWriteTransaction* trans,
48 CreateNewTypeRoot,
49 ModelType type)
50 : Entry(trans), base_write_transaction_(trans) {
51 DCHECK(!IsTypeWithServerGeneratedRoot(type));
52 Entry same_type_root(trans, GET_TYPE_ROOT, type);
53 kernel_ = NULL;
54 if (same_type_root.good()) {
55 return; // already have a type root for the given type
56 }
57
58 scoped_ptr<EntryKernel> kernel(new EntryKernel());
59
60 sync_pb::EntitySpecifics specifics;
61 AddDefaultFieldValue(type, &specifics);
62 kernel->put(SPECIFICS, specifics);
63
64 kernel->put(ID,
65 syncable::Id::CreateFromClientString(ModelTypeToString(type)));
66 kernel->put(META_HANDLE, trans->directory()->NextMetahandle());
67 kernel->put(PARENT_ID, syncable::Id::GetRoot());
68 kernel->put(BASE_VERSION, CHANGES_VERSION);
69 kernel->put(NON_UNIQUE_NAME, ModelTypeToString(type));
70 kernel->put(IS_DIR, true);
71
72 kernel->mark_dirty(&trans->directory()->kernel_->dirty_metahandles);
73
74 if (!trans->directory()->InsertEntry(trans, kernel.get())) {
75 return; // Failed inserting.
76 }
77
78 trans->TrackChangesTo(kernel.get());
79
80 kernel_ = kernel.release();
81 }
82
47 ModelNeutralMutableEntry::ModelNeutralMutableEntry( 83 ModelNeutralMutableEntry::ModelNeutralMutableEntry(
48 BaseWriteTransaction* trans, GetById, const Id& id) 84 BaseWriteTransaction* trans, GetById, const Id& id)
49 : Entry(trans, GET_BY_ID, id), base_write_transaction_(trans) { 85 : Entry(trans, GET_BY_ID, id), base_write_transaction_(trans) {
50 } 86 }
51 87
52 ModelNeutralMutableEntry::ModelNeutralMutableEntry( 88 ModelNeutralMutableEntry::ModelNeutralMutableEntry(
53 BaseWriteTransaction* trans, GetByHandle, int64 metahandle) 89 BaseWriteTransaction* trans, GetByHandle, int64 metahandle)
54 : Entry(trans, GET_BY_HANDLE, metahandle), base_write_transaction_(trans) { 90 : Entry(trans, GET_BY_HANDLE, metahandle), base_write_transaction_(trans) {
55 } 91 }
56 92
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 ModelNeutralMutableEntry::ModelNeutralMutableEntry(BaseWriteTransaction* trans) 420 ModelNeutralMutableEntry::ModelNeutralMutableEntry(BaseWriteTransaction* trans)
385 : Entry(trans), base_write_transaction_(trans) {} 421 : Entry(trans), base_write_transaction_(trans) {}
386 422
387 MetahandleSet* ModelNeutralMutableEntry::GetDirtyIndexHelper() { 423 MetahandleSet* ModelNeutralMutableEntry::GetDirtyIndexHelper() {
388 return &dir()->kernel_->dirty_metahandles; 424 return &dir()->kernel_->dirty_metahandles;
389 } 425 }
390 426
391 } // namespace syncable 427 } // namespace syncable
392 428
393 } // namespace syncer 429 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/syncable/model_neutral_mutable_entry.h ('k') | sync/syncable/model_type.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698