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/node_ordinal.h" | 8 #include "sync/internal_api/public/base/node_ordinal.h" |
9 #include "sync/syncable/directory.h" | 9 #include "sync/syncable/directory.h" |
10 #include "sync/syncable/scoped_index_updater.h" | 10 #include "sync/syncable/scoped_index_updater.h" |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 dir()->kernel_->unapplied_update_metahandles[new_server_type] | 266 dir()->kernel_->unapplied_update_metahandles[new_server_type] |
267 .insert(metahandle); | 267 .insert(metahandle); |
268 } | 268 } |
269 } | 269 } |
270 return true; | 270 return true; |
271 } | 271 } |
272 | 272 |
273 bool MutableEntry::Put(BitField field, bool value) { | 273 bool MutableEntry::Put(BitField field, bool value) { |
274 DCHECK(kernel_); | 274 DCHECK(kernel_); |
275 write_transaction_->SaveOriginal(kernel_); | 275 write_transaction_->SaveOriginal(kernel_); |
276 if (kernel_->ref(field) != value) { | 276 bool old_value = kernel_->ref(field); |
| 277 if (old_value != value) { |
277 kernel_->put(field, value); | 278 kernel_->put(field, value); |
278 kernel_->mark_dirty(GetDirtyIndexHelper()); | 279 kernel_->mark_dirty(GetDirtyIndexHelper()); |
| 280 |
| 281 // Update delete journal for existence status change on server side here |
| 282 // instead of in PutIsDel() because IS_DEL may not be updated due to |
| 283 // early returns when processing updates. And because |
| 284 // UpdateDeleteJournalForServerDelete() checks for SERVER_IS_DEL, it has |
| 285 // to be called on sync thread. |
| 286 if (field == SERVER_IS_DEL) { |
| 287 dir()->delete_journal()->UpdateDeleteJournalForServerDelete( |
| 288 write_transaction(), old_value, *kernel_); |
| 289 } |
279 } | 290 } |
280 return true; | 291 return true; |
281 } | 292 } |
282 | 293 |
283 MetahandleSet* MutableEntry::GetDirtyIndexHelper() { | 294 MetahandleSet* MutableEntry::GetDirtyIndexHelper() { |
284 return dir()->kernel_->dirty_metahandles; | 295 return dir()->kernel_->dirty_metahandles; |
285 } | 296 } |
286 | 297 |
287 bool MutableEntry::PutUniqueClientTag(const string& new_tag) { | 298 bool MutableEntry::PutUniqueClientTag(const string& new_tag) { |
288 write_transaction_->SaveOriginal(kernel_); | 299 write_transaction_->SaveOriginal(kernel_); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 DCHECK_NE(static_cast<MutableEntry*>(NULL), e); | 437 DCHECK_NE(static_cast<MutableEntry*>(NULL), e); |
427 DCHECK(!e->IsRoot()) << "We shouldn't mark a permanent object for syncing."; | 438 DCHECK(!e->IsRoot()) << "We shouldn't mark a permanent object for syncing."; |
428 if (!(e->Put(IS_UNSYNCED, true))) | 439 if (!(e->Put(IS_UNSYNCED, true))) |
429 return false; | 440 return false; |
430 e->Put(SYNCING, false); | 441 e->Put(SYNCING, false); |
431 return true; | 442 return true; |
432 } | 443 } |
433 | 444 |
434 } // namespace syncable | 445 } // namespace syncable |
435 } // namespace syncer | 446 } // namespace syncer |
OLD | NEW |