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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/api/attachments/attachment_store.cc
diff --git a/sync/api/attachments/attachment_store.cc b/sync/api/attachments/attachment_store.cc
index 9b22c51c017eac7389037e7adac6f8198921ebaf..129ac0b5dd5f5279ed1b87899aee44dd3f0e78dc 100644
--- a/sync/api/attachments/attachment_store.cc
+++ b/sync/api/attachments/attachment_store.cc
@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/location.h"
+#include "base/message_loop/message_loop.h"
#include "base/sequenced_task_runner.h"
#include "base/thread_task_runner_handle.h"
#include "sync/internal_api/public/attachments/attachment_store_handle.h"
@@ -23,10 +24,18 @@ AttachmentStore::~AttachmentStore() {}
scoped_refptr<AttachmentStore> AttachmentStore::CreateInMemoryStore() {
// Both frontend and backend of attachment store will live on current thread.
- scoped_ptr<AttachmentStoreBase> backend(
- new InMemoryAttachmentStore(base::ThreadTaskRunnerHandle::Get()));
- return scoped_refptr<AttachmentStore>(new AttachmentStoreHandle(
- backend.Pass(), base::ThreadTaskRunnerHandle::Get()));
+ scoped_refptr<base::SingleThreadTaskRunner> runner;
+ if (base::ThreadTaskRunnerHandle::IsSet()) {
+ runner = base::ThreadTaskRunnerHandle::Get();
+ } else {
+ // Dummy runner for tests that don't have MessageLoop.
+ base::MessageLoop loop;
+ // This works because |runner| takes a ref to the proxy.
+ runner = base::ThreadTaskRunnerHandle::Get();
+ }
+ scoped_ptr<AttachmentStoreBase> backend(new InMemoryAttachmentStore(runner));
+ return scoped_refptr<AttachmentStore>(
+ new AttachmentStoreHandle(backend.Pass(), runner));
}
scoped_refptr<AttachmentStore> AttachmentStore::CreateOnDiskStore(
« 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