| 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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 if (kernel_->ref(ATTACHMENT_METADATA).SerializeAsString() != | 239 if (kernel_->ref(ATTACHMENT_METADATA).SerializeAsString() != |
| 240 attachment_metadata.SerializeAsString()) { | 240 attachment_metadata.SerializeAsString()) { |
| 241 dir()->UpdateAttachmentIndex(GetMetahandle(), | 241 dir()->UpdateAttachmentIndex(GetMetahandle(), |
| 242 kernel_->ref(ATTACHMENT_METADATA), | 242 kernel_->ref(ATTACHMENT_METADATA), |
| 243 attachment_metadata); | 243 attachment_metadata); |
| 244 kernel_->put(ATTACHMENT_METADATA, attachment_metadata); | 244 kernel_->put(ATTACHMENT_METADATA, attachment_metadata); |
| 245 kernel_->mark_dirty(&dir()->kernel_->dirty_metahandles); | 245 kernel_->mark_dirty(&dir()->kernel_->dirty_metahandles); |
| 246 } | 246 } |
| 247 } | 247 } |
| 248 | 248 |
| 249 void MutableEntry::UpdateAttachmentIdWithServerInfo( | 249 void MutableEntry::MarkAttachmentAsOnServer( |
| 250 const sync_pb::AttachmentIdProto& updated_attachment_id) { | 250 const sync_pb::AttachmentIdProto& attachment_id) { |
| 251 DCHECK(kernel_); | 251 DCHECK(kernel_); |
| 252 DCHECK(!updated_attachment_id.unique_id().empty()); | 252 DCHECK(!attachment_id.unique_id().empty()); |
| 253 write_transaction()->TrackChangesTo(kernel_); | 253 write_transaction()->TrackChangesTo(kernel_); |
| 254 sync_pb::AttachmentMetadata& attachment_metadata = | 254 sync_pb::AttachmentMetadata& attachment_metadata = |
| 255 kernel_->mutable_ref(ATTACHMENT_METADATA); | 255 kernel_->mutable_ref(ATTACHMENT_METADATA); |
| 256 for (int i = 0; i < attachment_metadata.record_size(); ++i) { | 256 for (int i = 0; i < attachment_metadata.record_size(); ++i) { |
| 257 sync_pb::AttachmentMetadataRecord* record = | 257 sync_pb::AttachmentMetadataRecord* record = |
| 258 attachment_metadata.mutable_record(i); | 258 attachment_metadata.mutable_record(i); |
| 259 if (record->id().unique_id() != updated_attachment_id.unique_id()) | 259 if (record->id().unique_id() != attachment_id.unique_id()) |
| 260 continue; | 260 continue; |
| 261 *record->mutable_id() = updated_attachment_id; | |
| 262 record->set_is_on_server(true); | 261 record->set_is_on_server(true); |
| 263 } | 262 } |
| 264 kernel_->mark_dirty(&dir()->kernel_->dirty_metahandles); | 263 kernel_->mark_dirty(&dir()->kernel_->dirty_metahandles); |
| 265 MarkForSyncing(this); | 264 MarkForSyncing(this); |
| 266 } | 265 } |
| 267 | 266 |
| 268 // This function sets only the flags needed to get this entry to sync. | 267 // This function sets only the flags needed to get this entry to sync. |
| 269 bool MarkForSyncing(MutableEntry* e) { | 268 bool MarkForSyncing(MutableEntry* e) { |
| 270 DCHECK_NE(static_cast<MutableEntry*>(NULL), e); | 269 DCHECK_NE(static_cast<MutableEntry*>(NULL), e); |
| 271 DCHECK(!e->IsRoot()) << "We shouldn't mark a permanent object for syncing."; | 270 DCHECK(!e->IsRoot()) << "We shouldn't mark a permanent object for syncing."; |
| 272 if (!(e->PutIsUnsynced(true))) | 271 if (!(e->PutIsUnsynced(true))) |
| 273 return false; | 272 return false; |
| 274 e->PutSyncing(false); | 273 e->PutSyncing(false); |
| 275 return true; | 274 return true; |
| 276 } | 275 } |
| 277 | 276 |
| 278 } // namespace syncable | 277 } // namespace syncable |
| 279 } // namespace syncer | 278 } // namespace syncer |
| OLD | NEW |