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/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 93 |
94 void HistoryModelWorker::RegisterForLoopDestruction() { | 94 void HistoryModelWorker::RegisterForLoopDestruction() { |
95 CHECK(history_service_.get()); | 95 CHECK(history_service_.get()); |
96 history_service_->ScheduleDBTask( | 96 history_service_->ScheduleDBTask( |
97 scoped_ptr<history::HistoryDBTask>(new AddDBThreadObserverTask( | 97 scoped_ptr<history::HistoryDBTask>(new AddDBThreadObserverTask( |
98 base::Bind(&HistoryModelWorker::RegisterOnDBThread, this))), | 98 base::Bind(&HistoryModelWorker::RegisterOnDBThread, this))), |
99 cancelable_tracker_.get()); | 99 cancelable_tracker_.get()); |
100 } | 100 } |
101 | 101 |
102 void HistoryModelWorker::RegisterOnDBThread() { | 102 void HistoryModelWorker::RegisterOnDBThread() { |
103 base::MessageLoop::current()->AddDestructionObserver(this); | |
104 SetWorkingLoopToCurrent(); | 103 SetWorkingLoopToCurrent(); |
105 } | 104 } |
106 | 105 |
107 syncer::SyncerError HistoryModelWorker::DoWorkAndWaitUntilDoneImpl( | 106 syncer::SyncerError HistoryModelWorker::DoWorkAndWaitUntilDoneImpl( |
108 const syncer::WorkCallback& work) { | 107 const syncer::WorkCallback& work) { |
109 syncer::SyncerError error = syncer::UNSET; | 108 syncer::SyncerError error = syncer::UNSET; |
110 if (BrowserThread::PostTask(BrowserThread::UI, | 109 if (BrowserThread::PostTask(BrowserThread::UI, |
111 FROM_HERE, | 110 FROM_HERE, |
112 base::Bind(&PostWorkerTask, | 111 base::Bind(&PostWorkerTask, |
113 history_service_, | 112 history_service_, |
(...skipping 13 matching lines...) Expand all Loading... |
127 } | 126 } |
128 | 127 |
129 HistoryModelWorker::~HistoryModelWorker() { | 128 HistoryModelWorker::~HistoryModelWorker() { |
130 // The base::CancelableTaskTracker class is not thread-safe and must only be | 129 // The base::CancelableTaskTracker class is not thread-safe and must only be |
131 // used from a single thread but the current object may not be destroyed from | 130 // used from a single thread but the current object may not be destroyed from |
132 // the UI thread, so delete it from the UI thread. | 131 // the UI thread, so delete it from the UI thread. |
133 BrowserThread::DeleteOnUIThread::Destruct(cancelable_tracker_.release()); | 132 BrowserThread::DeleteOnUIThread::Destruct(cancelable_tracker_.release()); |
134 } | 133 } |
135 | 134 |
136 } // namespace browser_sync | 135 } // namespace browser_sync |
OLD | NEW |