| 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 <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // | 26 // |
| 27 // TODO(scherkus): replace this with something simpler http://crbug.com/116873 | 27 // TODO(scherkus): replace this with something simpler http://crbug.com/116873 |
| 28 class MEDIA_EXPORT MessageLoopFactory { | 28 class MEDIA_EXPORT MessageLoopFactory { |
| 29 public: | 29 public: |
| 30 MessageLoopFactory(); | 30 MessageLoopFactory(); |
| 31 | 31 |
| 32 // Get the message loop associated with |name|. A new MessageLoop | 32 // Get the message loop associated with |name|. A new MessageLoop |
| 33 // is created if the factory doesn't have one associated with |name|. | 33 // is created if the factory doesn't have one associated with |name|. |
| 34 // | 34 // |
| 35 // |name| must not be an empty string. | 35 // |name| must not be an empty string. |
| 36 MessageLoop* GetMessageLoop(const std::string& name); | 36 virtual MessageLoop* GetMessageLoop(const std::string& name); |
| 37 | 37 |
| 38 // Get the message loop proxy associated with |name|. A new MessageLoopProxy | 38 // Get the message loop proxy associated with |name|. A new MessageLoopProxy |
| 39 // is created if the factory doesn't have one associated with |name|. | 39 // is created if the factory doesn't have one associated with |name|. |
| 40 // | 40 // |
| 41 // |name| must not be an empty string. | 41 // |name| must not be an empty string. |
| 42 scoped_refptr<base::MessageLoopProxy> GetMessageLoopProxy( | 42 scoped_refptr<base::MessageLoopProxy> GetMessageLoopProxy( |
| 43 const std::string& name); | 43 const std::string& name); |
| 44 | 44 |
| 45 private: | 45 protected: |
| 46 // Only allow scoped_ptr<> to delete factory. | 46 // Only allow scoped_ptr<> to delete factory. |
| 47 friend class scoped_ptr<MessageLoopFactory>; | 47 friend class scoped_ptr<MessageLoopFactory>; |
| 48 ~MessageLoopFactory(); | 48 virtual ~MessageLoopFactory(); |
| 49 | 49 |
| 50 private: |
| 50 // Returns the thread associated with |name| creating a new thread if needed. | 51 // Returns the thread associated with |name| creating a new thread if needed. |
| 51 base::Thread* GetThread(const std::string& name); | 52 base::Thread* GetThread(const std::string& name); |
| 52 | 53 |
| 53 // Lock used to serialize access for the following data members. | 54 // Lock used to serialize access for the following data members. |
| 54 base::Lock lock_; | 55 base::Lock lock_; |
| 55 | 56 |
| 56 typedef std::map<std::string, base::Thread*> ThreadMap; | 57 typedef std::map<std::string, base::Thread*> ThreadMap; |
| 57 ThreadMap thread_map_; | 58 ThreadMap thread_map_; |
| 58 | 59 |
| 59 DISALLOW_COPY_AND_ASSIGN(MessageLoopFactory); | 60 DISALLOW_COPY_AND_ASSIGN(MessageLoopFactory); |
| 60 }; | 61 }; |
| 61 | 62 |
| 62 } // namespace media | 63 } // namespace media |
| 63 | 64 |
| 64 #endif // MEDIA_BASE_MESSAGE_LOOP_FACTORY_H_ | 65 #endif // MEDIA_BASE_MESSAGE_LOOP_FACTORY_H_ |
| OLD | NEW |