| 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_ui_data_type_controller.h" | 5 #include "components/sync_driver/non_ui_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/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 void UnblockBackendTasks() { | 124 void UnblockBackendTasks() { |
| 125 blocked_ = false; | 125 blocked_ = false; |
| 126 for (std::vector<PendingTask>::const_iterator it = pending_tasks_.begin(); | 126 for (std::vector<PendingTask>::const_iterator it = pending_tasks_.begin(); |
| 127 it != pending_tasks_.end(); ++it) { | 127 it != pending_tasks_.end(); ++it) { |
| 128 PostTaskOnBackendThread(it->from_here, it->task); | 128 PostTaskOnBackendThread(it->from_here, it->task); |
| 129 } | 129 } |
| 130 pending_tasks_.clear(); | 130 pending_tasks_.clear(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 virtual SharedChangeProcessor* CreateSharedChangeProcessor() OVERRIDE { | 133 virtual SharedChangeProcessor* CreateSharedChangeProcessor() OVERRIDE { |
| 134 return change_processor_; | 134 return change_processor_.get(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 protected: | 137 protected: |
| 138 virtual bool PostTaskOnBackendThread( | 138 virtual bool PostTaskOnBackendThread( |
| 139 const tracked_objects::Location& from_here, | 139 const tracked_objects::Location& from_here, |
| 140 const base::Closure& task) OVERRIDE { | 140 const base::Closure& task) OVERRIDE { |
| 141 if (blocked_) { | 141 if (blocked_) { |
| 142 pending_tasks_.push_back(PendingTask(from_here, task)); | 142 pending_tasks_.push_back(PendingTask(from_here, task)); |
| 143 return true; | 143 return true; |
| 144 } else { | 144 } else { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 : backend_thread_("dbthread") {} | 189 : backend_thread_("dbthread") {} |
| 190 | 190 |
| 191 virtual void SetUp() OVERRIDE { | 191 virtual void SetUp() OVERRIDE { |
| 192 backend_thread_.Start(); | 192 backend_thread_.Start(); |
| 193 change_processor_ = new SharedChangeProcessorMock(); | 193 change_processor_ = new SharedChangeProcessorMock(); |
| 194 // All of these are refcounted, so don't need to be released. | 194 // All of these are refcounted, so don't need to be released. |
| 195 dtc_mock_ = new StrictMock<NonUIDataTypeControllerMock>(); | 195 dtc_mock_ = new StrictMock<NonUIDataTypeControllerMock>(); |
| 196 non_ui_dtc_ = | 196 non_ui_dtc_ = |
| 197 new NonUIDataTypeControllerFake(NULL, | 197 new NonUIDataTypeControllerFake(NULL, |
| 198 dtc_mock_.get(), | 198 dtc_mock_.get(), |
| 199 change_processor_, | 199 change_processor_.get(), |
| 200 backend_thread_.message_loop_proxy()); | 200 backend_thread_.message_loop_proxy()); |
| 201 } | 201 } |
| 202 | 202 |
| 203 virtual void TearDown() OVERRIDE { | 203 virtual void TearDown() OVERRIDE { |
| 204 backend_thread_.Stop(); | 204 backend_thread_.Stop(); |
| 205 } | 205 } |
| 206 | 206 |
| 207 void WaitForDTC() { | 207 void WaitForDTC() { |
| 208 WaitableEvent done(true, false); | 208 WaitableEvent done(true, false); |
| 209 backend_thread_.message_loop_proxy()->PostTask( | 209 backend_thread_.message_loop_proxy()->PostTask( |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 &NonUIDataTypeControllerFake:: | 495 &NonUIDataTypeControllerFake:: |
| 496 OnSingleDataTypeUnrecoverableError, | 496 OnSingleDataTypeUnrecoverableError, |
| 497 non_ui_dtc_.get(), | 497 non_ui_dtc_.get(), |
| 498 error)); | 498 error)); |
| 499 WaitForDTC(); | 499 WaitForDTC(); |
| 500 } | 500 } |
| 501 | 501 |
| 502 } // namespace | 502 } // namespace |
| 503 | 503 |
| 504 } // namespace sync_driver | 504 } // namespace sync_driver |
| OLD | NEW |