| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/sync_driver/non_blocking_data_type_controller.h" | 5 #include "components/sync_driver/non_blocking_data_type_controller.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "sync/engine/model_type_sync_proxy_impl.h" | 10 #include "sync/engine/model_type_sync_proxy_impl.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 base::Bind(&syncer::ModelTypeSyncProxyImpl::Disconnect, | 109 base::Bind(&syncer::ModelTypeSyncProxyImpl::Disconnect, |
| 110 type_sync_proxy_)); | 110 type_sync_proxy_)); |
| 111 current_state_ = DISCONNECTED; | 111 current_state_ = DISCONNECTED; |
| 112 } | 112 } |
| 113 | 113 |
| 114 bool NonBlockingDataTypeController::IsPreferred() const { | 114 bool NonBlockingDataTypeController::IsPreferred() const { |
| 115 return is_preferred_; | 115 return is_preferred_; |
| 116 } | 116 } |
| 117 | 117 |
| 118 bool NonBlockingDataTypeController::IsSyncProxyConnected() const { | 118 bool NonBlockingDataTypeController::IsSyncProxyConnected() const { |
| 119 return task_runner_ != NULL; | 119 return task_runner_.get() != NULL; |
| 120 } | 120 } |
| 121 | 121 |
| 122 bool NonBlockingDataTypeController::IsSyncBackendConnected() const { | 122 bool NonBlockingDataTypeController::IsSyncBackendConnected() const { |
| 123 return sync_context_proxy_; | 123 return sync_context_proxy_; |
| 124 } | 124 } |
| 125 | 125 |
| 126 NonBlockingDataTypeController::TypeState | 126 NonBlockingDataTypeController::TypeState |
| 127 NonBlockingDataTypeController::GetDesiredState() const { | 127 NonBlockingDataTypeController::GetDesiredState() const { |
| 128 if (!IsPreferred()) { | 128 if (!IsPreferred()) { |
| 129 return DISABLED; | 129 return DISABLED; |
| 130 } else if (!IsSyncBackendConnected() || !IsSyncProxyConnected()) { | 130 } else if (!IsSyncBackendConnected() || !IsSyncProxyConnected()) { |
| 131 return DISCONNECTED; | 131 return DISCONNECTED; |
| 132 } else { | 132 } else { |
| 133 return ENABLED; | 133 return ENABLED; |
| 134 } | 134 } |
| 135 } | 135 } |
| 136 | 136 |
| 137 } // namespace sync_driver | 137 } // namespace sync_driver |
| OLD | NEW |