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
3 // found in the LICENSE file.
5 #ifndef SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_SERVICE_PROXY_FOR_TEST_H_
6 #define SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_SERVICE_PROXY_FOR_TEST_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/weak_ptr.h"
10 #include "sync/base/sync_export.h"
11 #include "sync/internal_api/public/attachments/attachment_service_proxy.h"
15 // An self-contained AttachmentServiceProxy to reduce boilerplate code in tests.
17 // Constructs and owns an AttachmentService suitable for use in tests.
18 // NOTE: This class does not require the current thread to have a MessageLoop,
19 // however all methods will effectively become no-op stubs in that case.
20 class SYNC_EXPORT AttachmentServiceProxyForTest
21 : public AttachmentServiceProxy
{
23 static AttachmentServiceProxy
Create();
24 ~AttachmentServiceProxyForTest() override
;
27 // A Core that owns the wrapped AttachmentService.
28 class OwningCore
: public AttachmentServiceProxy::Core
{
31 scoped_ptr
<AttachmentService
>,
32 scoped_ptr
<base::WeakPtrFactory
<AttachmentService
> > weak_ptr_factory
);
35 ~OwningCore() override
;
37 scoped_ptr
<AttachmentService
> wrapped_
;
38 // WeakPtrFactory for wrapped_. See Create() for why this is a scoped_ptr.
39 scoped_ptr
<base::WeakPtrFactory
<AttachmentService
> > weak_ptr_factory_
;
41 DISALLOW_COPY_AND_ASSIGN(OwningCore
);
44 AttachmentServiceProxyForTest(
45 const scoped_refptr
<base::SequencedTaskRunner
>& wrapped_task_runner
,
46 const scoped_refptr
<Core
>& core
);
51 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_SERVICE_PROXY_FOR_TEST_H_