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

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

Issue 272043002: Invoke AttachmentUploader and update AttachmentIds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Android build Created 6 years, 7 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
« no previous file with comments | « sync/syncable/mutable_entry.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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::UpdateAttachmentIdWithServerInfo(
251 const sync_pb::AttachmentIdProto& updated_attachment_id) {
252 DCHECK(kernel_);
253 DCHECK(!updated_attachment_id.unique_id().empty());
254 write_transaction()->TrackChangesTo(kernel_);
255 sync_pb::AttachmentMetadata& attachment_metadata =
256 kernel_->mutable_ref(ATTACHMENT_METADATA);
257 for (int i = 0; i < attachment_metadata.record_size(); ++i) {
258 sync_pb::AttachmentMetadataRecord* record =
259 attachment_metadata.mutable_record(i);
260 if (record->id().unique_id() != updated_attachment_id.unique_id())
261 continue;
262 *record->mutable_id() = updated_attachment_id;
263 record->set_is_on_server(true);
264 }
265 kernel_->mark_dirty(&dir()->kernel_->dirty_metahandles);
266 MarkForSyncing(this);
267 }
268
250 // This function sets only the flags needed to get this entry to sync. 269 // This function sets only the flags needed to get this entry to sync.
251 bool MarkForSyncing(MutableEntry* e) { 270 bool MarkForSyncing(MutableEntry* e) {
252 DCHECK_NE(static_cast<MutableEntry*>(NULL), e); 271 DCHECK_NE(static_cast<MutableEntry*>(NULL), e);
253 DCHECK(!e->IsRoot()) << "We shouldn't mark a permanent object for syncing."; 272 DCHECK(!e->IsRoot()) << "We shouldn't mark a permanent object for syncing.";
254 if (!(e->PutIsUnsynced(true))) 273 if (!(e->PutIsUnsynced(true)))
255 return false; 274 return false;
256 e->PutSyncing(false); 275 e->PutSyncing(false);
257 return true; 276 return true;
258 } 277 }
259 278
260 } // namespace syncable 279 } // namespace syncable
261 } // namespace syncer 280 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/syncable/mutable_entry.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698