Home | History | Annotate | Download | only in sync_driver
      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 "components/sync_driver/data_type_controller.h"
      6 
      7 #include "sync/internal_api/public/base/model_type.h"
      8 #include "sync/internal_api/public/user_share.h"
      9 #include "sync/util/data_type_histogram.h"
     10 
     11 namespace sync_driver {
     12 
     13 DataTypeController::DataTypeController(
     14     scoped_refptr<base::MessageLoopProxy> ui_thread,
     15     const base::Closure& error_callback)
     16     : base::RefCountedDeleteOnMessageLoop<DataTypeController>(ui_thread),
     17       error_callback_(error_callback),
     18       user_share_(NULL) {
     19 }
     20 
     21 DataTypeController::~DataTypeController() {
     22 }
     23 
     24 bool DataTypeController::IsUnrecoverableResult(ConfigureResult result) {
     25   return (result == UNRECOVERABLE_ERROR);
     26 }
     27 
     28 bool DataTypeController::IsSuccessfulResult(ConfigureResult result) {
     29   return (result == OK || result == OK_FIRST_RUN);
     30 }
     31 
     32 syncer::SyncError DataTypeController::CreateAndUploadError(
     33     const tracked_objects::Location& location,
     34     const std::string& message,
     35     syncer::ModelType type) {
     36   if (!error_callback_.is_null())
     37     error_callback_.Run();
     38   return syncer::SyncError(location,
     39                            syncer::SyncError::DATATYPE_ERROR,
     40                            message,
     41                            type);
     42 }
     43 
     44 void DataTypeController::OnUserShareReady(syncer::UserShare* share) {
     45   user_share_ = share;
     46 }
     47 
     48 syncer::UserShare* DataTypeController::user_share() const {
     49   return user_share_;
     50 }
     51 
     52 bool DataTypeController::ReadyForStart() const {
     53   return true;
     54 }
     55 
     56 }  // namespace sync_driver
     57