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

Unified Diff: base/memory/singleton.h

Issue 7157001: Implements AudioMessageFilter as member in RenderThread (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 6 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 | content/renderer/media/audio_device.h » ('j') | content/renderer/media/audio_device.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/singleton.h
===================================================================
--- base/memory/singleton.h (revision 89645)
+++ base/memory/singleton.h (working copy)
@@ -109,6 +109,30 @@
static base::subtle::Atomic32 dead_;
};
+// Alternate traits for use with the Singleton<Type>. Identical to
+// DefaultSingletonTraits except that AddRef() will be called on the singleton
+// upon construction and Release() will be called instead of delete when
+// the singleton is destructed.
+template<typename Type>
+struct RefCountedSingletonTraits {
+ // Allocates the reference counted object.
+ static Type* New() {
+ DCHECK(Type::ImplementsThreadSafeReferenceCounting());
+ Type* ptr = new Type();
+ ptr->AddRef();
+ return ptr;
+ }
+
+ // Destroys the reference counted object.
+ static void Delete(Type* x) {
+ DCHECK(Type::ImplementsThreadSafeReferenceCounting());
+ x->Release();
+ }
+
+ static const bool kRegisterAtExit = true;
+ static const bool kAllowedToAccessOnNonjoinableThread = false;
+};
+
template <typename Type> intptr_t
StaticMemorySingletonTraits<Type>::buffer_[kBufferSize];
template <typename Type> base::subtle::Atomic32
« no previous file with comments | « no previous file | content/renderer/media/audio_device.h » ('j') | content/renderer/media/audio_device.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698