summaryrefslogtreecommitdiffstats
path: root/sync/engine/non_blocking_type_processor_core.cc
blob: ea0f91889a450efa844daf0a90938b2c5a9258ae (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Copyright 2014 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.

#include "sync/engine/non_blocking_type_processor_core.h"

#include "base/logging.h"
#include "sync/engine/commit_contribution.h"

namespace syncer {

NonBlockingTypeProcessorCore::NonBlockingTypeProcessorCore(
      ModelType type,
      scoped_refptr<base::SequencedTaskRunner> processor_task_runner,
      base::WeakPtr<NonBlockingTypeProcessor> processor)
    : type_(type),
      processor_task_runner_(processor_task_runner),
      processor_(processor),
      weak_ptr_factory_(this) {
  progress_marker_.set_data_type_id(GetSpecificsFieldNumberFromModelType(type));
}

NonBlockingTypeProcessorCore::~NonBlockingTypeProcessorCore() {
}

ModelType NonBlockingTypeProcessorCore::GetModelType() const {
  DCHECK(CalledOnValidThread());
  return type_;
}

// UpdateHandler implementation.
void NonBlockingTypeProcessorCore::GetDownloadProgress(
    sync_pb::DataTypeProgressMarker* progress_marker) const {
  DCHECK(CalledOnValidThread());
  // TODO(rlarocque): Implement this properly.  crbug.com/351005.
  DVLOG(1) << "Getting progress for: " << ModelTypeToString(type_);
  *progress_marker = progress_marker_;
}

void NonBlockingTypeProcessorCore::GetDataTypeContext(
    sync_pb::DataTypeContext* context) const {
  // TODO(rlarocque): Implement this properly.  crbug.com/351005.
  DVLOG(1) << "Getting context for: " << ModelTypeToString(type_);
  context->Clear();
}

SyncerError NonBlockingTypeProcessorCore::ProcessGetUpdatesResponse(
    const sync_pb::DataTypeProgressMarker& progress_marker,
    const sync_pb::DataTypeContext& mutated_context,
    const SyncEntityList& applicable_updates,
    sessions::StatusController* status) {
  DCHECK(CalledOnValidThread());
  // TODO(rlarocque): Implement this properly.  crbug.com/351005.
  DVLOG(1) << "Processing updates response for: " << ModelTypeToString(type_);
  progress_marker_ = progress_marker;
  return SYNCER_OK;
}

void NonBlockingTypeProcessorCore::ApplyUpdates(
    sessions::StatusController* status) {
  DCHECK(CalledOnValidThread());
  // TODO(rlarocque): Implement this properly.  crbug.com/351005.
  DVLOG(1) << "Applying updates for: " << ModelTypeToString(type_);
}

void NonBlockingTypeProcessorCore::PassiveApplyUpdates(
    sessions::StatusController* status) {
  NOTREACHED()
      << "Non-blocking types should never apply updates on sync thread.  "
      << "ModelType is: " << ModelTypeToString(type_);
}

// CommitContributor implementation.
scoped_ptr<CommitContribution>
NonBlockingTypeProcessorCore::GetContribution(size_t max_entries) {
  DCHECK(CalledOnValidThread());
  // TODO(rlarocque): Implement this properly.  crbug.com/351005.
  DVLOG(1) << "Getting commit contribution for: " << ModelTypeToString(type_);
  return scoped_ptr<CommitContribution>();
}

base::WeakPtr<NonBlockingTypeProcessorCore>
NonBlockingTypeProcessorCore::AsWeakPtr() {
  return weak_ptr_factory_.GetWeakPtr();
}

}  // namespace syncer