Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / sync / engine / non_blocking_type_processor_core.cc
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 #include "sync/engine/non_blocking_type_processor_core.h"
6
7 #include "base/logging.h"
8 #include "sync/engine/commit_contribution.h"
9
10 namespace syncer {
11
12 NonBlockingTypeProcessorCore::NonBlockingTypeProcessorCore(
13       ModelType type,
14       scoped_refptr<base::SequencedTaskRunner> processor_task_runner,
15       base::WeakPtr<NonBlockingTypeProcessor> processor)
16     : type_(type),
17       processor_task_runner_(processor_task_runner),
18       processor_(processor),
19       weak_ptr_factory_(this) {
20   progress_marker_.set_data_type_id(GetSpecificsFieldNumberFromModelType(type));
21 }
22
23 NonBlockingTypeProcessorCore::~NonBlockingTypeProcessorCore() {
24 }
25
26 ModelType NonBlockingTypeProcessorCore::GetModelType() const {
27   DCHECK(CalledOnValidThread());
28   return type_;
29 }
30
31 // UpdateHandler implementation.
32 void NonBlockingTypeProcessorCore::GetDownloadProgress(
33     sync_pb::DataTypeProgressMarker* progress_marker) const {
34   DCHECK(CalledOnValidThread());
35   // TODO(rlarocque): Implement this properly.  crbug.com/351005.
36   DVLOG(1) << "Getting progress for: " << ModelTypeToString(type_);
37   *progress_marker = progress_marker_;
38 }
39
40 void NonBlockingTypeProcessorCore::GetDataTypeContext(
41     sync_pb::DataTypeContext* context) const {
42   // TODO(rlarocque): Implement this properly.  crbug.com/351005.
43   DVLOG(1) << "Getting context for: " << ModelTypeToString(type_);
44   context->Clear();
45 }
46
47 SyncerError NonBlockingTypeProcessorCore::ProcessGetUpdatesResponse(
48     const sync_pb::DataTypeProgressMarker& progress_marker,
49     const sync_pb::DataTypeContext& mutated_context,
50     const SyncEntityList& applicable_updates,
51     sessions::StatusController* status) {
52   DCHECK(CalledOnValidThread());
53   // TODO(rlarocque): Implement this properly.  crbug.com/351005.
54   DVLOG(1) << "Processing updates response for: " << ModelTypeToString(type_);
55   progress_marker_ = progress_marker;
56   return SYNCER_OK;
57 }
58
59 void NonBlockingTypeProcessorCore::ApplyUpdates(
60     sessions::StatusController* status) {
61   DCHECK(CalledOnValidThread());
62   // TODO(rlarocque): Implement this properly.  crbug.com/351005.
63   DVLOG(1) << "Applying updates for: " << ModelTypeToString(type_);
64 }
65
66 void NonBlockingTypeProcessorCore::PassiveApplyUpdates(
67     sessions::StatusController* status) {
68   NOTREACHED()
69       << "Non-blocking types should never apply updates on sync thread.  "
70       << "ModelType is: " << ModelTypeToString(type_);
71 }
72
73 // CommitContributor implementation.
74 scoped_ptr<CommitContribution>
75 NonBlockingTypeProcessorCore::GetContribution(size_t max_entries) {
76   DCHECK(CalledOnValidThread());
77   // TODO(rlarocque): Implement this properly.  crbug.com/351005.
78   DVLOG(1) << "Getting commit contribution for: " << ModelTypeToString(type_);
79   return scoped_ptr<CommitContribution>();
80 }
81
82 base::WeakPtr<NonBlockingTypeProcessorCore>
83 NonBlockingTypeProcessorCore::AsWeakPtr() {
84   return weak_ptr_factory_.GetWeakPtr();
85 }
86
87 }  // namespace syncer