Upstream version 6.35.121.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   VLOG(1) << "Getting progress for: " << ModelTypeToString(type_);
37   *progress_marker = progress_marker_;
38 }
39
40 void NonBlockingTypeProcessorCore::ProcessGetUpdatesResponse(
41     const sync_pb::DataTypeProgressMarker& progress_marker,
42     const SyncEntityList& applicable_updates,
43     sessions::StatusController* status) {
44   DCHECK(CalledOnValidThread());
45   // TODO(rlarocque): Implement this properly.  crbug.com/351005.
46   VLOG(1) << "Processing updates response for: " << ModelTypeToString(type_);
47   progress_marker_ = progress_marker;
48 }
49
50 void NonBlockingTypeProcessorCore::ApplyUpdates(
51     sessions::StatusController* status) {
52   DCHECK(CalledOnValidThread());
53   // TODO(rlarocque): Implement this properly.  crbug.com/351005.
54   VLOG(1) << "Applying updates for: " << ModelTypeToString(type_);
55 }
56
57 void NonBlockingTypeProcessorCore::PassiveApplyUpdates(
58     sessions::StatusController* status) {
59   NOTREACHED()
60       << "Non-blocking types should never apply updates on sync thread.  "
61       << "ModelType is: " << ModelTypeToString(type_);
62 }
63
64 // CommitContributor implementation.
65 scoped_ptr<CommitContribution>
66 NonBlockingTypeProcessorCore::GetContribution(size_t max_entries) {
67   DCHECK(CalledOnValidThread());
68   // TODO(rlarocque): Implement this properly.  crbug.com/351005.
69   VLOG(1) << "Getting commit contribution for: " << ModelTypeToString(type_);
70   return scoped_ptr<CommitContribution>();
71 }
72
73 base::WeakPtr<NonBlockingTypeProcessorCore>
74 NonBlockingTypeProcessorCore::AsWeakPtr() {
75   return weak_ptr_factory_.GetWeakPtr();
76 }
77
78 }  // namespace syncer