diff options
author | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-29 16:42:26 +0000 |
---|---|---|
committer | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-29 16:42:26 +0000 |
commit | dd509933fdebc605e36d92c3d6466b7bddf32b4a (patch) | |
tree | 9a73330afb1437b8d1e128943499bc07a3f15c23 /sync | |
parent | e489b15f17207d94984e39464274b476cf103177 (diff) | |
download | chromium_src-dd509933fdebc605e36d92c3d6466b7bddf32b4a.zip chromium_src-dd509933fdebc605e36d92c3d6466b7bddf32b4a.tar.gz chromium_src-dd509933fdebc605e36d92c3d6466b7bddf32b4a.tar.bz2 |
sync: don't require a MessageLoopProxy in AttachmentServiceProxyForTest
BUG=none
R=maniscalco@chromium.org, pavely@chromium.org
Review URL: https://codereview.chromium.org/254713003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266898 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync')
-rw-r--r-- | sync/api/attachments/attachment_service_proxy_for_test.cc | 14 | ||||
-rw-r--r-- | sync/api/attachments/attachment_service_proxy_for_test.h | 5 |
2 files changed, 15 insertions, 4 deletions
diff --git a/sync/api/attachments/attachment_service_proxy_for_test.cc b/sync/api/attachments/attachment_service_proxy_for_test.cc index 7f9f873..7d03ed8 100644 --- a/sync/api/attachments/attachment_service_proxy_for_test.cc +++ b/sync/api/attachments/attachment_service_proxy_for_test.cc @@ -4,6 +4,7 @@ #include "sync/api/attachments/attachment_service_proxy_for_test.h" +#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop_proxy.h" #include "sync/api/attachments/fake_attachment_service.h" @@ -36,8 +37,17 @@ AttachmentServiceProxy AttachmentServiceProxyForTest::Create() { scoped_refptr<Core> core_for_test( new OwningCore(wrapped.Pass(), weak_ptr_factory.Pass())); - return AttachmentServiceProxyForTest(base::MessageLoopProxy::current(), - core_for_test); + + scoped_refptr<base::SequencedTaskRunner> runner( + base::MessageLoopProxy::current()); + if (!runner) { + // Dummy runner for tests that don't care about AttachmentServiceProxy. + DVLOG(1) << "Creating dummy MessageLoop for AttachmentServiceProxy."; + base::MessageLoop loop; + // This works because |runner| takes a ref to the proxy. + runner = loop.message_loop_proxy(); + } + return AttachmentServiceProxyForTest(runner, core_for_test); } AttachmentServiceProxyForTest::~AttachmentServiceProxyForTest() { diff --git a/sync/api/attachments/attachment_service_proxy_for_test.h b/sync/api/attachments/attachment_service_proxy_for_test.h index 916e788..2fb5c86 100644 --- a/sync/api/attachments/attachment_service_proxy_for_test.h +++ b/sync/api/attachments/attachment_service_proxy_for_test.h @@ -14,8 +14,9 @@ namespace syncer { // An self-contained AttachmentServiceProxy to reduce boilerplate code in tests. // -// Constructs and owns an AttachmentService suitable for use in tests. Assumes -// the current thread has a MessageLoop. +// Constructs and owns an AttachmentService suitable for use in tests. +// NOTE: This class does not require the current thread to have a MessageLoop, +// however all methods will effectively become no-op stubs in that case. class SYNC_EXPORT AttachmentServiceProxyForTest : public AttachmentServiceProxy { public: |