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

Side by Side Diff: sync/api/attachments/attachment_store.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/api/attachments/attachment_store.h" 5 #include "sync/api/attachments/attachment_store.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 void AttachmentStore::ReadMetadataById(const AttachmentIdList& ids, 51 void AttachmentStore::ReadMetadataById(const AttachmentIdList& ids,
52 const ReadMetadataCallback& callback) { 52 const ReadMetadataCallback& callback) {
53 frontend_->ReadMetadataById(component_, ids, callback); 53 frontend_->ReadMetadataById(component_, ids, callback);
54 } 54 }
55 55
56 void AttachmentStore::ReadMetadata(const ReadMetadataCallback& callback) { 56 void AttachmentStore::ReadMetadata(const ReadMetadataCallback& callback) {
57 frontend_->ReadMetadata(component_, callback); 57 frontend_->ReadMetadata(component_, callback);
58 } 58 }
59 59
60 scoped_ptr<AttachmentStoreForSync> 60 std::unique_ptr<AttachmentStoreForSync>
61 AttachmentStore::CreateAttachmentStoreForSync() const { 61 AttachmentStore::CreateAttachmentStoreForSync() const {
62 scoped_ptr<AttachmentStoreForSync> attachment_store_for_sync( 62 std::unique_ptr<AttachmentStoreForSync> attachment_store_for_sync(
63 new AttachmentStoreForSync(frontend_, component_, SYNC)); 63 new AttachmentStoreForSync(frontend_, component_, SYNC));
64 return attachment_store_for_sync; 64 return attachment_store_for_sync;
65 } 65 }
66 66
67 scoped_ptr<AttachmentStore> AttachmentStore::CreateInMemoryStore() { 67 std::unique_ptr<AttachmentStore> AttachmentStore::CreateInMemoryStore() {
68 // Both frontend and backend of attachment store will live on current thread. 68 // Both frontend and backend of attachment store will live on current thread.
69 scoped_refptr<base::SingleThreadTaskRunner> runner; 69 scoped_refptr<base::SingleThreadTaskRunner> runner;
70 if (base::ThreadTaskRunnerHandle::IsSet()) { 70 if (base::ThreadTaskRunnerHandle::IsSet()) {
71 runner = base::ThreadTaskRunnerHandle::Get(); 71 runner = base::ThreadTaskRunnerHandle::Get();
72 } else { 72 } else {
73 // Dummy runner for tests that don't have MessageLoop. 73 // Dummy runner for tests that don't have MessageLoop.
74 base::MessageLoop loop; 74 base::MessageLoop loop;
75 // This works because |runner| takes a ref to the proxy. 75 // This works because |runner| takes a ref to the proxy.
76 runner = base::ThreadTaskRunnerHandle::Get(); 76 runner = base::ThreadTaskRunnerHandle::Get();
77 } 77 }
78 scoped_ptr<AttachmentStoreBackend> backend( 78 std::unique_ptr<AttachmentStoreBackend> backend(
79 new InMemoryAttachmentStore(runner)); 79 new InMemoryAttachmentStore(runner));
80 scoped_refptr<AttachmentStoreFrontend> frontend( 80 scoped_refptr<AttachmentStoreFrontend> frontend(
81 new AttachmentStoreFrontend(std::move(backend), runner)); 81 new AttachmentStoreFrontend(std::move(backend), runner));
82 scoped_ptr<AttachmentStore> attachment_store( 82 std::unique_ptr<AttachmentStore> attachment_store(
83 new AttachmentStore(frontend, MODEL_TYPE)); 83 new AttachmentStore(frontend, MODEL_TYPE));
84 return attachment_store; 84 return attachment_store;
85 } 85 }
86 86
87 scoped_ptr<AttachmentStore> AttachmentStore::CreateOnDiskStore( 87 std::unique_ptr<AttachmentStore> AttachmentStore::CreateOnDiskStore(
88 const base::FilePath& path, 88 const base::FilePath& path,
89 const scoped_refptr<base::SequencedTaskRunner>& backend_task_runner, 89 const scoped_refptr<base::SequencedTaskRunner>& backend_task_runner,
90 const InitCallback& callback) { 90 const InitCallback& callback) {
91 scoped_ptr<OnDiskAttachmentStore> backend( 91 std::unique_ptr<OnDiskAttachmentStore> backend(
92 new OnDiskAttachmentStore(base::ThreadTaskRunnerHandle::Get(), path)); 92 new OnDiskAttachmentStore(base::ThreadTaskRunnerHandle::Get(), path));
93 93
94 scoped_refptr<AttachmentStoreFrontend> frontend = 94 scoped_refptr<AttachmentStoreFrontend> frontend =
95 new AttachmentStoreFrontend(std::move(backend), backend_task_runner); 95 new AttachmentStoreFrontend(std::move(backend), backend_task_runner);
96 scoped_ptr<AttachmentStore> attachment_store( 96 std::unique_ptr<AttachmentStore> attachment_store(
97 new AttachmentStore(frontend, MODEL_TYPE)); 97 new AttachmentStore(frontend, MODEL_TYPE));
98 frontend->Init(callback); 98 frontend->Init(callback);
99 99
100 return attachment_store; 100 return attachment_store;
101 } 101 }
102 102
103 scoped_ptr<AttachmentStore> AttachmentStore::CreateMockStoreForTest( 103 std::unique_ptr<AttachmentStore> AttachmentStore::CreateMockStoreForTest(
104 scoped_ptr<AttachmentStoreBackend> backend) { 104 std::unique_ptr<AttachmentStoreBackend> backend) {
105 scoped_refptr<base::SingleThreadTaskRunner> runner = 105 scoped_refptr<base::SingleThreadTaskRunner> runner =
106 base::ThreadTaskRunnerHandle::Get(); 106 base::ThreadTaskRunnerHandle::Get();
107 scoped_refptr<AttachmentStoreFrontend> attachment_store_frontend( 107 scoped_refptr<AttachmentStoreFrontend> attachment_store_frontend(
108 new AttachmentStoreFrontend(std::move(backend), runner)); 108 new AttachmentStoreFrontend(std::move(backend), runner));
109 scoped_ptr<AttachmentStore> attachment_store( 109 std::unique_ptr<AttachmentStore> attachment_store(
110 new AttachmentStore(attachment_store_frontend, MODEL_TYPE)); 110 new AttachmentStore(attachment_store_frontend, MODEL_TYPE));
111 return attachment_store; 111 return attachment_store;
112 } 112 }
113 113
114 AttachmentStoreForSync::AttachmentStoreForSync( 114 AttachmentStoreForSync::AttachmentStoreForSync(
115 const scoped_refptr<AttachmentStoreFrontend>& frontend, 115 const scoped_refptr<AttachmentStoreFrontend>& frontend,
116 Component consumer_component, 116 Component consumer_component,
117 Component sync_component) 117 Component sync_component)
118 : AttachmentStore(frontend, consumer_component), 118 : AttachmentStore(frontend, consumer_component),
119 sync_component_(sync_component) { 119 sync_component_(sync_component) {
(...skipping 15 matching lines...) Expand all
135 frontend()->DropReference(sync_component_, ids, 135 frontend()->DropReference(sync_component_, ids,
136 base::Bind(&NoOpDropCallback)); 136 base::Bind(&NoOpDropCallback));
137 } 137 }
138 138
139 void AttachmentStoreForSync::ReadMetadataForSync( 139 void AttachmentStoreForSync::ReadMetadataForSync(
140 const ReadMetadataCallback& callback) { 140 const ReadMetadataCallback& callback) {
141 frontend()->ReadMetadata(sync_component_, callback); 141 frontend()->ReadMetadata(sync_component_, callback);
142 } 142 }
143 143
144 } // namespace syncer 144 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698