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

Side by Side Diff: chrome/browser/history/history_db_task.h

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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_HISTORY_HISTORY_DB_TASK_H_ 5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_DB_TASK_H_
6 #define CHROME_BROWSER_HISTORY_HISTORY_DB_TASK_H_ 6 #define CHROME_BROWSER_HISTORY_HISTORY_DB_TASK_H_
7 7
8 #include "base/memory/ref_counted.h"
9
10 namespace history { 8 namespace history {
11 9
12 class HistoryBackend; 10 class HistoryBackend;
13 class HistoryDatabase; 11 class HistoryDatabase;
14 12
15 // HistoryDBTask can be used to process arbitrary work on the history backend 13 // HistoryDBTask can be used to process arbitrary work on the history backend
16 // thread. HistoryDBTask is scheduled using HistoryService::ScheduleDBTask. 14 // thread. HistoryDBTask is scheduled using HistoryService::ScheduleDBTask.
17 // When HistoryBackend processes the task it invokes RunOnDBThread. Once the 15 // When HistoryBackend processes the task it invokes RunOnDBThread. Once the
18 // task completes and has not been canceled, DoneRunOnMainThread is invoked back 16 // task completes and has not been canceled, DoneRunOnMainThread is invoked back
19 // on the main thread. 17 // on the main thread.
sky 2014/07/14 20:27:44 Document where destruction occurs.
Bernhard Bauer 2014/07/15 10:17:24 Done.
20 class HistoryDBTask : public base::RefCountedThreadSafe<HistoryDBTask> { 18 class HistoryDBTask {
21 public: 19 public:
20 virtual ~HistoryDBTask() {}
21
22 // Invoked on the database thread. The return value indicates whether the 22 // Invoked on the database thread. The return value indicates whether the
23 // task is done. A return value of true signals the task is done and 23 // task is done. A return value of true signals the task is done and
24 // RunOnDBThread should NOT be invoked again. A return value of false 24 // RunOnDBThread should NOT be invoked again. A return value of false
25 // indicates the task is not done, and should be run again after other 25 // indicates the task is not done, and should be run again after other
26 // tasks are given a chance to be processed. 26 // tasks are given a chance to be processed.
27 virtual bool RunOnDBThread(HistoryBackend* backend, HistoryDatabase* db) = 0; 27 virtual bool RunOnDBThread(HistoryBackend* backend, HistoryDatabase* db) = 0;
28 28
29 // Invoked on the main thread once RunOnDBThread has returned true. This is 29 // Invoked on the main thread once RunOnDBThread has returned true. This is
30 // only invoked if the request was not canceled and returned true from 30 // only invoked if the request was not canceled and returned true from
31 // RunOnDBThread. 31 // RunOnDBThread.
32 virtual void DoneRunOnMainThread() = 0; 32 virtual void DoneRunOnMainThread() = 0;
33
34 protected:
35 friend class base::RefCountedThreadSafe<HistoryDBTask>;
36
37 virtual ~HistoryDBTask() {}
38 }; 33 };
39 34
40 } // namespace history 35 } // namespace history
41 36
42 #endif // CHROME_BROWSER_HISTORY_HISTORY_DB_TASK_H_ 37 #endif // CHROME_BROWSER_HISTORY_HISTORY_DB_TASK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698