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

Unified Diff: media/base/message_loop_factory.h

Issue 9597016: Fold media::MessageLoopFactoryImpl into media::MessageLoopFactory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698