OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "components/sync/core/write_transaction.h" | 5 #include "components/sync/core/write_transaction.h" |
6 | 6 |
7 #include "components/sync/syncable/directory.h" | 7 #include "components/sync/syncable/directory.h" |
8 #include "components/sync/syncable/mutable_entry.h" | 8 #include "components/sync/syncable/mutable_entry.h" |
9 #include "components/sync/syncable/syncable_write_transaction.h" | 9 #include "components/sync/syncable/syncable_write_transaction.h" |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 WriteTransaction::~WriteTransaction() { | 30 WriteTransaction::~WriteTransaction() { |
31 delete transaction_; | 31 delete transaction_; |
32 } | 32 } |
33 | 33 |
34 syncable::BaseTransaction* WriteTransaction::GetWrappedTrans() const { | 34 syncable::BaseTransaction* WriteTransaction::GetWrappedTrans() const { |
35 return transaction_; | 35 return transaction_; |
36 } | 36 } |
37 | 37 |
38 void WriteTransaction::SetDataTypeContext( | 38 void WriteTransaction::SetDataTypeContext( |
39 ModelType type, | 39 ModelType type, |
40 SyncChangeProcessor::ContextRefreshStatus refresh_status, | 40 syncer::SyncChangeProcessor::ContextRefreshStatus refresh_status, |
41 const std::string& context) { | 41 const std::string& context) { |
42 DCHECK(ProtocolTypes().Has(type)); | 42 DCHECK(ProtocolTypes().Has(type)); |
43 int field_number = GetSpecificsFieldNumberFromModelType(type); | 43 int field_number = GetSpecificsFieldNumberFromModelType(type); |
44 sync_pb::DataTypeContext local_context; | 44 sync_pb::DataTypeContext local_context; |
45 GetDirectory()->GetDataTypeContext(transaction_, type, &local_context); | 45 GetDirectory()->GetDataTypeContext(transaction_, type, &local_context); |
46 if (local_context.context() == context) | 46 if (local_context.context() == context) |
47 return; | 47 return; |
48 | 48 |
49 if (!local_context.has_data_type_id()) | 49 if (!local_context.has_data_type_id()) |
50 local_context.set_data_type_id(field_number); | 50 local_context.set_data_type_id(field_number); |
51 | 51 |
52 DCHECK_EQ(field_number, local_context.data_type_id()); | 52 DCHECK_EQ(field_number, local_context.data_type_id()); |
53 DCHECK_GE(local_context.version(), 0); | 53 DCHECK_GE(local_context.version(), 0); |
54 local_context.set_version(local_context.version() + 1); | 54 local_context.set_version(local_context.version() + 1); |
55 local_context.set_context(context); | 55 local_context.set_context(context); |
56 GetDirectory()->SetDataTypeContext(transaction_, type, local_context); | 56 GetDirectory()->SetDataTypeContext(transaction_, type, local_context); |
57 if (refresh_status == SyncChangeProcessor::REFRESH_NEEDED) { | 57 if (refresh_status == syncer::SyncChangeProcessor::REFRESH_NEEDED) { |
58 DVLOG(1) << "Forcing refresh of type " << ModelTypeToString(type); | 58 DVLOG(1) << "Forcing refresh of type " << ModelTypeToString(type); |
59 // Clear the progress token from the progress markers. Preserve all other | 59 // Clear the progress token from the progress markers. Preserve all other |
60 // state, in case a GC directive was present. | 60 // state, in case a GC directive was present. |
61 sync_pb::DataTypeProgressMarker progress_marker; | 61 sync_pb::DataTypeProgressMarker progress_marker; |
62 GetDirectory()->GetDownloadProgress(type, &progress_marker); | 62 GetDirectory()->GetDownloadProgress(type, &progress_marker); |
63 progress_marker.clear_token(); | 63 progress_marker.clear_token(); |
64 GetDirectory()->SetDownloadProgress(type, progress_marker); | 64 GetDirectory()->SetDownloadProgress(type, progress_marker); |
65 | 65 |
66 // Go through and reset the versions for all the synced entities of this | 66 // Go through and reset the versions for all the synced entities of this |
67 // data type. | 67 // data type. |
(...skipping 12 matching lines...) Expand all Loading... |
80 GetDirectory()->GetMetahandlesByAttachmentId( | 80 GetDirectory()->GetMetahandlesByAttachmentId( |
81 transaction_, attachment_id.GetProto(), &handles); | 81 transaction_, attachment_id.GetProto(), &handles); |
82 for (syncable::Directory::Metahandles::iterator iter = handles.begin(); | 82 for (syncable::Directory::Metahandles::iterator iter = handles.begin(); |
83 iter != handles.end(); ++iter) { | 83 iter != handles.end(); ++iter) { |
84 syncable::MutableEntry entry(transaction_, syncable::GET_BY_HANDLE, *iter); | 84 syncable::MutableEntry entry(transaction_, syncable::GET_BY_HANDLE, *iter); |
85 entry.MarkAttachmentAsOnServer(attachment_id.GetProto()); | 85 entry.MarkAttachmentAsOnServer(attachment_id.GetProto()); |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 } // namespace syncer | 89 } // namespace syncer |
OLD | NEW |