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 "sync/syncable/mutable_entry.h" | 5 #include "sync/syncable/mutable_entry.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "sync/internal_api/public/base/unique_position.h" | 8 #include "sync/internal_api/public/base/unique_position.h" |
9 #include "sync/syncable/directory.h" | 9 #include "sync/syncable/directory.h" |
10 #include "sync/syncable/scoped_kernel_lock.h" | 10 #include "sync/syncable/scoped_kernel_lock.h" |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
240 if (kernel_->ref(ATTACHMENT_METADATA).SerializeAsString() != | 240 if (kernel_->ref(ATTACHMENT_METADATA).SerializeAsString() != |
241 attachment_metadata.SerializeAsString()) { | 241 attachment_metadata.SerializeAsString()) { |
242 dir()->UpdateAttachmentIndex(GetMetahandle(), | 242 dir()->UpdateAttachmentIndex(GetMetahandle(), |
243 kernel_->ref(ATTACHMENT_METADATA), | 243 kernel_->ref(ATTACHMENT_METADATA), |
244 attachment_metadata); | 244 attachment_metadata); |
245 kernel_->put(ATTACHMENT_METADATA, attachment_metadata); | 245 kernel_->put(ATTACHMENT_METADATA, attachment_metadata); |
246 kernel_->mark_dirty(&dir()->kernel_->dirty_metahandles); | 246 kernel_->mark_dirty(&dir()->kernel_->dirty_metahandles); |
247 } | 247 } |
248 } | 248 } |
249 | 249 |
250 void MutableEntry::UpdateAttachmentId( | |
maniscalco
2014/05/09 18:12:11
How about adding a unit test for this method? dir
pavely
2014/05/13 23:06:44
Done.
| |
251 const sync_pb::AttachmentIdProto& attachment_id) { | |
252 DCHECK(kernel_); | |
maniscalco
2014/05/09 18:12:11
Consider DCHECKing that attachment_id's unique_id
pavely
2014/05/13 23:06:44
Done.
| |
253 write_transaction()->TrackChangesTo(kernel_); | |
254 sync_pb::AttachmentMetadata& attachment_metadata = | |
255 kernel_->mutable_ref(ATTACHMENT_METADATA); | |
256 for (int i = 0; i < attachment_metadata.record_size(); ++i) { | |
257 sync_pb::AttachmentMetadataRecord* record = | |
258 attachment_metadata.mutable_record(i); | |
259 if (record->id().unique_id() != attachment_id.unique_id()) | |
260 continue; | |
261 record->set_is_on_server(true); | |
maniscalco
2014/05/09 18:12:11
I wonder if we can make it more obvious that this
pavely
2014/05/13 23:06:44
Decided to name it UpdateAttachmentIdWithServerInf
| |
262 record->mutable_id()->set_url(attachment_id.url()); | |
263 } | |
264 kernel_->mark_dirty(&dir()->kernel_->dirty_metahandles); | |
265 MarkForSyncing(this); | |
266 } | |
267 | |
250 // This function sets only the flags needed to get this entry to sync. | 268 // This function sets only the flags needed to get this entry to sync. |
251 bool MarkForSyncing(MutableEntry* e) { | 269 bool MarkForSyncing(MutableEntry* e) { |
252 DCHECK_NE(static_cast<MutableEntry*>(NULL), e); | 270 DCHECK_NE(static_cast<MutableEntry*>(NULL), e); |
253 DCHECK(!e->IsRoot()) << "We shouldn't mark a permanent object for syncing."; | 271 DCHECK(!e->IsRoot()) << "We shouldn't mark a permanent object for syncing."; |
254 if (!(e->PutIsUnsynced(true))) | 272 if (!(e->PutIsUnsynced(true))) |
255 return false; | 273 return false; |
256 e->PutSyncing(false); | 274 e->PutSyncing(false); |
257 return true; | 275 return true; |
258 } | 276 } |
259 | 277 |
260 } // namespace syncable | 278 } // namespace syncable |
261 } // namespace syncer | 279 } // namespace syncer |
OLD | NEW |