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

Side by Side 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, 9 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) 2011 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 <string> 9 #include <string>
9 10
10 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
12 #include "base/message_loop_proxy.h" 13 #include "base/message_loop_proxy.h"
14 #include "base/synchronization/lock.h"
13 #include "media/base/media_export.h" 15 #include "media/base/media_export.h"
14 16
15 class MessageLoop; 17 class MessageLoop;
16 18
19 namespace base {
20 class Thread;
21 }
22
17 namespace media { 23 namespace media {
18 24
19 // Factory object that manages named MessageLoops. 25 // Factory object that manages named MessageLoops.
20 class MEDIA_EXPORT MessageLoopFactory { 26 class MEDIA_EXPORT MessageLoopFactory {
21 public: 27 public:
28 MessageLoopFactory();
29
22 // Get the message loop associated with |name|. A new MessageLoop 30 // Get the message loop associated with |name|. A new MessageLoop
23 // is created if the factory doesn't have one associated with |name|. 31 // is created if the factory doesn't have one associated with |name|.
24 // NULL is returned if |name| is an empty string, or a new 32 // NULL is returned if |name| is an empty string.
25 // MessageLoop needs to be created and a failure occurs during the 33 MessageLoop* GetMessageLoop(const std::string& name);
26 // creation process.
27 virtual MessageLoop* GetMessageLoop(const std::string& name) = 0;
28 34
29 // Get the message loop proxy associated with |name|. A new MessageLoopProxy 35 // Get the message loop proxy associated with |name|. A new MessageLoopProxy
30 // is created if the factory doesn't have one associated with |name|. 36 // is created if the factory doesn't have one associated with |name|.
31 // NULL is returned if |name| is an empty string, or a new 37 // NULL is returned if |name| is an empty string.
32 // MessageLoop needs to be created and a failure occurs during the 38 scoped_refptr<base::MessageLoopProxy> GetMessageLoopProxy(
33 // creation process. 39 const std::string& name);
34 virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoopProxy(
35 const std::string& name) = 0;
36 40
37 protected: 41 private:
38 // Only allow scoped_ptr<> to delete factory. 42 // Only allow scoped_ptr<> to delete factory.
39 friend class scoped_ptr<MessageLoopFactory>; 43 friend class scoped_ptr<MessageLoopFactory>;
40 virtual ~MessageLoopFactory(); 44 ~MessageLoopFactory();
45
46 // Returns the thread associated with |name| creating a new thread if needed.
47 base::Thread* GetThread(const std::string& name);
48
49 // Lock used to serialize access for the following data members.
50 base::Lock lock_;
51
52 typedef std::map<std::string, base::Thread*> ThreadMap;
53 ThreadMap thread_map_;
54
55 DISALLOW_COPY_AND_ASSIGN(MessageLoopFactory);
41 }; 56 };
42 57
43 } // namespace media 58 } // namespace media
44 59
45 #endif // MEDIA_BASE_MESSAGE_LOOP_FACTORY_H_ 60 #endif // MEDIA_BASE_MESSAGE_LOOP_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698