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

Side by Side Diff: sync/api/attachments/attachment_store.cc

Issue 1539843002: Convert Pass()→std::move() in sync/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleaned up Created 4 years, 12 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 | « no previous file | sync/api/fake_syncable_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/callback.h" 10 #include "base/callback.h"
9 #include "base/location.h" 11 #include "base/location.h"
10 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
11 #include "base/sequenced_task_runner.h" 13 #include "base/sequenced_task_runner.h"
12 #include "base/thread_task_runner_handle.h" 14 #include "base/thread_task_runner_handle.h"
13 #include "sync/internal_api/public/attachments/attachment_store_frontend.h" 15 #include "sync/internal_api/public/attachments/attachment_store_frontend.h"
14 #include "sync/internal_api/public/attachments/in_memory_attachment_store.h" 16 #include "sync/internal_api/public/attachments/in_memory_attachment_store.h"
15 #include "sync/internal_api/public/attachments/on_disk_attachment_store.h" 17 #include "sync/internal_api/public/attachments/on_disk_attachment_store.h"
16 18
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 } 54 }
53 55
54 void AttachmentStore::ReadMetadata(const ReadMetadataCallback& callback) { 56 void AttachmentStore::ReadMetadata(const ReadMetadataCallback& callback) {
55 frontend_->ReadMetadata(component_, callback); 57 frontend_->ReadMetadata(component_, callback);
56 } 58 }
57 59
58 scoped_ptr<AttachmentStoreForSync> 60 scoped_ptr<AttachmentStoreForSync>
59 AttachmentStore::CreateAttachmentStoreForSync() const { 61 AttachmentStore::CreateAttachmentStoreForSync() const {
60 scoped_ptr<AttachmentStoreForSync> attachment_store_for_sync( 62 scoped_ptr<AttachmentStoreForSync> attachment_store_for_sync(
61 new AttachmentStoreForSync(frontend_, component_, SYNC)); 63 new AttachmentStoreForSync(frontend_, component_, SYNC));
62 return attachment_store_for_sync.Pass(); 64 return attachment_store_for_sync;
63 } 65 }
64 66
65 scoped_ptr<AttachmentStore> AttachmentStore::CreateInMemoryStore() { 67 scoped_ptr<AttachmentStore> AttachmentStore::CreateInMemoryStore() {
66 // 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.
67 scoped_refptr<base::SingleThreadTaskRunner> runner; 69 scoped_refptr<base::SingleThreadTaskRunner> runner;
68 if (base::ThreadTaskRunnerHandle::IsSet()) { 70 if (base::ThreadTaskRunnerHandle::IsSet()) {
69 runner = base::ThreadTaskRunnerHandle::Get(); 71 runner = base::ThreadTaskRunnerHandle::Get();
70 } else { 72 } else {
71 // Dummy runner for tests that don't have MessageLoop. 73 // Dummy runner for tests that don't have MessageLoop.
72 base::MessageLoop loop; 74 base::MessageLoop loop;
73 // This works because |runner| takes a ref to the proxy. 75 // This works because |runner| takes a ref to the proxy.
74 runner = base::ThreadTaskRunnerHandle::Get(); 76 runner = base::ThreadTaskRunnerHandle::Get();
75 } 77 }
76 scoped_ptr<AttachmentStoreBackend> backend( 78 scoped_ptr<AttachmentStoreBackend> backend(
77 new InMemoryAttachmentStore(runner)); 79 new InMemoryAttachmentStore(runner));
78 scoped_refptr<AttachmentStoreFrontend> frontend( 80 scoped_refptr<AttachmentStoreFrontend> frontend(
79 new AttachmentStoreFrontend(backend.Pass(), runner)); 81 new AttachmentStoreFrontend(std::move(backend), runner));
80 scoped_ptr<AttachmentStore> attachment_store( 82 scoped_ptr<AttachmentStore> attachment_store(
81 new AttachmentStore(frontend, MODEL_TYPE)); 83 new AttachmentStore(frontend, MODEL_TYPE));
82 return attachment_store.Pass(); 84 return attachment_store;
83 } 85 }
84 86
85 scoped_ptr<AttachmentStore> AttachmentStore::CreateOnDiskStore( 87 scoped_ptr<AttachmentStore> AttachmentStore::CreateOnDiskStore(
86 const base::FilePath& path, 88 const base::FilePath& path,
87 const scoped_refptr<base::SequencedTaskRunner>& backend_task_runner, 89 const scoped_refptr<base::SequencedTaskRunner>& backend_task_runner,
88 const InitCallback& callback) { 90 const InitCallback& callback) {
89 scoped_ptr<OnDiskAttachmentStore> backend( 91 scoped_ptr<OnDiskAttachmentStore> backend(
90 new OnDiskAttachmentStore(base::ThreadTaskRunnerHandle::Get(), path)); 92 new OnDiskAttachmentStore(base::ThreadTaskRunnerHandle::Get(), path));
91 93
92 scoped_refptr<AttachmentStoreFrontend> frontend = 94 scoped_refptr<AttachmentStoreFrontend> frontend =
93 new AttachmentStoreFrontend(backend.Pass(), backend_task_runner); 95 new AttachmentStoreFrontend(std::move(backend), backend_task_runner);
94 scoped_ptr<AttachmentStore> attachment_store( 96 scoped_ptr<AttachmentStore> attachment_store(
95 new AttachmentStore(frontend, MODEL_TYPE)); 97 new AttachmentStore(frontend, MODEL_TYPE));
96 frontend->Init(callback); 98 frontend->Init(callback);
97 99
98 return attachment_store.Pass(); 100 return attachment_store;
99 } 101 }
100 102
101 scoped_ptr<AttachmentStore> AttachmentStore::CreateMockStoreForTest( 103 scoped_ptr<AttachmentStore> AttachmentStore::CreateMockStoreForTest(
102 scoped_ptr<AttachmentStoreBackend> backend) { 104 scoped_ptr<AttachmentStoreBackend> backend) {
103 scoped_refptr<base::SingleThreadTaskRunner> runner = 105 scoped_refptr<base::SingleThreadTaskRunner> runner =
104 base::ThreadTaskRunnerHandle::Get(); 106 base::ThreadTaskRunnerHandle::Get();
105 scoped_refptr<AttachmentStoreFrontend> attachment_store_frontend( 107 scoped_refptr<AttachmentStoreFrontend> attachment_store_frontend(
106 new AttachmentStoreFrontend(backend.Pass(), runner)); 108 new AttachmentStoreFrontend(std::move(backend), runner));
107 scoped_ptr<AttachmentStore> attachment_store( 109 scoped_ptr<AttachmentStore> attachment_store(
108 new AttachmentStore(attachment_store_frontend, MODEL_TYPE)); 110 new AttachmentStore(attachment_store_frontend, MODEL_TYPE));
109 return attachment_store.Pass(); 111 return attachment_store;
110 } 112 }
111 113
112 AttachmentStoreForSync::AttachmentStoreForSync( 114 AttachmentStoreForSync::AttachmentStoreForSync(
113 const scoped_refptr<AttachmentStoreFrontend>& frontend, 115 const scoped_refptr<AttachmentStoreFrontend>& frontend,
114 Component consumer_component, 116 Component consumer_component,
115 Component sync_component) 117 Component sync_component)
116 : AttachmentStore(frontend, consumer_component), 118 : AttachmentStore(frontend, consumer_component),
117 sync_component_(sync_component) { 119 sync_component_(sync_component) {
118 } 120 }
119 121
(...skipping 13 matching lines...) Expand all
133 frontend()->DropReference(sync_component_, ids, 135 frontend()->DropReference(sync_component_, ids,
134 base::Bind(&NoOpDropCallback)); 136 base::Bind(&NoOpDropCallback));
135 } 137 }
136 138
137 void AttachmentStoreForSync::ReadMetadataForSync( 139 void AttachmentStoreForSync::ReadMetadataForSync(
138 const ReadMetadataCallback& callback) { 140 const ReadMetadataCallback& callback) {
139 frontend()->ReadMetadata(sync_component_, callback); 141 frontend()->ReadMetadata(sync_component_, callback);
140 } 142 }
141 143
142 } // namespace syncer 144 } // namespace syncer
OLDNEW
« no previous file with comments | « no previous file | sync/api/fake_syncable_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698