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