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

Side by Side Diff: media/base/message_loop_factory.h

Issue 11468033: Vanquish the remnants of media::MessageLoopFactory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_BASE_MESSAGE_LOOP_FACTORY_H_
6 #define MEDIA_BASE_MESSAGE_LOOP_FACTORY_H_
7
8 #include <list>
9 #include <string>
10
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/message_loop_proxy.h"
14 #include "base/synchronization/lock.h"
15 #include "media/base/media_export.h"
16
17 class MessageLoop;
18
19 namespace base {
20 class Thread;
21 }
22
23 namespace media {
24
25 // Factory object that manages named MessageLoops.
26 //
27 // TODO(scherkus): replace this with something simpler http://crbug.com/116873
28 class MEDIA_EXPORT MessageLoopFactory {
29 public:
30 enum Type {
31 kPipeline
32 };
33
34 MessageLoopFactory();
35
36 // Get the message loop proxy associated with |type|. A new MessageLoopProxy
37 // is created if the factory doesn't have one associated with |type|.
38 scoped_refptr<base::MessageLoopProxy> GetMessageLoop(Type type);
39
40 private:
41 // Only allow scoped_ptr<> to delete factory.
42 friend class scoped_ptr<MessageLoopFactory>;
43 ~MessageLoopFactory();
44
45 // Returns the thread associated with |type| creating a new thread if needed.
46 base::Thread* GetThread(Type type);
47
48 // Lock used to serialize access for the following data members.
49 base::Lock lock_;
50
51 // List of pairs of created threads and their types. We use a list to ensure
52 // threads are stopped & deleted in reverse order of creation.
53 typedef std::list<std::pair<Type, base::Thread*> > ThreadList;
54 ThreadList threads_;
55
56 DISALLOW_COPY_AND_ASSIGN(MessageLoopFactory);
57 };
58
59 } // namespace media
60
61 #endif // MEDIA_BASE_MESSAGE_LOOP_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698