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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 : ModelNeutralMutableEntry(trans, GET_BY_HANDLE, metahandle), | 91 : ModelNeutralMutableEntry(trans, GET_BY_HANDLE, metahandle), |
92 write_transaction_(trans) { | 92 write_transaction_(trans) { |
93 } | 93 } |
94 | 94 |
95 MutableEntry::MutableEntry(WriteTransaction* trans, GetByClientTag, | 95 MutableEntry::MutableEntry(WriteTransaction* trans, GetByClientTag, |
96 const std::string& tag) | 96 const std::string& tag) |
97 : ModelNeutralMutableEntry(trans, GET_BY_CLIENT_TAG, tag), | 97 : ModelNeutralMutableEntry(trans, GET_BY_CLIENT_TAG, tag), |
98 write_transaction_(trans) { | 98 write_transaction_(trans) { |
99 } | 99 } |
100 | 100 |
101 MutableEntry::MutableEntry(WriteTransaction* trans, GetByServerTag, | 101 MutableEntry::MutableEntry(WriteTransaction* trans, GetTypeRoot, ModelType type) |
102 const string& tag) | 102 : ModelNeutralMutableEntry(trans, GET_TYPE_ROOT, type), |
103 : ModelNeutralMutableEntry(trans, GET_BY_SERVER_TAG, tag), | |
104 write_transaction_(trans) { | 103 write_transaction_(trans) { |
105 } | 104 } |
106 | 105 |
107 void MutableEntry::PutLocalExternalId(int64 value) { | 106 void MutableEntry::PutLocalExternalId(int64 value) { |
108 DCHECK(kernel_); | 107 DCHECK(kernel_); |
109 write_transaction()->TrackChangesTo(kernel_); | 108 write_transaction()->TrackChangesTo(kernel_); |
110 if (kernel_->ref(LOCAL_EXTERNAL_ID) != value) { | 109 if (kernel_->ref(LOCAL_EXTERNAL_ID) != value) { |
111 ScopedKernelLock lock(dir()); | 110 ScopedKernelLock lock(dir()); |
112 kernel_->put(LOCAL_EXTERNAL_ID, value); | 111 kernel_->put(LOCAL_EXTERNAL_ID, value); |
113 kernel_->mark_dirty(&dir()->kernel_->dirty_metahandles); | 112 kernel_->mark_dirty(&dir()->kernel_->dirty_metahandles); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 DCHECK_NE(static_cast<MutableEntry*>(NULL), e); | 270 DCHECK_NE(static_cast<MutableEntry*>(NULL), e); |
272 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."; |
273 if (!(e->PutIsUnsynced(true))) | 272 if (!(e->PutIsUnsynced(true))) |
274 return false; | 273 return false; |
275 e->PutSyncing(false); | 274 e->PutSyncing(false); |
276 return true; | 275 return true; |
277 } | 276 } |
278 | 277 |
279 } // namespace syncable | 278 } // namespace syncable |
280 } // namespace syncer | 279 } // namespace syncer |
OLD | NEW |