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 browser_sync {
     12 
     13 DataTypeController::DataTypeController(
     14     scoped_refptr<base::MessageLoopProxy> ui_thread,
     15     const base::Closure& error_callback,
     16     const DisableTypeCallback& disable_callback)
     17     : base::RefCountedDeleteOnMessageLoop<DataTypeController>(ui_thread),
     18       error_callback_(error_callback),
     19       disable_callback_(disable_callback),
     20       user_share_(NULL) {
     21 }
     22 
     23 DataTypeController::~DataTypeController() {
     24 }
     25 
     26 bool DataTypeController::IsUnrecoverableResult(StartResult result) {
     27   return (result == UNRECOVERABLE_ERROR);
     28 }
     29 
     30 bool DataTypeController::IsSuccessfulResult(StartResult result) {
     31   return (result == OK || result == OK_FIRST_RUN);
     32 }
     33 
     34 syncer::SyncError DataTypeController::CreateAndUploadError(
     35     const tracked_objects::Location& location,
     36     const std::string& message,
     37     syncer::ModelType type) {
     38   if (!error_callback_.is_null())
     39     error_callback_.Run();
     40   return syncer::SyncError(location,
     41                            syncer::SyncError::DATATYPE_ERROR,
     42                            message,
     43                            type);
     44 }
     45 
     46 void DataTypeController::OnUserShareReady(syncer::UserShare* share) {
     47   user_share_ = share;
     48 }
     49 
     50 syncer::UserShare* DataTypeController::user_share() const {
     51   return user_share_;
     52 }
     53 
     54 DataTypeController::DisableTypeCallback
     55 DataTypeController::disable_callback() {
     56   return disable_callback_;
     57 }
     58 
     59 bool DataTypeController::ReadyForStart() const {
     60   return true;
     61 }
     62 
     63 }  // namespace browser_sync
     64