| OLD | NEW |
| 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 20 matching lines...) Expand all Loading... |
| 31 kPipeline | 31 kPipeline |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 MessageLoopFactory(); | 34 MessageLoopFactory(); |
| 35 | 35 |
| 36 // Get the message loop proxy associated with |type|. A new MessageLoopProxy | 36 // Get the message loop proxy associated with |type|. A new MessageLoopProxy |
| 37 // is created if the factory doesn't have one associated with |type|. | 37 // is created if the factory doesn't have one associated with |type|. |
| 38 scoped_refptr<base::MessageLoopProxy> GetMessageLoop(Type type); | 38 scoped_refptr<base::MessageLoopProxy> GetMessageLoop(Type type); |
| 39 | 39 |
| 40 private: | 40 private: |
| 41 // Only allow scoped_ptr<> to delete factory. | 41 // Restrict who can delete the factory to scoped_ptr<>. scoped_ptr<> uses |
| 42 friend class scoped_ptr<MessageLoopFactory>; | 42 // base::DefaultDeleter. |
| 43 friend struct base::DefaultDeleter<MessageLoopFactory>; |
| 43 ~MessageLoopFactory(); | 44 ~MessageLoopFactory(); |
| 44 | 45 |
| 45 // Returns the thread associated with |type| creating a new thread if needed. | 46 // Returns the thread associated with |type| creating a new thread if needed. |
| 46 base::Thread* GetThread(Type type); | 47 base::Thread* GetThread(Type type); |
| 47 | 48 |
| 48 // Lock used to serialize access for the following data members. | 49 // Lock used to serialize access for the following data members. |
| 49 base::Lock lock_; | 50 base::Lock lock_; |
| 50 | 51 |
| 51 // List of pairs of created threads and their types. We use a list to ensure | 52 // List of pairs of created threads and their types. We use a list to ensure |
| 52 // threads are stopped & deleted in reverse order of creation. | 53 // threads are stopped & deleted in reverse order of creation. |
| 53 typedef std::list<std::pair<Type, base::Thread*> > ThreadList; | 54 typedef std::list<std::pair<Type, base::Thread*> > ThreadList; |
| 54 ThreadList threads_; | 55 ThreadList threads_; |
| 55 | 56 |
| 56 DISALLOW_COPY_AND_ASSIGN(MessageLoopFactory); | 57 DISALLOW_COPY_AND_ASSIGN(MessageLoopFactory); |
| 57 }; | 58 }; |
| 58 | 59 |
| 59 } // namespace media | 60 } // namespace media |
| 60 | 61 |
| 61 #endif // MEDIA_BASE_MESSAGE_LOOP_FACTORY_H_ | 62 #endif // MEDIA_BASE_MESSAGE_LOOP_FACTORY_H_ |
| OLD | NEW |