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

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

Issue 254713003: sync: don't require a MessageLoopProxy in AttachmentServiceProxyForTest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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_service_proxy_for_test.h" 5 #include "sync/api/attachments/attachment_service_proxy_for_test.h"
6 6
7 #include "base/message_loop/message_loop.h"
7 #include "base/message_loop/message_loop_proxy.h" 8 #include "base/message_loop/message_loop_proxy.h"
8 #include "sync/api/attachments/fake_attachment_service.h" 9 #include "sync/api/attachments/fake_attachment_service.h"
9 10
10 namespace syncer { 11 namespace syncer {
11 12
12 AttachmentServiceProxyForTest::OwningCore::OwningCore( 13 AttachmentServiceProxyForTest::OwningCore::OwningCore(
13 scoped_ptr<AttachmentService> wrapped, 14 scoped_ptr<AttachmentService> wrapped,
14 scoped_ptr<base::WeakPtrFactory<AttachmentService> > weak_ptr_factory) 15 scoped_ptr<base::WeakPtrFactory<AttachmentService> > weak_ptr_factory)
15 : Core(weak_ptr_factory->GetWeakPtr()), 16 : Core(weak_ptr_factory->GetWeakPtr()),
16 wrapped_(wrapped.Pass()), 17 wrapped_(wrapped.Pass()),
(...skipping 12 matching lines...) Expand all
29 // invoked before any of this class's members are initialized, we create the 30 // invoked before any of this class's members are initialized, we create the
30 // WeakPtrFactory here and pass it to the ctor so that it may initialize its 31 // WeakPtrFactory here and pass it to the ctor so that it may initialize its
31 // base class and own the WeakPtrFactory. 32 // base class and own the WeakPtrFactory.
32 // 33 //
33 // We must pass by scoped_ptr because WeakPtrFactory has no copy constructor. 34 // We must pass by scoped_ptr because WeakPtrFactory has no copy constructor.
34 scoped_ptr<base::WeakPtrFactory<AttachmentService> > weak_ptr_factory( 35 scoped_ptr<base::WeakPtrFactory<AttachmentService> > weak_ptr_factory(
35 new base::WeakPtrFactory<AttachmentService>(wrapped.get())); 36 new base::WeakPtrFactory<AttachmentService>(wrapped.get()));
36 37
37 scoped_refptr<Core> core_for_test( 38 scoped_refptr<Core> core_for_test(
38 new OwningCore(wrapped.Pass(), weak_ptr_factory.Pass())); 39 new OwningCore(wrapped.Pass(), weak_ptr_factory.Pass()));
39 return AttachmentServiceProxyForTest(base::MessageLoopProxy::current(), 40
40 core_for_test); 41 scoped_refptr<base::SequencedTaskRunner> runner(
42 base::MessageLoopProxy::current());
43 if (!runner) {
44 // Dummy runner for tests that don't care about AttachmentServiceProxy.
45 DLOG(WARNING) << "Creating dummy MessageLoop for AttachmentServiceProxy.";
maniscalco 2014/04/28 16:05:12 I'm not real familiar with logging conventions in
tim (not reviewing) 2014/04/28 18:41:29 Hmm, I'll make it a DVLOG(1). I was worried that
46 base::MessageLoop loop;
maniscalco 2014/04/28 16:05:12 Can you update the ASPFT class comment now that it
tim (not reviewing) 2014/04/28 18:41:29 Done.
47 runner = loop.message_loop_proxy();
48 }
49 return AttachmentServiceProxyForTest(runner, core_for_test);
41 } 50 }
42 51
43 AttachmentServiceProxyForTest::~AttachmentServiceProxyForTest() { 52 AttachmentServiceProxyForTest::~AttachmentServiceProxyForTest() {
44 } 53 }
45 54
46 AttachmentServiceProxyForTest::AttachmentServiceProxyForTest( 55 AttachmentServiceProxyForTest::AttachmentServiceProxyForTest(
47 const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner, 56 const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner,
48 const scoped_refptr<Core>& core) 57 const scoped_refptr<Core>& core)
49 : AttachmentServiceProxy(wrapped_task_runner, core) { 58 : AttachmentServiceProxy(wrapped_task_runner, core) {
50 } 59 }
51 60
52 } // namespace syncer 61 } // namespace syncer
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698