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

Unified Diff: chrome/browser/metrics/thread_watcher.cc

Issue 6575007: Fixed the memory leak of callback Task in PostPingMessage.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/metrics/thread_watcher.cc
===================================================================
--- chrome/browser/metrics/thread_watcher.cc (revision 75833)
+++ chrome/browser/metrics/thread_watcher.cc (working copy)
@@ -104,18 +104,22 @@
// Send a ping message to the watched thread.
Task* callback_task = method_factory_.NewRunnableMethod(
&ThreadWatcher::OnPongMessage, ping_sequence_number_);
- BrowserThread::PostTask(
- thread_id(),
- FROM_HERE,
- NewRunnableFunction(
- &ThreadWatcher::OnPingMessage, thread_id_, callback_task));
-
- // Post a task to check the responsiveness of watched thread.
- MessageLoop::current()->PostDelayedTask(
- FROM_HERE,
- method_factory_.NewRunnableMethod(
- &ThreadWatcher::OnCheckResponsiveness, ping_sequence_number_),
- unresponsive_time_.InMilliseconds());
+ if (BrowserThread::PostTask(
+ thread_id(),
+ FROM_HERE,
+ NewRunnableFunction(
+ &ThreadWatcher::OnPingMessage, thread_id_, callback_task))) {
+ // Post a task to check the responsiveness of watched thread.
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ method_factory_.NewRunnableMethod(
+ &ThreadWatcher::OnCheckResponsiveness, ping_sequence_number_),
+ unresponsive_time_.InMilliseconds());
+ } else {
+ // Watched thread might have gone away, stop watching it.
+ delete callback_task;
+ DeActivateThreadWatching();
+ }
}
void ThreadWatcher::OnPongMessage(uint64 ping_sequence_number) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698