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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_DB_TASK_H_ 6 #define CHROME_BROWSER_HISTORY_HISTORY_DB_TASK_H_ 7 8 namespace history { 9 10 class HistoryBackend; 11 class HistoryDatabase; 12 13 // HistoryDBTask can be used to process arbitrary work on the history backend 14 // thread. HistoryDBTask is scheduled using HistoryService::ScheduleDBTask. 15 // When HistoryBackend processes the task it invokes RunOnDBThread. Once the 16 // task completes and has not been canceled, DoneRunOnMainThread is invoked back 17 // on the main thread, after which this object is destroyed, also on the 18 // main thread. 19 class HistoryDBTask { 20 public: 21 virtual ~HistoryDBTask() {} 22 23 // Invoked on the database thread. The return value indicates whether the 24 // task is done. A return value of true signals the task is done and 25 // RunOnDBThread should NOT be invoked again. A return value of false 26 // indicates the task is not done, and should be run again after other 27 // tasks are given a chance to be processed. 28 virtual bool RunOnDBThread(HistoryBackend* backend, HistoryDatabase* db) = 0; 29 30 // Invoked on the main thread once RunOnDBThread has returned true. This is 31 // only invoked if the request was not canceled and returned true from 32 // RunOnDBThread. 33 virtual void DoneRunOnMainThread() = 0; 34 }; 35 36 } // namespace history 37 38 #endif // CHROME_BROWSER_HISTORY_HISTORY_DB_TASK_H_ 39