summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authordmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-05 20:27:59 +0000
committerdmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-05 20:27:59 +0000
commit027dbf4bc5eed13b01719fb0068fbf8aa31e9a18 (patch)
tree77a764de6e78ef888ac7e018855407f1a18c8150 /content
parent7bd40d378209807d6a58173fc9f0ae2427c632cf (diff)
downloadchromium_src-027dbf4bc5eed13b01719fb0068fbf8aa31e9a18.zip
chromium_src-027dbf4bc5eed13b01719fb0068fbf8aa31e9a18.tar.gz
chromium_src-027dbf4bc5eed13b01719fb0068fbf8aa31e9a18.tar.bz2
Encourage reliability of code using browser thread.
I had a leak that occurred because the return value from DeleteSoon was not being checked. It looked like this: { scoped_ptr<AThing> foo = new AThing; BrowserThread browser_ui_thread(BrowserThread::UI, &loop); .... } Turned out the leak occurred because AThing was set to only delete itself on a UI browser thread, but browser_ui_thread was going out of scope before delete was being called. Adding the DLOG to DeleteSoon helps expose these errors. BUG=NONE TEST=BUILD Review URL: http://codereview.chromium.org/6691044 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80524 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/browser_thread.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/content/browser/browser_thread.h b/content/browser/browser_thread.h
index 8a67f3d..b54f5fe 100644
--- a/content/browser/browser_thread.h
+++ b/content/browser/browser_thread.h
@@ -6,6 +6,9 @@
#define CONTENT_BROWSER_BROWSER_THREAD_H_
#pragma once
+#if defined(UNIT_TEST)
+#include "base/logging.h"
+#endif // UNIT_TEST
#include "base/synchronization/lock.h"
#include "base/task.h"
#include "base/threading/thread.h"
@@ -161,7 +164,13 @@ class BrowserThread : public base::Thread {
if (CurrentlyOn(thread)) {
delete x;
} else {
- DeleteSoon(thread, FROM_HERE, x);
+ if (!DeleteSoon(thread, FROM_HERE, x)) {
+#if defined(UNIT_TEST)
+ // Only logged under unit testing because leaks at shutdown
+ // are acceptable under normal circumstances.
+ LOG(ERROR) << "DeleteSoon failed on thread " << thread;
+#endif // UNIT_TEST
+ }
}
}
};