OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROME_RENDERER_PEPPER_PNACL_TRANSLATION_RESOURCE_HOST_H_ | 5 #ifndef CHROME_RENDERER_PEPPER_PNACL_TRANSLATION_RESOURCE_HOST_H_ |
6 #define CHROME_RENDERER_PEPPER_PNACL_TRANSLATION_RESOURCE_HOST_H_ | 6 #define CHROME_RENDERER_PEPPER_PNACL_TRANSLATION_RESOURCE_HOST_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "ipc/ipc_channel_proxy.h" | |
11 #include "ipc/ipc_platform_file.h" | 10 #include "ipc/ipc_platform_file.h" |
| 11 #include "ipc/message_filter.h" |
12 #include "ppapi/c/private/pp_file_handle.h" | 12 #include "ppapi/c/private/pp_file_handle.h" |
13 #include "ppapi/shared_impl/tracked_callback.h" | 13 #include "ppapi/shared_impl/tracked_callback.h" |
14 | 14 |
15 namespace nacl { | 15 namespace nacl { |
16 struct PnaclCacheInfo; | 16 struct PnaclCacheInfo; |
17 } | 17 } |
18 | 18 |
19 // A class to keep track of requests made to the browser for resources that the | 19 // A class to keep track of requests made to the browser for resources that the |
20 // PNaCl translator needs (e.g. descriptors for the translator nexes, temp | 20 // PNaCl translator needs (e.g. descriptors for the translator nexes, temp |
21 // files, and cached translations). | 21 // files, and cached translations). |
22 | 22 |
23 // "Resource" might not be the best name for the various things that pnacl | 23 // "Resource" might not be the best name for the various things that pnacl |
24 // needs from the browser since "Resource" is a Pepper thing... | 24 // needs from the browser since "Resource" is a Pepper thing... |
25 class PnaclTranslationResourceHost : public IPC::ChannelProxy::MessageFilter { | 25 class PnaclTranslationResourceHost : public IPC::MessageFilter { |
26 public: | 26 public: |
27 explicit PnaclTranslationResourceHost( | 27 explicit PnaclTranslationResourceHost( |
28 const scoped_refptr<base::MessageLoopProxy>& io_message_loop); | 28 const scoped_refptr<base::MessageLoopProxy>& io_message_loop); |
29 void RequestNexeFd(int render_view_id, | 29 void RequestNexeFd(int render_view_id, |
30 PP_Instance instance, | 30 PP_Instance instance, |
31 const nacl::PnaclCacheInfo& cache_info, | 31 const nacl::PnaclCacheInfo& cache_info, |
32 PP_Bool* is_hit, | 32 PP_Bool* is_hit, |
33 PP_FileHandle* file_handle, | 33 PP_FileHandle* file_handle, |
34 scoped_refptr<ppapi::TrackedCallback> callback); | 34 scoped_refptr<ppapi::TrackedCallback> callback); |
35 void ReportTranslationFinished(PP_Instance instance, PP_Bool success); | 35 void ReportTranslationFinished(PP_Instance instance, PP_Bool success); |
(...skipping 11 matching lines...) Expand all Loading... |
47 ~CacheRequestInfo(); | 47 ~CacheRequestInfo(); |
48 | 48 |
49 PP_Bool* is_hit; | 49 PP_Bool* is_hit; |
50 PP_FileHandle* file_handle; | 50 PP_FileHandle* file_handle; |
51 scoped_refptr<ppapi::TrackedCallback> callback; | 51 scoped_refptr<ppapi::TrackedCallback> callback; |
52 }; | 52 }; |
53 | 53 |
54 // Maps the instance with an outstanding cache request to the info | 54 // Maps the instance with an outstanding cache request to the info |
55 // about that request. | 55 // about that request. |
56 typedef std::map<PP_Instance, CacheRequestInfo> CacheRequestInfoMap; | 56 typedef std::map<PP_Instance, CacheRequestInfo> CacheRequestInfoMap; |
57 // IPC::ChannelProxy::MessageFilter implementation. | 57 // IPC::MessageFilter implementation. |
58 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 58 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
59 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE; | 59 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE; |
60 virtual void OnFilterRemoved() OVERRIDE; | 60 virtual void OnFilterRemoved() OVERRIDE; |
61 virtual void OnChannelClosing() OVERRIDE; | 61 virtual void OnChannelClosing() OVERRIDE; |
62 | 62 |
63 void SendRequestNexeFd(int render_view_id, | 63 void SendRequestNexeFd(int render_view_id, |
64 PP_Instance instance, | 64 PP_Instance instance, |
65 const nacl::PnaclCacheInfo& cache_info, | 65 const nacl::PnaclCacheInfo& cache_info, |
66 PP_Bool* is_hit, | 66 PP_Bool* is_hit, |
67 PP_FileHandle* file_handle, | 67 PP_FileHandle* file_handle, |
68 scoped_refptr<ppapi::TrackedCallback> callback); | 68 scoped_refptr<ppapi::TrackedCallback> callback); |
69 void SendReportTranslationFinished(PP_Instance instance, | 69 void SendReportTranslationFinished(PP_Instance instance, |
70 PP_Bool success); | 70 PP_Bool success); |
71 void OnNexeTempFileReply(PP_Instance instance, | 71 void OnNexeTempFileReply(PP_Instance instance, |
72 bool is_hit, | 72 bool is_hit, |
73 IPC::PlatformFileForTransit file); | 73 IPC::PlatformFileForTransit file); |
74 void CleanupCacheRequests(); | 74 void CleanupCacheRequests(); |
75 | 75 |
76 scoped_refptr<base::MessageLoopProxy> io_message_loop_; | 76 scoped_refptr<base::MessageLoopProxy> io_message_loop_; |
77 | 77 |
78 // Should be accessed on the io thread. | 78 // Should be accessed on the io thread. |
79 IPC::Channel* channel_; | 79 IPC::Channel* channel_; |
80 CacheRequestInfoMap pending_cache_requests_; | 80 CacheRequestInfoMap pending_cache_requests_; |
81 DISALLOW_COPY_AND_ASSIGN(PnaclTranslationResourceHost); | 81 DISALLOW_COPY_AND_ASSIGN(PnaclTranslationResourceHost); |
82 }; | 82 }; |
83 | 83 |
84 #endif // CHROME_RENDERER_PEPPER_PNACL_TRANSLATION_RESOURCE_HOST_H_ | 84 #endif // CHROME_RENDERER_PEPPER_PNACL_TRANSLATION_RESOURCE_HOST_H_ |
OLD | NEW |