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

Unified Diff: chrome/browser/sync/glue/data_type_controller.h

Issue 10391080: No longer keep a lingering reference to TypedUrlDataTypeController after PSS exits (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed memory leak. Created 8 years, 7 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: chrome/browser/sync/glue/data_type_controller.h
diff --git a/chrome/browser/sync/glue/data_type_controller.h b/chrome/browser/sync/glue/data_type_controller.h
index 2be6064ca679a53be1a74fa74cfbb6175d7efd62..f7a97933aeaad4b0c6573d5543fba868415c85aa 100644
--- a/chrome/browser/sync/glue/data_type_controller.h
+++ b/chrome/browser/sync/glue/data_type_controller.h
@@ -22,11 +22,25 @@ class SyncError;
namespace browser_sync {
+// The last reference to a DataTypeController should always be released on the
+// UI thread. This is enforced in NonFrontendDataTypeController by blocking
+// until StopAssociation() has finished executing.
+struct ForceDeleteOnUIThread {
+ template<typename T>
+ static void Destruct(const T* x) {
+ if (content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
+ delete x;
+ } else {
+ NOTREACHED();
+ }
+ }
+};
+
// Data type controllers need to be refcounted threadsafe, as they may
// need to run model associator or change processor on other threads.
class DataTypeController
: public base::RefCountedThreadSafe<
- DataTypeController, content::BrowserThread::DeleteOnUIThread>,
+ DataTypeController, ForceDeleteOnUIThread>,
public DataTypeErrorHandler {
public:
enum State {
@@ -105,8 +119,7 @@ class DataTypeController
syncable::ModelType type) OVERRIDE;
protected:
- friend struct content::BrowserThread::DeleteOnThread<
- content::BrowserThread::UI>;
+ friend struct ForceDeleteOnUIThread;
friend class base::DeleteHelper<DataTypeController>;
virtual ~DataTypeController() {}

Powered by Google App Engine
This is Rietveld 408576698