| 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 "chrome/common/pnacl_types.h" | 10 #include "chrome/common/pnacl_types.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 explicit PnaclTranslationResourceHost( | 24 explicit PnaclTranslationResourceHost( |
| 25 const scoped_refptr<base::MessageLoopProxy>& io_message_loop); | 25 const scoped_refptr<base::MessageLoopProxy>& io_message_loop); |
| 26 void RequestNexeFd(int render_view_id, | 26 void RequestNexeFd(int render_view_id, |
| 27 PP_Instance instance, | 27 PP_Instance instance, |
| 28 const nacl::PnaclCacheInfo& cache_info, | 28 const nacl::PnaclCacheInfo& cache_info, |
| 29 PP_Bool* is_hit, | 29 PP_Bool* is_hit, |
| 30 PP_FileHandle* file_handle, | 30 PP_FileHandle* file_handle, |
| 31 scoped_refptr<ppapi::TrackedCallback> callback); | 31 scoped_refptr<ppapi::TrackedCallback> callback); |
| 32 void ReportTranslationFinished(PP_Instance instance); | 32 void ReportTranslationFinished(PP_Instance instance); |
| 33 | 33 |
| 34 // Ensure that PNaCl resources (pnacl-llc.nexe, linker, libs) are installed. |
| 35 void EnsurePnaclInstalled(PP_Instance instance, |
| 36 scoped_refptr<ppapi::TrackedCallback> callback); |
| 37 |
| 34 protected: | 38 protected: |
| 35 virtual ~PnaclTranslationResourceHost(); | 39 virtual ~PnaclTranslationResourceHost(); |
| 36 | 40 |
| 37 private: | 41 private: |
| 38 class CacheRequestInfo { | 42 class CacheRequestInfo { |
| 39 public: | 43 public: |
| 40 CacheRequestInfo(PP_Bool* hit, | 44 CacheRequestInfo(PP_Bool* hit, |
| 41 PP_FileHandle* handle, | 45 PP_FileHandle* handle, |
| 42 scoped_refptr<ppapi::TrackedCallback> cb); | 46 scoped_refptr<ppapi::TrackedCallback> cb); |
| 43 | 47 |
| 44 ~CacheRequestInfo(); | 48 ~CacheRequestInfo(); |
| 45 | 49 |
| 46 PP_Bool* is_hit; | 50 PP_Bool* is_hit; |
| 47 PP_FileHandle* file_handle; | 51 PP_FileHandle* file_handle; |
| 48 scoped_refptr<ppapi::TrackedCallback> callback; | 52 scoped_refptr<ppapi::TrackedCallback> callback; |
| 49 }; | 53 }; |
| 50 | 54 |
| 51 // Maps the instance with an outstanding cache request to the info | 55 // Maps the instance with an outstanding cache request to the info |
| 52 // about that request. | 56 // about that request. |
| 53 typedef std::map<PP_Instance, CacheRequestInfo> CacheRequestInfoMap; | 57 typedef std::map<PP_Instance, CacheRequestInfo> CacheRequestInfoMap; |
| 58 // Maps the instance to an outstanding ensure pnacl installed request. |
| 59 typedef std::map<PP_Instance, scoped_refptr<ppapi::TrackedCallback> > |
| 60 EnsurePnaclInstalledMap; |
| 54 // IPC::ChannelProxy::MessageFilter implementation. | 61 // IPC::ChannelProxy::MessageFilter implementation. |
| 55 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 62 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 56 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE; | 63 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE; |
| 57 virtual void OnFilterRemoved() OVERRIDE; | 64 virtual void OnFilterRemoved() OVERRIDE; |
| 58 virtual void OnChannelClosing() OVERRIDE; | 65 virtual void OnChannelClosing() OVERRIDE; |
| 59 | 66 |
| 60 void OnNexeTempFileReply(PP_Instance instance, | 67 void OnNexeTempFileReply(PP_Instance instance, |
| 61 bool is_hit, | 68 bool is_hit, |
| 62 IPC::PlatformFileForTransit file); | 69 IPC::PlatformFileForTransit file); |
| 63 void CleanupCacheRequests(); | 70 void CleanupCacheRequests(); |
| 71 void OnEnsurePnaclInstalledReply(PP_Instance instance, |
| 72 bool success); |
| 73 void OnEnsurePnaclInstalledProgress(PP_Instance instance, |
| 74 int64_t current_progress, |
| 75 int64_t total); |
| 76 void CleanupEnsurePnaclRequests(); |
| 64 | 77 |
| 65 scoped_refptr<base::MessageLoopProxy> io_message_loop_; | 78 scoped_refptr<base::MessageLoopProxy> io_message_loop_; |
| 66 IPC::Channel* channel_; | 79 IPC::Channel* channel_; |
| 67 | 80 |
| 68 // Should be accessed on the io thread. | 81 // Should be accessed on the io thread. |
| 69 CacheRequestInfoMap pending_cache_requests_; | 82 CacheRequestInfoMap pending_cache_requests_; |
| 83 EnsurePnaclInstalledMap pending_ensure_pnacl_requests_; |
| 70 | 84 |
| 71 DISALLOW_COPY_AND_ASSIGN(PnaclTranslationResourceHost); | 85 DISALLOW_COPY_AND_ASSIGN(PnaclTranslationResourceHost); |
| 72 }; | 86 }; |
| 73 | 87 |
| 74 #endif // CHROME_RENDERER_PEPPER_PNACL_TRANSLATION_RESOURCE_HOST_H_ | 88 #endif // CHROME_RENDERER_PEPPER_PNACL_TRANSLATION_RESOURCE_HOST_H_ |
| OLD | NEW |