summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-20 00:36:17 +0000
committerajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-20 00:36:17 +0000
commit6c59ab46825b33b24780dace2b403aadf429bc15 (patch)
tree247590feebb80fc389d82633da913993449b7a01 /media
parent0236aa8e8a64cc2ef7d6ebc9dc9e23ccd3dd469e (diff)
downloadchromium_src-6c59ab46825b33b24780dace2b403aadf429bc15.zip
chromium_src-6c59ab46825b33b24780dace2b403aadf429bc15.tar.gz
chromium_src-6c59ab46825b33b24780dace2b403aadf429bc15.tar.bz2
Extend scoped_ptr to be closer to unique_ptr. Support custom deleters, and deleting arrays.
This is based on the modifications by "Geoffrey Romer" <gromer@google.com> to Google's internal version of scoped_ptr<>. All cleaver tricks are his, not mine. :) It brings most of the features of C++11's unique_ptr<> into this class and should eliminate the need for scoped_array<>, scoped_malloc_free<>, and possibly a few other scopers. Please refer to the unique_ptr<> API for documentation. Divergence from unique_ptr<>: 1) DefaultDeleter<T[n]> (sized-arrays) is explicitly disabled because this construct would cause the single-object delete to be called on a pointer to a T[n]. It is impossible to construct a single-object new expression that returns a T[n]*. You can only get this with new[] which should correspond to DefaultDeleter<T[n][]>. This issue has been raised with the C++ LWG as it is possible a unique_ptr<> spec defect. 2) Reference types for Deleters are not supported. This simplifies implementation significantly because there is no need to distinguish between the converting constructor + converting assignment operator and their move constructor + move assignment operator. 4) Move-only Deleters are not supported. Avoids the need to emulate std::forward(). BUG=109874 TBR=dhollowa,kinuko,ananta,hans,scherkus Review URL: https://codereview.chromium.org/11149006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174057 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/base/audio_bus.h2
-rw-r--r--media/base/message_loop_factory.h5
-rw-r--r--media/base/serial_runner.h2
3 files changed, 5 insertions, 4 deletions
diff --git a/media/base/audio_bus.h b/media/base/audio_bus.h
index 5ea4e08..d94ab38 100644
--- a/media/base/audio_bus.h
+++ b/media/base/audio_bus.h
@@ -93,7 +93,7 @@ class MEDIA_EXPORT AudioBus {
void ZeroFramesPartial(int start_frame, int frames);
private:
- friend class scoped_ptr<AudioBus>;
+ friend struct base::DefaultDeleter<AudioBus>;
~AudioBus();
AudioBus(int channels, int frames);
diff --git a/media/base/message_loop_factory.h b/media/base/message_loop_factory.h
index f399b48..0989174 100644
--- a/media/base/message_loop_factory.h
+++ b/media/base/message_loop_factory.h
@@ -38,8 +38,9 @@ class MEDIA_EXPORT MessageLoopFactory {
scoped_refptr<base::MessageLoopProxy> GetMessageLoop(Type type);
private:
- // Only allow scoped_ptr<> to delete factory.
- friend class scoped_ptr<MessageLoopFactory>;
+ // Restrict who can delete the factory to scoped_ptr<>. scoped_ptr<> uses
+ // base::DefaultDeleter.
+ friend struct base::DefaultDeleter<MessageLoopFactory>;
~MessageLoopFactory();
// Returns the thread associated with |type| creating a new thread if needed.
diff --git a/media/base/serial_runner.h b/media/base/serial_runner.h
index 16fa6f3..a59c775 100644
--- a/media/base/serial_runner.h
+++ b/media/base/serial_runner.h
@@ -56,7 +56,7 @@ class SerialRunner {
const Queue& bound_fns, const PipelineStatusCB& done_cb);
private:
- friend class scoped_ptr<SerialRunner>;
+ friend struct base::DefaultDeleter<SerialRunner>;
SerialRunner(const Queue& bound_fns, const PipelineStatusCB& done_cb);
~SerialRunner();