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

Side by Side Diff: sync/internal_api/attachments/attachment_service_proxy_for_test.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 unified diff | Download patch
« no previous file with comments | « sync/api/attachments/attachment_store.cc ('k') | 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/internal_api/public/attachments/attachment_service_proxy_for_test .h" 5 #include "sync/internal_api/public/attachments/attachment_service_proxy_for_test .h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/thread_task_runner_handle.h" 8 #include "base/thread_task_runner_handle.h"
9 #include "sync/internal_api/public/attachments/attachment_service_impl.h" 9 #include "sync/internal_api/public/attachments/attachment_service_impl.h"
10 10
(...skipping 20 matching lines...) Expand all
31 // 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
32 // base class and own the WeakPtrFactory. 32 // base class and own the WeakPtrFactory.
33 // 33 //
34 // 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.
35 scoped_ptr<base::WeakPtrFactory<AttachmentService> > weak_ptr_factory( 35 scoped_ptr<base::WeakPtrFactory<AttachmentService> > weak_ptr_factory(
36 new base::WeakPtrFactory<AttachmentService>(wrapped.get())); 36 new base::WeakPtrFactory<AttachmentService>(wrapped.get()));
37 37
38 scoped_refptr<Core> core_for_test( 38 scoped_refptr<Core> core_for_test(
39 new OwningCore(wrapped.Pass(), weak_ptr_factory.Pass())); 39 new OwningCore(wrapped.Pass(), weak_ptr_factory.Pass()));
40 40
41 scoped_refptr<base::SequencedTaskRunner> runner( 41 scoped_refptr<base::SequencedTaskRunner> runner;
42 base::ThreadTaskRunnerHandle::Get()); 42 if (base::ThreadTaskRunnerHandle::IsSet()) {
43 if (!runner.get()) { 43 runner = base::ThreadTaskRunnerHandle::Get();
44 // Dummy runner for tests that don't care about AttachmentServiceProxy. 44 } else {
45 // Dummy runner for tests that don't have MessageLoop.
45 DVLOG(1) << "Creating dummy MessageLoop for AttachmentServiceProxy."; 46 DVLOG(1) << "Creating dummy MessageLoop for AttachmentServiceProxy.";
46 base::MessageLoop loop; 47 base::MessageLoop loop;
47 // This works because |runner| takes a ref to the proxy. 48 // This works because |runner| takes a ref to the proxy.
48 runner = loop.message_loop_proxy(); 49 runner = base::ThreadTaskRunnerHandle::Get();
49 } 50 }
50 return AttachmentServiceProxyForTest(runner, core_for_test); 51 return AttachmentServiceProxyForTest(runner, core_for_test);
51 } 52 }
52 53
53 AttachmentServiceProxyForTest::~AttachmentServiceProxyForTest() { 54 AttachmentServiceProxyForTest::~AttachmentServiceProxyForTest() {
54 } 55 }
55 56
56 AttachmentServiceProxyForTest::AttachmentServiceProxyForTest( 57 AttachmentServiceProxyForTest::AttachmentServiceProxyForTest(
57 const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner, 58 const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner,
58 const scoped_refptr<Core>& core) 59 const scoped_refptr<Core>& core)
59 : AttachmentServiceProxy(wrapped_task_runner, core) { 60 : AttachmentServiceProxy(wrapped_task_runner, core) {
60 } 61 }
61 62
62 } // namespace syncer 63 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/api/attachments/attachment_store.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698