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

Side by Side Diff: media/base/message_loop_factory.h

Issue 11149006: Extend scoped_ptr to be closer to unique_ptr. Support custom deleters, and deleting arrays. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: utility -> algorithm. Mac needs it. Created 8 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_BASE_MESSAGE_LOOP_FACTORY_H_ 5 #ifndef MEDIA_BASE_MESSAGE_LOOP_FACTORY_H_
6 #define MEDIA_BASE_MESSAGE_LOOP_FACTORY_H_ 6 #define MEDIA_BASE_MESSAGE_LOOP_FACTORY_H_
7 7
8 #include <list> 8 #include <list>
9 #include <string> 9 #include <string>
10 10
(...skipping 21 matching lines...) Expand all
32 kPipeline 32 kPipeline
33 }; 33 };
34 34
35 MessageLoopFactory(); 35 MessageLoopFactory();
36 36
37 // Get the message loop proxy associated with |type|. A new MessageLoopProxy 37 // Get the message loop proxy associated with |type|. A new MessageLoopProxy
38 // is created if the factory doesn't have one associated with |type|. 38 // is created if the factory doesn't have one associated with |type|.
39 scoped_refptr<base::MessageLoopProxy> GetMessageLoop(Type type); 39 scoped_refptr<base::MessageLoopProxy> GetMessageLoop(Type type);
40 40
41 private: 41 private:
42 // Only allow scoped_ptr<> to delete factory. 42 // Restrict who can delete the factory to scoped_ptr<>. scoped_ptr<> uses
43 friend class scoped_ptr<MessageLoopFactory>; 43 // base::DefaultDeleter.
44 friend struct base::DefaultDeleter<MessageLoopFactory>;
44 ~MessageLoopFactory(); 45 ~MessageLoopFactory();
45 46
46 // Returns the thread associated with |type| creating a new thread if needed. 47 // Returns the thread associated with |type| creating a new thread if needed.
47 base::Thread* GetThread(Type type); 48 base::Thread* GetThread(Type type);
48 49
49 // Lock used to serialize access for the following data members. 50 // Lock used to serialize access for the following data members.
50 base::Lock lock_; 51 base::Lock lock_;
51 52
52 // List of pairs of created threads and their types. We use a list to ensure 53 // List of pairs of created threads and their types. We use a list to ensure
53 // threads are stopped & deleted in reverse order of creation. 54 // threads are stopped & deleted in reverse order of creation.
54 typedef std::list<std::pair<Type, base::Thread*> > ThreadList; 55 typedef std::list<std::pair<Type, base::Thread*> > ThreadList;
55 ThreadList threads_; 56 ThreadList threads_;
56 57
57 DISALLOW_COPY_AND_ASSIGN(MessageLoopFactory); 58 DISALLOW_COPY_AND_ASSIGN(MessageLoopFactory);
58 }; 59 };
59 60
60 } // namespace media 61 } // namespace media
61 62
62 #endif // MEDIA_BASE_MESSAGE_LOOP_FACTORY_H_ 63 #endif // MEDIA_BASE_MESSAGE_LOOP_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698