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

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: nits 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
« no previous file with comments | « content/renderer/render_view_impl.cc ('k') | media/base/message_loop_factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
26 //
27 // TODO(scherkus): replace this with something simpler http://crbug.com/116873
20 class MEDIA_EXPORT MessageLoopFactory { 28 class MEDIA_EXPORT MessageLoopFactory {
21 public: 29 public:
30 MessageLoopFactory();
31
22 // Get the message loop associated with |name|. A new MessageLoop 32 // Get the message loop associated with |name|. A new MessageLoop
23 // 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|.
24 // NULL is returned if |name| is an empty string, or a new 34 //
25 // MessageLoop needs to be created and a failure occurs during the 35 // |name| must not be an empty string.
26 // creation process. 36 MessageLoop* GetMessageLoop(const std::string& name);
27 virtual MessageLoop* GetMessageLoop(const std::string& name) = 0;
28 37
29 // Get the message loop proxy associated with |name|. A new MessageLoopProxy 38 // Get the message loop proxy associated with |name|. A new MessageLoopProxy
30 // 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|.
31 // NULL is returned if |name| is an empty string, or a new 40 //
32 // MessageLoop needs to be created and a failure occurs during the 41 // |name| must not be an empty string.
33 // creation process. 42 scoped_refptr<base::MessageLoopProxy> GetMessageLoopProxy(
34 virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoopProxy( 43 const std::string& name);
35 const std::string& name) = 0;
36 44
37 protected: 45 private:
38 // Only allow scoped_ptr<> to delete factory. 46 // Only allow scoped_ptr<> to delete factory.
39 friend class scoped_ptr<MessageLoopFactory>; 47 friend class scoped_ptr<MessageLoopFactory>;
40 virtual ~MessageLoopFactory(); 48 ~MessageLoopFactory();
49
50 // Returns the thread associated with |name| creating a new thread if needed.
51 base::Thread* GetThread(const std::string& name);
52
53 // Lock used to serialize access for the following data members.
54 base::Lock lock_;
55
56 typedef std::map<std::string, base::Thread*> ThreadMap;
57 ThreadMap thread_map_;
58
59 DISALLOW_COPY_AND_ASSIGN(MessageLoopFactory);
41 }; 60 };
42 61
43 } // namespace media 62 } // namespace media
44 63
45 #endif // MEDIA_BASE_MESSAGE_LOOP_FACTORY_H_ 64 #endif // MEDIA_BASE_MESSAGE_LOOP_FACTORY_H_
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.cc ('k') | media/base/message_loop_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698