Commit dd509933 authored by tim@chromium.org's avatar tim@chromium.org

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
parent e489b15f
......@@ -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() {
......
......@@ -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:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment