summaryrefslogtreecommitdiffstats
path: root/sync/api
diff options
context:
space:
mode:
authorpavely <pavely@chromium.org>2015-01-16 09:20:41 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-16 17:21:40 +0000
commita8e369960cfab093ffffc9dc9f0066cca2b56812 (patch)
tree8f4d6d16ad9dfeb0af61aa47eea1ed0c53bc919b /sync/api
parent4bdbb054140fb4d84a767a8828159b5f5dbe8799 (diff)
downloadchromium_src-a8e369960cfab093ffffc9dc9f0066cca2b56812.zip
chromium_src-a8e369960cfab093ffffc9dc9f0066cca2b56812.tar.gz
chromium_src-a8e369960cfab093ffffc9dc9f0066cca2b56812.tar.bz2
Don't DCHECK in AttachmentServiceProxyForTest when MessageLoop is absent
The code in AttachmentServiceProxyForTest::Create checks that base::ThreadTaskRunnerHandle::Get() returns valid runner in the incorrect way. Get() DCHECKs that there is valid MessageLoop. Instead it should check ThreadTaskRunnerHandle::IsSet(). BUG=449327 R=maniscalco@chromium.org Review URL: https://codereview.chromium.org/814273006 Cr-Commit-Position: refs/heads/master@{#311917}
Diffstat (limited to 'sync/api')
-rw-r--r--sync/api/attachments/attachment_store.cc17
1 files changed, 13 insertions, 4 deletions
diff --git a/sync/api/attachments/attachment_store.cc b/sync/api/attachments/attachment_store.cc
index 9b22c51..129ac0b5 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(