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

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

Issue 814273006: Don't DCHECK in AttachmentServiceProxyForTest when MessageLoop is absent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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/internal_api/attachments/attachment_service_proxy_for_test.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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/message_loop/message_loop.h"
10 #include "base/sequenced_task_runner.h" 11 #include "base/sequenced_task_runner.h"
11 #include "base/thread_task_runner_handle.h" 12 #include "base/thread_task_runner_handle.h"
12 #include "sync/internal_api/public/attachments/attachment_store_handle.h" 13 #include "sync/internal_api/public/attachments/attachment_store_handle.h"
13 #include "sync/internal_api/public/attachments/in_memory_attachment_store.h" 14 #include "sync/internal_api/public/attachments/in_memory_attachment_store.h"
14 #include "sync/internal_api/public/attachments/on_disk_attachment_store.h" 15 #include "sync/internal_api/public/attachments/on_disk_attachment_store.h"
15 16
16 namespace syncer { 17 namespace syncer {
17 18
18 AttachmentStoreBase::AttachmentStoreBase() {} 19 AttachmentStoreBase::AttachmentStoreBase() {}
19 AttachmentStoreBase::~AttachmentStoreBase() {} 20 AttachmentStoreBase::~AttachmentStoreBase() {}
20 21
21 AttachmentStore::AttachmentStore() {} 22 AttachmentStore::AttachmentStore() {}
22 AttachmentStore::~AttachmentStore() {} 23 AttachmentStore::~AttachmentStore() {}
23 24
24 scoped_refptr<AttachmentStore> AttachmentStore::CreateInMemoryStore() { 25 scoped_refptr<AttachmentStore> AttachmentStore::CreateInMemoryStore() {
25 // Both frontend and backend of attachment store will live on current thread. 26 // Both frontend and backend of attachment store will live on current thread.
26 scoped_ptr<AttachmentStoreBase> backend( 27 scoped_refptr<base::SingleThreadTaskRunner> runner;
27 new InMemoryAttachmentStore(base::ThreadTaskRunnerHandle::Get())); 28 if (base::ThreadTaskRunnerHandle::IsSet()) {
28 return scoped_refptr<AttachmentStore>(new AttachmentStoreHandle( 29 runner = base::ThreadTaskRunnerHandle::Get();
29 backend.Pass(), base::ThreadTaskRunnerHandle::Get())); 30 } else {
31 // Dummy runner for tests that don't have MessageLoop.
32 base::MessageLoop loop;
33 // This works because |runner| takes a ref to the proxy.
34 runner = base::ThreadTaskRunnerHandle::Get();
35 }
36 scoped_ptr<AttachmentStoreBase> backend(new InMemoryAttachmentStore(runner));
37 return scoped_refptr<AttachmentStore>(
38 new AttachmentStoreHandle(backend.Pass(), runner));
30 } 39 }
31 40
32 scoped_refptr<AttachmentStore> AttachmentStore::CreateOnDiskStore( 41 scoped_refptr<AttachmentStore> AttachmentStore::CreateOnDiskStore(
33 const base::FilePath& path, 42 const base::FilePath& path,
34 const scoped_refptr<base::SequencedTaskRunner>& backend_task_runner, 43 const scoped_refptr<base::SequencedTaskRunner>& backend_task_runner,
35 const InitCallback& callback) { 44 const InitCallback& callback) {
36 scoped_ptr<OnDiskAttachmentStore> backend( 45 scoped_ptr<OnDiskAttachmentStore> backend(
37 new OnDiskAttachmentStore(base::ThreadTaskRunnerHandle::Get(), path)); 46 new OnDiskAttachmentStore(base::ThreadTaskRunnerHandle::Get(), path));
38 47
39 scoped_refptr<AttachmentStore> attachment_store = 48 scoped_refptr<AttachmentStore> attachment_store =
40 new AttachmentStoreHandle(backend.Pass(), backend_task_runner); 49 new AttachmentStoreHandle(backend.Pass(), backend_task_runner);
41 attachment_store->Init(callback); 50 attachment_store->Init(callback);
42 51
43 return attachment_store; 52 return attachment_store;
44 } 53 }
45 54
46 } // namespace syncer 55 } // namespace syncer
OLDNEW
« no previous file with comments | « no previous file | sync/internal_api/attachments/attachment_service_proxy_for_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698