Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(731)

Side by Side Diff: chrome/browser/sync/glue/history_model_worker.cc

Issue 387923002: Make HistoryDBTask not refcounted, and ensure it's destroyed on its origin thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 // Post the work task on |history_service|'s DB thread from the UI 65 // Post the work task on |history_service|'s DB thread from the UI
66 // thread. 66 // thread.
67 void PostWorkerTask(const base::WeakPtr<HistoryService>& history_service, 67 void PostWorkerTask(const base::WeakPtr<HistoryService>& history_service,
68 const syncer::WorkCallback& work, 68 const syncer::WorkCallback& work,
69 base::CancelableTaskTracker* cancelable_tracker, 69 base::CancelableTaskTracker* cancelable_tracker,
70 WaitableEvent* done, 70 WaitableEvent* done,
71 syncer::SyncerError* error) { 71 syncer::SyncerError* error) {
72 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 72 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
73 if (history_service.get()) { 73 if (history_service.get()) {
74 scoped_refptr<WorkerTask> task(new WorkerTask(work, done, error)); 74 WorkerTask* task = new WorkerTask(work, done, error);
75 history_service->ScheduleDBTask(task.get(), cancelable_tracker); 75 history_service->ScheduleDBTask(task, cancelable_tracker);
76 } else { 76 } else {
77 *error = syncer::CANNOT_DO_WORK; 77 *error = syncer::CANNOT_DO_WORK;
78 done->Signal(); 78 done->Signal();
79 } 79 }
80 } 80 }
81 81
82 } // namespace 82 } // namespace
83 83
84 HistoryModelWorker::HistoryModelWorker( 84 HistoryModelWorker::HistoryModelWorker(
85 const base::WeakPtr<HistoryService>& history_service, 85 const base::WeakPtr<HistoryService>& history_service,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 } 127 }
128 128
129 HistoryModelWorker::~HistoryModelWorker() { 129 HistoryModelWorker::~HistoryModelWorker() {
130 // The base::CancelableTaskTracker class is not thread-safe and must only be 130 // 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 131 // 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. 132 // the UI thread, so delete it from the UI thread.
133 BrowserThread::DeleteOnUIThread::Destruct(cancelable_tracker_.release()); 133 BrowserThread::DeleteOnUIThread::Destruct(cancelable_tracker_.release());
134 } 134 }
135 135
136 } // namespace browser_sync 136 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698