summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/glue/syncable_service_adapter.h
blob: f6401d4c0665dbc07924a5c4dff23fc4e324d4b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_SYNC_GLUE_SYNCABLE_SERVICE_ADAPTER_H_
#define CHROME_BROWSER_SYNC_GLUE_SYNCABLE_SERVICE_ADAPTER_H_
#pragma once

#include <vector>

#include "base/compiler_specific.h"
#include "chrome/browser/sync/api/syncable_service.h"
#include "chrome/browser/sync/glue/model_associator.h"

class SyncableService;

namespace browser_sync {

class GenericChangeProcessor;

// An adapter to handle transitioning from model associator's to syncable
// services. Implements the model associator interface, invoking the
// provided SyncableService as necessary.
class SyncableServiceAdapter : public AssociatorInterface {
 public:
  explicit SyncableServiceAdapter(syncable::ModelType type,
                                  SyncableService* service,
                                  GenericChangeProcessor* sync_processor);
  virtual ~SyncableServiceAdapter();

  // AssociatorInterface implementation.
  virtual bool AssociateModels() OVERRIDE;
  virtual bool DisassociateModels() OVERRIDE;
  virtual bool SyncModelHasUserCreatedNodes(bool* has_nodes) OVERRIDE;
  virtual void AbortAssociation() OVERRIDE;
  virtual bool CryptoReadyIfNecessary() OVERRIDE;

 private:
  // Whether the SyncableService we wrap is currently syncing or not.
  bool syncing_;

  // The data type being provided by this service.
  syncable::ModelType type_;

  // A pointer to the actual local syncable service, which performs all the
  // real work.
  SyncableService* service_;

  // The datatype's SyncChange handler that interacts with the sync db.
  GenericChangeProcessor* sync_processor_;

  DISALLOW_COPY_AND_ASSIGN(SyncableServiceAdapter);
};

}  // namespace browser_sync

#endif  // CHROME_BROWSER_SYNC_GLUE_SYNCABLE_SERVICE_ADAPTER_H_