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 COMPONENTS_SYNC_DRIVER_SYNC_API_COMPONENT_FACTORY_H_
6 #define COMPONENTS_SYNC_DRIVER_SYNC_API_COMPONENT_FACTORY_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/weak_ptr.h"
10 #include "sync/api/syncable_service.h"
11 #include "sync/internal_api/public/attachments/attachment_service.h"
12 #include "sync/internal_api/public/base/model_type.h"
14 namespace sync_driver
{
16 // This factory provides sync driver code with the model type specific sync/api
17 // service (like SyncableService) implementations.
18 class SyncApiComponentFactory
{
20 virtual ~SyncApiComponentFactory() {}
22 // Returns a weak pointer to the syncable service specified by |type|.
23 // Weak pointer may be unset if service is already destroyed.
24 // Note: Should only be called from the model type thread.
25 virtual base::WeakPtr
<syncer::SyncableService
> GetSyncableServiceForType(
26 syncer::ModelType type
) = 0;
28 // Creates attachment service.
29 // Note: Should only be called from the model type thread.
31 // |store_birthday| is the store birthday. Must not be empty.
33 // |model_type| is the model type this AttachmentService will be used with.
35 // |delegate| is optional delegate for AttachmentService to notify about
36 // asynchronous events (AttachmentUploaded). Pass NULL if delegate is not
37 // provided. AttachmentService doesn't take ownership of delegate, the pointer
38 // must be valid throughout AttachmentService lifetime.
39 virtual scoped_ptr
<syncer::AttachmentService
> CreateAttachmentService(
40 scoped_ptr
<syncer::AttachmentStoreForSync
> attachment_store
,
41 const syncer::UserShare
& user_share
,
42 const std::string
& store_birthday
,
43 syncer::ModelType model_type
,
44 syncer::AttachmentService::Delegate
* delegate
) = 0;
47 } // namespace sync_driver
49 #endif // COMPONENTS_SYNC_DRIVER_SYNC_API_COMPONENT_FACTORY_H_