| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/sync/glue/history_model_worker.h" | 5 #include "chrome/browser/sync/glue/history_model_worker.h" |
| 6 | 6 |
| 7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "chrome/browser/history/history_service.h" | 10 #include "chrome/browser/history/history_service.h" |
| 11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
| 12 | 12 |
| 13 using base::WaitableEvent; | 13 using base::WaitableEvent; |
| 14 using content::BrowserThread; | 14 using content::BrowserThread; |
| 15 | 15 |
| 16 namespace browser_sync { | 16 namespace browser_sync { |
| 17 | 17 |
| 18 class WorkerTask : public HistoryDBTask { | 18 class WorkerTask : public HistoryDBTask { |
| 19 public: | 19 public: |
| 20 WorkerTask( | 20 WorkerTask( |
| 21 const syncer::WorkCallback& work, | 21 const syncer::WorkCallback& work, |
| 22 WaitableEvent* done, | 22 WaitableEvent* done, |
| 23 syncer::SyncerError* error) | 23 syncer::SyncerError* error) |
| 24 : work_(work), done_(done), error_(error) {} | 24 : work_(work), done_(done), error_(error) {} |
| 25 | 25 |
| 26 virtual bool RunOnDBThread(history::HistoryBackend* backend, | 26 virtual bool RunOnDBThread(history::HistoryBackend* backend, |
| 27 history::HistoryDatabase* db) { | 27 history::HistoryDatabase* db) OVERRIDE { |
| 28 *error_ = work_.Run(); | 28 *error_ = work_.Run(); |
| 29 done_->Signal(); | 29 done_->Signal(); |
| 30 return true; | 30 return true; |
| 31 } | 31 } |
| 32 | 32 |
| 33 // Since the DoWorkAndWaitUntilDone() is syncronous, we don't need to run any | 33 // Since the DoWorkAndWaitUntilDone() is syncronous, we don't need to run any |
| 34 // code asynchronously on the main thread after completion. | 34 // code asynchronously on the main thread after completion. |
| 35 virtual void DoneRunOnMainThread() {} | 35 virtual void DoneRunOnMainThread() OVERRIDE {} |
| 36 | 36 |
| 37 protected: | 37 protected: |
| 38 virtual ~WorkerTask() {} | 38 virtual ~WorkerTask() {} |
| 39 | 39 |
| 40 syncer::WorkCallback work_; | 40 syncer::WorkCallback work_; |
| 41 WaitableEvent* done_; | 41 WaitableEvent* done_; |
| 42 syncer::SyncerError* error_; | 42 syncer::SyncerError* error_; |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 namespace { | 45 namespace { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 return error; | 85 return error; |
| 86 } | 86 } |
| 87 | 87 |
| 88 syncer::ModelSafeGroup HistoryModelWorker::GetModelSafeGroup() { | 88 syncer::ModelSafeGroup HistoryModelWorker::GetModelSafeGroup() { |
| 89 return syncer::GROUP_HISTORY; | 89 return syncer::GROUP_HISTORY; |
| 90 } | 90 } |
| 91 | 91 |
| 92 HistoryModelWorker::~HistoryModelWorker() {} | 92 HistoryModelWorker::~HistoryModelWorker() {} |
| 93 | 93 |
| 94 } // namespace browser_sync | 94 } // namespace browser_sync |
| OLD | NEW |