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

Unified Diff: chrome/browser/upgrade_detector_impl.cc

Issue 8513020: base::Bind migrations in chrome/browser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: review fix Created 9 years, 1 month 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
« no previous file with comments | « chrome/browser/upgrade_detector_impl.h ('k') | chrome/browser/visitedlink/visitedlink_master.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/upgrade_detector_impl.cc
===================================================================
--- chrome/browser/upgrade_detector_impl.cc (revision 110185)
+++ chrome/browser/upgrade_detector_impl.cc (working copy)
@@ -6,6 +6,7 @@
#include <string>
+#include "base/bind.h"
#include "base/command_line.h"
#include "base/file_path.h"
#include "base/memory/scoped_ptr.h"
@@ -67,7 +68,7 @@
// callback task. Otherwise it just deletes the task.
class DetectUpgradeTask : public Task {
public:
- DetectUpgradeTask(Task* upgrade_detected_task,
+ DetectUpgradeTask(const base::Closure& upgrade_detected_task,
bool* is_unstable_channel,
bool* is_critical_upgrade)
: upgrade_detected_task_(upgrade_detected_task),
@@ -76,10 +77,10 @@
}
virtual ~DetectUpgradeTask() {
- if (upgrade_detected_task_) {
+ if (!upgrade_detected_task_.is_null()) {
// This has to get deleted on the same thread it was created.
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- new DeleteTask<Task>(upgrade_detected_task_));
+ upgrade_detected_task_);
Mark Mentovai 2011/11/18 20:27:45 Aha! In the DetectUpgradeTask destructor, you’re p
}
}
@@ -160,12 +161,12 @@
// Fire off the upgrade detected task.
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
upgrade_detected_task_);
- upgrade_detected_task_ = NULL;
+ upgrade_detected_task_.Reset();
}
}
private:
- Task* upgrade_detected_task_;
+ base::Closure upgrade_detected_task_;
bool* is_unstable_channel_;
bool* is_critical_upgrade_;
};
@@ -173,7 +174,7 @@
} // namespace
UpgradeDetectorImpl::UpgradeDetectorImpl()
- : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)),
+ : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
is_unstable_channel_(false) {
CommandLine command_line(*CommandLine::ForCurrentProcess());
if (command_line.HasSwitch(switches::kDisableBackgroundNetworking))
@@ -197,9 +198,10 @@
}
void UpgradeDetectorImpl::CheckForUpgrade() {
- method_factory_.RevokeAll();
- Task* callback_task =
- method_factory_.NewRunnableMethod(&UpgradeDetectorImpl::UpgradeDetected);
+ weak_factory_.InvalidateWeakPtrs();
+ base::Closure callback_task =
+ base::Bind(&UpgradeDetectorImpl::UpgradeDetected,
+ weak_factory_.GetWeakPtr());
// We use FILE as the thread to run the upgrade detection code on all
// platforms. For Linux, this is because we don't want to block the UI thread
// while launching a background process and reading its output; on the Mac and
« no previous file with comments | « chrome/browser/upgrade_detector_impl.h ('k') | chrome/browser/visitedlink/visitedlink_master.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698