Index: media/base/message_loop_factory.h |
diff --git a/media/base/message_loop_factory.h b/media/base/message_loop_factory.h |
index 7227840eb902ff2ce4106932e604705d7035ce4c..9efda98ce00f759acbe500f03122a99e001a6017 100644 |
--- a/media/base/message_loop_factory.h |
+++ b/media/base/message_loop_factory.h |
@@ -1,43 +1,58 @@ |
-// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
#ifndef MEDIA_BASE_MESSAGE_LOOP_FACTORY_H_ |
#define MEDIA_BASE_MESSAGE_LOOP_FACTORY_H_ |
+#include <map> |
#include <string> |
#include "base/memory/ref_counted.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/message_loop_proxy.h" |
+#include "base/synchronization/lock.h" |
#include "media/base/media_export.h" |
class MessageLoop; |
+namespace base { |
+class Thread; |
+} |
+ |
namespace media { |
// Factory object that manages named MessageLoops. |
class MEDIA_EXPORT MessageLoopFactory { |
public: |
+ MessageLoopFactory(); |
+ |
// Get the message loop associated with |name|. A new MessageLoop |
// is created if the factory doesn't have one associated with |name|. |
- // NULL is returned if |name| is an empty string, or a new |
- // MessageLoop needs to be created and a failure occurs during the |
- // creation process. |
- virtual MessageLoop* GetMessageLoop(const std::string& name) = 0; |
+ // NULL is returned if |name| is an empty string. |
+ MessageLoop* GetMessageLoop(const std::string& name); |
// Get the message loop proxy associated with |name|. A new MessageLoopProxy |
// is created if the factory doesn't have one associated with |name|. |
- // NULL is returned if |name| is an empty string, or a new |
- // MessageLoop needs to be created and a failure occurs during the |
- // creation process. |
- virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoopProxy( |
- const std::string& name) = 0; |
+ // NULL is returned if |name| is an empty string. |
+ scoped_refptr<base::MessageLoopProxy> GetMessageLoopProxy( |
+ const std::string& name); |
- protected: |
+ private: |
// Only allow scoped_ptr<> to delete factory. |
friend class scoped_ptr<MessageLoopFactory>; |
- virtual ~MessageLoopFactory(); |
+ ~MessageLoopFactory(); |
+ |
+ // Returns the thread associated with |name| creating a new thread if needed. |
+ base::Thread* GetThread(const std::string& name); |
+ |
+ // Lock used to serialize access for the following data members. |
+ base::Lock lock_; |
+ |
+ typedef std::map<std::string, base::Thread*> ThreadMap; |
+ ThreadMap thread_map_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(MessageLoopFactory); |
}; |
} // namespace media |