summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-10 18:36:51 +0000
committerdcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-10 18:36:51 +0000
commit1cb1a240b45493ae160fc8d822e332a5ce07d2e1 (patch)
treedfce2084e834a081d2fce94625f541cda9a6bb52
parent2da894c9f540654f4a169b1963974aadd187f260 (diff)
downloadchromium_src-1cb1a240b45493ae160fc8d822e332a5ce07d2e1.zip
chromium_src-1cb1a240b45493ae160fc8d822e332a5ce07d2e1.tar.gz
chromium_src-1cb1a240b45493ae160fc8d822e332a5ce07d2e1.tar.bz2
Eliminated the last few uses of MessageLoop::QuitTask in chrome/
BUG=none TEST=trybots Review URL: http://codereview.chromium.org/8892023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113957 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/history/history.cc2
-rw-r--r--chrome/browser/history/history.h2
-rw-r--r--chrome/browser/history/history_backend.cc10
-rw-r--r--chrome/browser/history/history_backend.h7
-rw-r--r--chrome/browser/history/history_querying_unittest.cc2
-rw-r--r--chrome/browser/history/history_unittest.cc4
-rw-r--r--chrome/browser/visitedlink/visitedlink_master.cc6
-rw-r--r--chrome/browser/visitedlink/visitedlink_master.h13
-rw-r--r--chrome/browser/visitedlink/visitedlink_unittest.cc8
-rw-r--r--chrome/test/base/testing_profile.cc4
10 files changed, 29 insertions, 29 deletions
diff --git a/chrome/browser/history/history.cc b/chrome/browser/history/history.cc
index b9ad686..809ea5a 100644
--- a/chrome/browser/history/history.cc
+++ b/chrome/browser/history/history.cc
@@ -310,7 +310,7 @@ HistoryService::Handle HistoryService::QuerySegmentUsageSince(
from_time, max_result_count);
}
-void HistoryService::SetOnBackendDestroyTask(Task* task) {
+void HistoryService::SetOnBackendDestroyTask(const base::Closure& task) {
ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::SetOnBackendDestroyTask,
MessageLoop::current(), task);
}
diff --git a/chrome/browser/history/history.h b/chrome/browser/history/history.h
index 5d68b60..dcb3064 100644
--- a/chrome/browser/history/history.h
+++ b/chrome/browser/history/history.h
@@ -529,7 +529,7 @@ class HistoryService : public CancelableRequestProvider,
// There can be only one closing task, so this will override any previously
// set task. We will take ownership of the pointer and delete it when done.
// The task will be run on the calling thread (this function is threadsafe).
- void SetOnBackendDestroyTask(Task* task);
+ void SetOnBackendDestroyTask(const base::Closure& task);
// Used for unit testing and potentially importing to get known information
// into the database. This assumes the URL doesn't exist in the database
diff --git a/chrome/browser/history/history_backend.cc b/chrome/browser/history/history_backend.cc
index 18cc3cb..1fa9406 100644
--- a/chrome/browser/history/history_backend.cc
+++ b/chrome/browser/history/history_backend.cc
@@ -9,6 +9,7 @@
#include <set>
#include <vector>
+#include "base/callback.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/file_util.h"
@@ -209,7 +210,6 @@ HistoryBackend::HistoryBackend(const FilePath& history_dir,
ALLOW_THIS_IN_INITIALIZER_LIST(expirer_(this, bookmark_service)),
recent_redirects_(kMaxRedirectCount),
backend_destroy_message_loop_(NULL),
- backend_destroy_task_(NULL),
segment_queried_(false),
bookmark_service_(bookmark_service) {
}
@@ -237,7 +237,7 @@ HistoryBackend::~HistoryBackend() {
text_database_.reset();
}
- if (backend_destroy_task_) {
+ if (!backend_destroy_task_.is_null()) {
// Notify an interested party (typically a unit test) that we're done.
DCHECK(backend_destroy_message_loop_);
backend_destroy_message_loop_->PostTask(FROM_HERE, backend_destroy_task_);
@@ -251,11 +251,9 @@ void HistoryBackend::Init(const std::string& languages, bool force_fail) {
}
void HistoryBackend::SetOnBackendDestroyTask(MessageLoop* message_loop,
- Task* task) {
- if (backend_destroy_task_) {
+ const base::Closure& task) {
+ if (!backend_destroy_task_.is_null())
DLOG(WARNING) << "Setting more than one destroy task, overriding";
- delete backend_destroy_task_;
- }
backend_destroy_message_loop_ = message_loop;
backend_destroy_task_ = task;
}
diff --git a/chrome/browser/history/history_backend.h b/chrome/browser/history/history_backend.h
index 9600df1..23ac69c 100644
--- a/chrome/browser/history/history_backend.h
+++ b/chrome/browser/history/history_backend.h
@@ -334,7 +334,8 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>,
// Sets the task to run and the message loop to run it on when this object
// is destroyed. See HistoryService::SetOnBackendDestroyTask for a more
// complete description.
- void SetOnBackendDestroyTask(MessageLoop* message_loop, Task* task);
+ void SetOnBackendDestroyTask(MessageLoop* message_loop,
+ const base::Closure& task);
// Adds the given rows to the database if it doesn't exist. A visit will be
// added for each given URL at the last visit time in the URLRow if the
@@ -615,9 +616,9 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>,
// Timestamp of the first entry in our database.
base::Time first_recorded_time_;
- // When non-NULL, this is the task that should be invoked on
+ // When set, this is the task that should be invoked on destruction.
MessageLoop* backend_destroy_message_loop_;
- Task* backend_destroy_task_;
+ base::Closure backend_destroy_task_;
// Tracks page transition types.
VisitTracker tracker_;
diff --git a/chrome/browser/history/history_querying_unittest.cc b/chrome/browser/history/history_querying_unittest.cc
index 0ba62fa..fbdc704 100644
--- a/chrome/browser/history/history_querying_unittest.cc
+++ b/chrome/browser/history/history_querying_unittest.cc
@@ -121,7 +121,7 @@ class HistoryQueryTest : public testing::Test {
virtual void TearDown() {
if (history_.get()) {
- history_->SetOnBackendDestroyTask(new MessageLoop::QuitTask);
+ history_->SetOnBackendDestroyTask(MessageLoop::QuitClosure());
history_->Cleanup();
history_ = NULL;
MessageLoop::current()->Run(); // Wait for the other thread.
diff --git a/chrome/browser/history/history_unittest.cc b/chrome/browser/history/history_unittest.cc
index ceb9608..82c285c 100644
--- a/chrome/browser/history/history_unittest.cc
+++ b/chrome/browser/history/history_unittest.cc
@@ -168,7 +168,7 @@ class HistoryTest : public testing::Test {
// Make sure we don't have any event pending that could disrupt the next
// test.
- MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask);
+ MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
MessageLoop::current()->Run();
}
@@ -176,7 +176,7 @@ class HistoryTest : public testing::Test {
DCHECK(history_service_.get());
history_service_->NotifyRenderProcessHostDestruction(0);
- history_service_->SetOnBackendDestroyTask(new MessageLoop::QuitTask);
+ history_service_->SetOnBackendDestroyTask(MessageLoop::QuitClosure());
history_service_->Cleanup();
history_service_ = NULL;
diff --git a/chrome/browser/visitedlink/visitedlink_master.cc b/chrome/browser/visitedlink/visitedlink_master.cc
index 50a8248..f3fbc85 100644
--- a/chrome/browser/visitedlink/visitedlink_master.cc
+++ b/chrome/browser/visitedlink/visitedlink_master.cc
@@ -847,9 +847,9 @@ void VisitedLinkMaster::OnTableRebuildComplete(
table_builder_ = NULL; // Will release our reference to the builder.
// Notify the unit test that the rebuild is complete (will be NULL in prod.)
- if (rebuild_complete_task_.get()) {
- rebuild_complete_task_->Run();
- rebuild_complete_task_.reset(NULL);
+ if (!rebuild_complete_task_.is_null()) {
+ rebuild_complete_task_.Run();
+ rebuild_complete_task_.Reset();
}
}
diff --git a/chrome/browser/visitedlink/visitedlink_master.h b/chrome/browser/visitedlink/visitedlink_master.h
index 87de153..c84e809 100644
--- a/chrome/browser/visitedlink/visitedlink_master.h
+++ b/chrome/browser/visitedlink/visitedlink_master.h
@@ -12,6 +12,7 @@
#include <set>
#include <vector>
+#include "base/callback_forward.h"
#include "base/file_path.h"
#include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h"
@@ -102,9 +103,9 @@ class VisitedLinkMaster : public VisitedLinkCommon {
// Sets a task to execute when the next rebuild from history is complete.
// This is used by unit tests to wait for the rebuild to complete before
// they continue. The pointer will be owned by this object after the call.
- void set_rebuild_complete_task(Task* task) {
- DCHECK(!rebuild_complete_task_.get());
- rebuild_complete_task_.reset(task);
+ void set_rebuild_complete_task(const base::Closure& task) {
+ DCHECK(rebuild_complete_task_.is_null());
+ rebuild_complete_task_ = task;
}
// returns the number of items in the table for testing verification
@@ -359,9 +360,9 @@ class VisitedLinkMaster : public VisitedLinkCommon {
// BrowserProcess. This is provided for unit tests.
HistoryService* history_service_override_;
- // When non-NULL, indicates the task that should be run after the next
- // rebuild from history is complete.
- scoped_ptr<Task> rebuild_complete_task_;
+ // When set, indicates the task that should be run after the next rebuild from
+ // history is complete.
+ base::Closure rebuild_complete_task_;
// Set to prevent us from attempting to rebuild the database from global
// history if we have an error opening the file. This is used for testing,
diff --git a/chrome/browser/visitedlink/visitedlink_unittest.cc b/chrome/browser/visitedlink/visitedlink_unittest.cc
index 487c73d..04728a6 100644
--- a/chrome/browser/visitedlink/visitedlink_unittest.cc
+++ b/chrome/browser/visitedlink/visitedlink_unittest.cc
@@ -106,7 +106,7 @@ class VisitedLinkTest : public testing::Test {
master_.reset(NULL);
if (history_service_.get()) {
- history_service_->SetOnBackendDestroyTask(new MessageLoop::QuitTask);
+ history_service_->SetOnBackendDestroyTask(MessageLoop::QuitClosure());
history_service_->Cleanup();
history_service_ = NULL;
@@ -402,7 +402,7 @@ TEST_F(VisitedLinkTest, Rebuild) {
// complete before we set the task because the rebuild completion message
// is posted to the message loop; until we Run() it, rebuild can not
// complete.
- master_->set_rebuild_complete_task(new MessageLoop::QuitTask);
+ master_->set_rebuild_complete_task(MessageLoop::QuitClosure());
MessageLoop::current()->Run();
// Test that all URLs were written to the database properly.
@@ -423,7 +423,7 @@ TEST_F(VisitedLinkTest, BigImport) {
master_->AddURL(TestURL(i));
// Wait for the rebuild to complete.
- master_->set_rebuild_complete_task(new MessageLoop::QuitTask);
+ master_->set_rebuild_complete_task(MessageLoop::QuitClosure());
MessageLoop::current()->Run();
// Ensure that the right number of URLs are present
@@ -591,7 +591,7 @@ class VisitedLinkEventsTest : public ChromeRenderViewHostTestHarness {
void WaitForCoalescense() {
// Let the timer fire.
MessageLoop::current()->PostDelayedTask(FROM_HERE,
- new MessageLoop::QuitTask(), 110);
+ MessageLoop::QuitClosure(), 110);
MessageLoop::current()->Run();
}
diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc
index 008c871..6a96762 100644
--- a/chrome/test/base/testing_profile.cc
+++ b/chrome/test/base/testing_profile.cc
@@ -259,7 +259,7 @@ void TestingProfile::DestroyHistoryService() {
return;
history_service_->NotifyRenderProcessHostDestruction(0);
- history_service_->SetOnBackendDestroyTask(new MessageLoop::QuitTask);
+ history_service_->SetOnBackendDestroyTask(MessageLoop::QuitClosure());
history_service_->Cleanup();
history_service_ = NULL;
@@ -271,7 +271,7 @@ void TestingProfile::DestroyHistoryService() {
// Make sure we don't have any event pending that could disrupt the next
// test.
- MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask);
+ MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
MessageLoop::current()->Run();
}