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

Unified Diff: trunk/src/chrome/browser/history/history_unittest.cc

Issue 416543006: Revert 284958 "Make HistoryDBTask not refcounted, and ensure it'..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: trunk/src/chrome/browser/history/history_unittest.cc
===================================================================
--- trunk/src/chrome/browser/history/history_unittest.cc (revision 285001)
+++ trunk/src/chrome/browser/history/history_unittest.cc (working copy)
@@ -1502,21 +1502,20 @@
public:
static const int kWantInvokeCount;
- HistoryDBTaskImpl(int* invoke_count, bool* done_invoked)
- : invoke_count_(invoke_count), done_invoked_(done_invoked) {}
+ HistoryDBTaskImpl() : invoke_count(0), done_invoked(false) {}
virtual bool RunOnDBThread(HistoryBackend* backend,
HistoryDatabase* db) OVERRIDE {
- return (++*invoke_count_ == kWantInvokeCount);
+ return (++invoke_count == kWantInvokeCount);
}
virtual void DoneRunOnMainThread() OVERRIDE {
- *done_invoked_ = true;
+ done_invoked = true;
base::MessageLoop::current()->Quit();
}
- int* invoke_count_;
- bool* done_invoked_;
+ int invoke_count;
+ bool done_invoked;
private:
virtual ~HistoryDBTaskImpl() {}
@@ -1532,12 +1531,8 @@
TEST_F(HistoryTest, HistoryDBTask) {
ASSERT_TRUE(history_service_.get());
base::CancelableTaskTracker task_tracker;
- int invoke_count = 0;
- bool done_invoked = false;
- history_service_->ScheduleDBTask(
- scoped_ptr<history::HistoryDBTask>(
- new HistoryDBTaskImpl(&invoke_count, &done_invoked)),
- &task_tracker);
+ scoped_refptr<HistoryDBTaskImpl> task(new HistoryDBTaskImpl());
+ history_service_->ScheduleDBTask(task.get(), &task_tracker);
// Run the message loop. When HistoryDBTaskImpl::DoneRunOnMainThread runs,
// it will stop the message loop. If the test hangs here, it means
// DoneRunOnMainThread isn't being invoked correctly.
@@ -1545,24 +1540,20 @@
CleanupHistoryService();
// WARNING: history has now been deleted.
history_service_.reset();
- ASSERT_EQ(HistoryDBTaskImpl::kWantInvokeCount, invoke_count);
- ASSERT_TRUE(done_invoked);
+ ASSERT_EQ(HistoryDBTaskImpl::kWantInvokeCount, task->invoke_count);
+ ASSERT_TRUE(task->done_invoked);
}
TEST_F(HistoryTest, HistoryDBTaskCanceled) {
ASSERT_TRUE(history_service_.get());
base::CancelableTaskTracker task_tracker;
- int invoke_count = 0;
- bool done_invoked = false;
- history_service_->ScheduleDBTask(
- scoped_ptr<history::HistoryDBTask>(
- new HistoryDBTaskImpl(&invoke_count, &done_invoked)),
- &task_tracker);
+ scoped_refptr<HistoryDBTaskImpl> task(new HistoryDBTaskImpl());
+ history_service_->ScheduleDBTask(task.get(), &task_tracker);
task_tracker.TryCancelAll();
CleanupHistoryService();
// WARNING: history has now been deleted.
history_service_.reset();
- ASSERT_FALSE(done_invoked);
+ ASSERT_FALSE(task->done_invoked);
}
// Create a local delete directive and process it while sync is
« no previous file with comments | « trunk/src/chrome/browser/history/history_service.cc ('k') | trunk/src/chrome/browser/history/in_memory_url_index.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698