OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 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 PPAPI_PROXY_RESOURCE_REPLY_THREAD_REGISTRAR_H_ |
| 6 #define PPAPI_PROXY_RESOURCE_REPLY_THREAD_REGISTRAR_H_ |
| 7 |
| 8 #include <map> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/synchronization/lock.h" |
| 13 #include "ppapi/c/pp_resource.h" |
| 14 #include "ppapi/proxy/ppapi_proxy_export.h" |
| 15 #include "ppapi/shared_impl/tracked_callback.h" |
| 16 |
| 17 namespace base { |
| 18 class MessageLoopProxy; |
| 19 } |
| 20 |
| 21 namespace ppapi { |
| 22 namespace proxy { |
| 23 |
| 24 class PPAPI_PROXY_EXPORT ResourceReplyThreadRegistrar |
| 25 : public base::RefCountedThreadSafe<ResourceReplyThreadRegistrar> { |
| 26 public: |
| 27 explicit ResourceReplyThreadRegistrar( |
| 28 scoped_refptr<base::MessageLoopProxy> default_thread); |
| 29 |
| 30 void Register(PP_Resource resource, |
| 31 int32_t sequence_number, |
| 32 scoped_refptr<TrackedCallback> reply_thread_hint); |
| 33 void Unregister(PP_Resource resource); |
| 34 |
| 35 scoped_refptr<base::MessageLoopProxy> GetTargetThread( |
| 36 PP_Resource resource, |
| 37 int32_t sequence_number); |
| 38 |
| 39 private: |
| 40 friend class base::RefCountedThreadSafe<ResourceReplyThreadRegistrar>; |
| 41 |
| 42 typedef std::map<int32_t, scoped_refptr<base::MessageLoopProxy> > |
| 43 SequenceNumberMap; |
| 44 typedef std::map<PP_Resource, SequenceNumberMap> ResourceMap; |
| 45 |
| 46 ~ResourceReplyThreadRegistrar(); |
| 47 |
| 48 base::Lock lock_; |
| 49 ResourceMap map_; |
| 50 scoped_refptr<base::MessageLoopProxy> default_thread_; |
| 51 |
| 52 DISALLOW_COPY_AND_ASSIGN(ResourceReplyThreadRegistrar); |
| 53 }; |
| 54 |
| 55 } // namespace proxy |
| 56 } // namespace ppapi |
| 57 |
| 58 #endif // PPAPI_PROXY_RESOURCE_REPLY_THREAD_REGISTRAR_H_ |
OLD | NEW |