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

Side by Side Diff: sync/engine/directory_commit_contribution.cc

Issue 1866243002: Convert //sync from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/engine/directory_commit_contribution.h" 5 #include "sync/engine/directory_commit_contribution.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
11 #include <set> 11 #include <set>
12 12
13 #include "sync/engine/commit_util.h" 13 #include "sync/engine/commit_util.h"
14 #include "sync/engine/get_commit_ids.h" 14 #include "sync/engine/get_commit_ids.h"
15 #include "sync/engine/syncer_util.h" 15 #include "sync/engine/syncer_util.h"
16 #include "sync/internal_api/public/sessions/commit_counters.h" 16 #include "sync/internal_api/public/sessions/commit_counters.h"
17 #include "sync/syncable/model_neutral_mutable_entry.h" 17 #include "sync/syncable/model_neutral_mutable_entry.h"
18 #include "sync/syncable/syncable_model_neutral_write_transaction.h" 18 #include "sync/syncable/syncable_model_neutral_write_transaction.h"
19 19
20 namespace syncer { 20 namespace syncer {
21 21
22 using syncable::GET_BY_HANDLE; 22 using syncable::GET_BY_HANDLE;
23 using syncable::SYNCER; 23 using syncable::SYNCER;
24 24
25 DirectoryCommitContribution::~DirectoryCommitContribution() { 25 DirectoryCommitContribution::~DirectoryCommitContribution() {
26 DCHECK(!syncing_bits_set_); 26 DCHECK(!syncing_bits_set_);
27 } 27 }
28 28
29 // static. 29 // static.
30 scoped_ptr<DirectoryCommitContribution> DirectoryCommitContribution::Build( 30 std::unique_ptr<DirectoryCommitContribution> DirectoryCommitContribution::Build(
31 syncable::Directory* dir, 31 syncable::Directory* dir,
32 ModelType type, 32 ModelType type,
33 size_t max_entries, 33 size_t max_entries,
34 DirectoryTypeDebugInfoEmitter* debug_info_emitter) { 34 DirectoryTypeDebugInfoEmitter* debug_info_emitter) {
35 DCHECK(debug_info_emitter); 35 DCHECK(debug_info_emitter);
36 36
37 std::vector<int64_t> metahandles; 37 std::vector<int64_t> metahandles;
38 38
39 syncable::ModelNeutralWriteTransaction trans(FROM_HERE, SYNCER, dir); 39 syncable::ModelNeutralWriteTransaction trans(FROM_HERE, SYNCER, dir);
40 GetCommitIdsForType(&trans, type, max_entries, &metahandles); 40 GetCommitIdsForType(&trans, type, max_entries, &metahandles);
41 41
42 if (metahandles.empty()) 42 if (metahandles.empty())
43 return scoped_ptr<DirectoryCommitContribution>(); 43 return std::unique_ptr<DirectoryCommitContribution>();
44 44
45 google::protobuf::RepeatedPtrField<sync_pb::SyncEntity> entities; 45 google::protobuf::RepeatedPtrField<sync_pb::SyncEntity> entities;
46 for (std::vector<int64_t>::iterator it = metahandles.begin(); 46 for (std::vector<int64_t>::iterator it = metahandles.begin();
47 it != metahandles.end(); ++it) { 47 it != metahandles.end(); ++it) {
48 sync_pb::SyncEntity* entity = entities.Add(); 48 sync_pb::SyncEntity* entity = entities.Add();
49 syncable::ModelNeutralMutableEntry entry(&trans, GET_BY_HANDLE, *it); 49 syncable::ModelNeutralMutableEntry entry(&trans, GET_BY_HANDLE, *it);
50 commit_util::BuildCommitItem(entry, entity); 50 commit_util::BuildCommitItem(entry, entity);
51 entry.PutSyncing(true); 51 entry.PutSyncing(true);
52 } 52 }
53 53
54 sync_pb::DataTypeContext context; 54 sync_pb::DataTypeContext context;
55 dir->GetDataTypeContext(&trans, type, &context); 55 dir->GetDataTypeContext(&trans, type, &context);
56 56
57 return scoped_ptr<DirectoryCommitContribution>( 57 return std::unique_ptr<DirectoryCommitContribution>(
58 new DirectoryCommitContribution( 58 new DirectoryCommitContribution(metahandles, entities, context, dir,
59 metahandles, 59 debug_info_emitter));
60 entities,
61 context,
62 dir,
63 debug_info_emitter));
64 } 60 }
65 61
66 void DirectoryCommitContribution::AddToCommitMessage( 62 void DirectoryCommitContribution::AddToCommitMessage(
67 sync_pb::ClientToServerMessage* msg) { 63 sync_pb::ClientToServerMessage* msg) {
68 DCHECK(syncing_bits_set_); 64 DCHECK(syncing_bits_set_);
69 sync_pb::CommitMessage* commit_message = msg->mutable_commit(); 65 sync_pb::CommitMessage* commit_message = msg->mutable_commit();
70 entries_start_index_ = commit_message->entries_size(); 66 entries_start_index_ = commit_message->entries_size();
71 std::copy(entities_.begin(), 67 std::copy(entities_.begin(),
72 entities_.end(), 68 entities_.end(),
73 RepeatedPtrFieldBackInserter(commit_message->mutable_entries())); 69 RepeatedPtrFieldBackInserter(commit_message->mutable_entries()));
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 // complete but the Cleanup method is called anyways. It appears these are 190 // complete but the Cleanup method is called anyways. It appears these are
195 // unset on the assumption that the sync cycle must have finished properly, 191 // unset on the assumption that the sync cycle must have finished properly,
196 // although that's actually up to the commit response handling logic. 192 // although that's actually up to the commit response handling logic.
197 entry.PutDirtySync(false); 193 entry.PutDirtySync(false);
198 entry.PutSyncing(false); 194 entry.PutSyncing(false);
199 } 195 }
200 syncing_bits_set_ = false; 196 syncing_bits_set_ = false;
201 } 197 }
202 198
203 } // namespace syncer 199 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698