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.
4
5#ifndef COMPONENTS_SYNC_DRIVER_GENERIC_CHANGE_PROCESSOR_FACTORY_H_
6#define COMPONENTS_SYNC_DRIVER_GENERIC_CHANGE_PROCESSOR_FACTORY_H_
7
8#include "base/memory/weak_ptr.h"
9#include "sync/internal_api/public/base/model_type.h"
10
11namespace syncer {
12class AttachmentService;
13class SyncableService;
14class SyncMergeResult;
15struct UserShare;
16}
17
18namespace sync_driver {
19
20class DataTypeErrorHandler;
21class GenericChangeProcessor;
22class SyncApiComponentFactory;
23
24// Because GenericChangeProcessors are created and used only from the model
25// thread, their lifetime is strictly shorter than other components like
26// DataTypeController, which live before / after communication with model
27// threads begins and ends.
28// The GCP is created "on the fly" at just the right time, on just the right
29// thread. Given that, we use a factory to instantiate GenericChangeProcessors
30// so that tests can choose to use a fake processor (i.e instead of injection).
31// |sync_factory| is used to create AttachmentServicefor GenericChangeProcessor.
32// It is not retained after CreateGenericChangeProcessor exits.
33class GenericChangeProcessorFactory {
34 public:
35  GenericChangeProcessorFactory();
36  virtual ~GenericChangeProcessorFactory();
37  virtual scoped_ptr<GenericChangeProcessor> CreateGenericChangeProcessor(
38      syncer::ModelType type,
39      syncer::UserShare* user_share,
40      DataTypeErrorHandler* error_handler,
41      const base::WeakPtr<syncer::SyncableService>& local_service,
42      const base::WeakPtr<syncer::SyncMergeResult>& merge_result,
43      SyncApiComponentFactory* sync_factory);
44
45 private:
46  DISALLOW_COPY_AND_ASSIGN(GenericChangeProcessorFactory);
47};
48
49}  // namespace sync_driver
50
51#endif  // COMPONENTS_SYNC_DRIVER_GENERIC_CHANGE_PROCESSOR_FACTORY_H_
52