summaryrefslogtreecommitdiffstats
path: root/sync/api/model_type_change_processor.h
blob: 91f7380aa547412a5dc0f287952aec2067355656 (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
58
59
// Copyright 2015 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 SYNC_API_MODEL_TYPE_CHANGE_PROCESSOR_H_
#define SYNC_API_MODEL_TYPE_CHANGE_PROCESSOR_H_

#include <string>

#include "base/memory/scoped_ptr.h"
#include "sync/api/entity_data.h"
#include "sync/base/sync_export.h"
#include "sync/internal_api/public/activation_context.h"

namespace syncer {
class SyncError;
}  // namespace syncer

namespace syncer_v2 {

class MetadataBatch;
class MetadataChangeList;

// Interface used by the ModelTypeService to inform sync of local
// changes.
class SYNC_EXPORT ModelTypeChangeProcessor {
 public:
  typedef base::Callback<void(syncer::SyncError, scoped_ptr<ActivationContext>)>
      StartCallback;

  ModelTypeChangeProcessor();
  virtual ~ModelTypeChangeProcessor();

  // Inform the processor of a new or updated entity. The |entity_data| param
  // does not need to be fully set, but it should at least have specifics and
  // non-unique name. The processor will fill in the rest if the service does
  // not have a reason to care.
  virtual void Put(const std::string& client_tag,
                   scoped_ptr<EntityData> entity_data,
                   MetadataChangeList* metadata_change_list) = 0;

  // Inform the processor of a deleted entity.
  virtual void Delete(const std::string& client_tag,
                      MetadataChangeList* metadata_change_list) = 0;

  // Accept the initial sync metadata loaded by the service. This should be
  // called as soon as the metadata is available to the service.
  virtual void OnMetadataLoaded(scoped_ptr<MetadataBatch> batch) = 0;

  // Called by the DataTypeController to gather additional information needed
  // before a CommitQueue object can be created for this model type. Once the
  // metadata has been loaded, the info is collected and given to |callback|.
  // Once called, this can only be called again if sync is disconnected.
  virtual void OnSyncStarting(const StartCallback& callback) = 0;
};

}  // namespace syncer_v2

#endif  // SYNC_API_MODEL_TYPE_CHANGE_PROCESSOR_H_