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

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

Issue 218623014: [Sync] Add context proto and directory support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update protos Created 6 years, 8 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
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/directory.h" 5 #include "sync/syncable/directory.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 int64 Directory::GetTransactionVersion(ModelType type) const { 785 int64 Directory::GetTransactionVersion(ModelType type) const {
786 kernel_->transaction_mutex.AssertAcquired(); 786 kernel_->transaction_mutex.AssertAcquired();
787 return kernel_->persisted_info.transaction_version[type]; 787 return kernel_->persisted_info.transaction_version[type];
788 } 788 }
789 789
790 void Directory::IncrementTransactionVersion(ModelType type) { 790 void Directory::IncrementTransactionVersion(ModelType type) {
791 kernel_->transaction_mutex.AssertAcquired(); 791 kernel_->transaction_mutex.AssertAcquired();
792 kernel_->persisted_info.transaction_version[type]++; 792 kernel_->persisted_info.transaction_version[type]++;
793 } 793 }
794 794
795 void Directory::GetDataTypeContext(ModelType type,
796 sync_pb::DataTypeContext* context) const {
797 kernel_->transaction_mutex.AssertAcquired();
maniscalco 2014/04/03 16:59:37 I noticed that in some methods we acquire a lock (
Nicolas Zea 2014/04/03 21:01:11 It has to do with whether it's expected that a tra
798 context->CopyFrom(kernel_->persisted_info.datatype_context[type]);
799 }
800
801 void Directory::SetDataTypeContext(
802 ModelType type,
803 const sync_pb::DataTypeContext& context) {
804 kernel_->transaction_mutex.AssertAcquired();
rlarocque 2014/04/03 17:36:55 What's up with this pattern? I thought the tradit
Nicolas Zea 2014/04/03 21:01:11 This is actually wrong, see above comment. I've up
805 kernel_->persisted_info.datatype_context[type].CopyFrom(context);
806 }
807
795 ModelTypeSet Directory::InitialSyncEndedTypes() { 808 ModelTypeSet Directory::InitialSyncEndedTypes() {
796 syncable::ReadTransaction trans(FROM_HERE, this); 809 syncable::ReadTransaction trans(FROM_HERE, this);
797 ModelTypeSet protocol_types = ProtocolTypes(); 810 ModelTypeSet protocol_types = ProtocolTypes();
798 ModelTypeSet initial_sync_ended_types; 811 ModelTypeSet initial_sync_ended_types;
799 for (ModelTypeSet::Iterator i = protocol_types.First(); i.Good(); i.Inc()) { 812 for (ModelTypeSet::Iterator i = protocol_types.First(); i.Good(); i.Inc()) {
800 if (InitialSyncEndedForType(&trans, i.Get())) { 813 if (InitialSyncEndedForType(&trans, i.Get())) {
801 initial_sync_ended_types.Put(i.Get()); 814 initial_sync_ended_types.Put(i.Get());
802 } 815 }
803 } 816 }
804 return initial_sync_ended_types; 817 return initial_sync_ended_types;
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 1311
1299 for (OrderedChildSet::const_iterator i = children->begin(); 1312 for (OrderedChildSet::const_iterator i = children->begin();
1300 i != children->end(); ++i) { 1313 i != children->end(); ++i) {
1301 DCHECK_EQ(parent_id, (*i)->ref(PARENT_ID)); 1314 DCHECK_EQ(parent_id, (*i)->ref(PARENT_ID));
1302 result->push_back((*i)->ref(META_HANDLE)); 1315 result->push_back((*i)->ref(META_HANDLE));
1303 } 1316 }
1304 } 1317 }
1305 1318
1306 } // namespace syncable 1319 } // namespace syncable
1307 } // namespace syncer 1320 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698