summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/glue/backend_data_type_configurer.h
blob: e7bf09827d1feda238768e1c038e86f1b828ba0a (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
// Copyright (c) 2012 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_BACKEND_DATA_TYPE_CONFIGURER_H_
#define CHROME_BROWSER_SYNC_GLUE_BACKEND_DATA_TYPE_CONFIGURER_H_
#pragma once

#include "base/callback.h"
#include "sync/internal_api/public/configure_reason.h"
#include "sync/internal_api/public/syncable/model_type.h"

namespace browser_sync {

// The DataTypeConfigurer interface abstracts out the action of
// configuring a set of new data types and cleaning up after a set of
// removed data types.
class BackendDataTypeConfigurer {
 public:
  // Enum representing the two "modes" of configuration.
  // WITHOUT_NIGORI is only used by migration.
  enum NigoriState { WITHOUT_NIGORI, WITH_NIGORI };

  // Configures the given set of types to add and remove.
  // |ready_task| is called on the same thread as ConfigureDataTypes
  // is called when configuration is done with the set of data types
  // that failed configuration (i.e., configuration succeeded iff that
  // set is empty).
  //
  // TODO(akalin): Use a Delegate class with
  // OnConfigureSuccess/OnConfigureFailure/OnConfigureRetry instead of
  // a pair of callbacks.  The awkward part is handling when
  // SyncBackendHost calls ConfigureDataTypes on itself to configure
  // Nigori.
  virtual void ConfigureDataTypes(
      sync_api::ConfigureReason reason,
      const syncable::ModelTypeSet& types_to_add,
      const syncable::ModelTypeSet& types_to_remove,
      NigoriState nigori_state,
      const base::Callback<void(syncable::ModelTypeSet)>& ready_task,
      const base::Callback<void()>& retry_callback) = 0;

 protected:
  virtual ~BackendDataTypeConfigurer() {}
};

}  // namespace browser_sync

#endif  // CHROME_BROWSER_SYNC_GLUE_BACKEND_DATA_TYPE_CONFIGURER_H_