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

Side by Side Diff: chrome/renderer/pepper/pnacl_translation_resource_host.h

Issue 19863003: PNaCl on-demand installs: Make a separate async IPC to check if PNaCl is installed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: take out progress IPC for now Created 7 years, 4 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
OLDNEW
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 #include <vector>
9 10
10 #include "components/nacl/common/pnacl_types.h"
11 #include "ipc/ipc_channel_proxy.h" 11 #include "ipc/ipc_channel_proxy.h"
12 #include "ipc/ipc_platform_file.h" 12 #include "ipc/ipc_platform_file.h"
13 #include "ppapi/c/private/pp_file_handle.h" 13 #include "ppapi/c/private/pp_file_handle.h"
14 #include "ppapi/shared_impl/tracked_callback.h" 14 #include "ppapi/shared_impl/tracked_callback.h"
15 15
16 namespace nacl {
17 struct PnaclCacheInfo;
18 }
19
16 // A class to keep track of requests made to the browser for resources that the 20 // A class to keep track of requests made to the browser for resources that the
17 // PNaCl translator needs (e.g. descriptors for the translator nexes, temp 21 // PNaCl translator needs (e.g. descriptors for the translator nexes, temp
18 // files, and cached translations). 22 // files, and cached translations).
19 23
20 // "Resource" might not be the best name for the various things that pnacl 24 // "Resource" might not be the best name for the various things that pnacl
21 // needs from the browser since "Resource" is a Pepper thing... 25 // needs from the browser since "Resource" is a Pepper thing...
22 class PnaclTranslationResourceHost : public IPC::ChannelProxy::MessageFilter { 26 class PnaclTranslationResourceHost : public IPC::ChannelProxy::MessageFilter {
23 public: 27 public:
24 explicit PnaclTranslationResourceHost( 28 explicit PnaclTranslationResourceHost(
25 const scoped_refptr<base::MessageLoopProxy>& io_message_loop); 29 const scoped_refptr<base::MessageLoopProxy>& io_message_loop);
26 void RequestNexeFd(int render_view_id, 30 void RequestNexeFd(int render_view_id,
27 PP_Instance instance, 31 PP_Instance instance,
28 const nacl::PnaclCacheInfo& cache_info, 32 const nacl::PnaclCacheInfo& cache_info,
29 PP_Bool* is_hit, 33 PP_Bool* is_hit,
30 PP_FileHandle* file_handle, 34 PP_FileHandle* file_handle,
31 scoped_refptr<ppapi::TrackedCallback> callback); 35 scoped_refptr<ppapi::TrackedCallback> callback);
32 void ReportTranslationFinished(PP_Instance instance); 36 void ReportTranslationFinished(PP_Instance instance);
33 37
38 // Ensure that PNaCl resources (pnacl-llc.nexe, linker, libs) are installed.
39 void EnsurePnaclInstalled(PP_Instance instance,
40 scoped_refptr<ppapi::TrackedCallback> callback);
41
34 protected: 42 protected:
35 virtual ~PnaclTranslationResourceHost(); 43 virtual ~PnaclTranslationResourceHost();
36 44
37 private: 45 private:
38 class CacheRequestInfo { 46 class CacheRequestInfo {
39 public: 47 public:
40 CacheRequestInfo(PP_Bool* hit, 48 CacheRequestInfo(PP_Bool* hit,
41 PP_FileHandle* handle, 49 PP_FileHandle* handle,
42 scoped_refptr<ppapi::TrackedCallback> cb); 50 scoped_refptr<ppapi::TrackedCallback> cb);
43 51
44 ~CacheRequestInfo(); 52 ~CacheRequestInfo();
45 53
46 PP_Bool* is_hit; 54 PP_Bool* is_hit;
47 PP_FileHandle* file_handle; 55 PP_FileHandle* file_handle;
48 scoped_refptr<ppapi::TrackedCallback> callback; 56 scoped_refptr<ppapi::TrackedCallback> callback;
49 }; 57 };
50 58
51 // Maps the instance with an outstanding cache request to the info 59 // Maps the instance with an outstanding cache request to the info
52 // about that request. 60 // about that request.
53 typedef std::map<PP_Instance, CacheRequestInfo> CacheRequestInfoMap; 61 typedef std::map<PP_Instance, CacheRequestInfo> CacheRequestInfoMap;
62 // A list of outstanding EnsurePnaclInstalled requests.
63 typedef std::vector<scoped_refptr<ppapi::TrackedCallback> >
64 EnsurePnaclInstalledList;
54 // IPC::ChannelProxy::MessageFilter implementation. 65 // IPC::ChannelProxy::MessageFilter implementation.
55 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 66 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
56 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE; 67 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE;
57 virtual void OnFilterRemoved() OVERRIDE; 68 virtual void OnFilterRemoved() OVERRIDE;
58 virtual void OnChannelClosing() OVERRIDE; 69 virtual void OnChannelClosing() OVERRIDE;
59 70
71 void SendRequestNexeFd(int render_view_id,
72 PP_Instance instance,
73 const nacl::PnaclCacheInfo& cache_info,
74 PP_Bool* is_hit,
75 PP_FileHandle* file_handle,
76 scoped_refptr<ppapi::TrackedCallback> callback);
77 void SendReportTranslationFinished(PP_Instance instance);
78 void SendEnsurePnaclInstalled(PP_Instance instance,
79 scoped_refptr<ppapi::TrackedCallback> callback);
80
60 void OnNexeTempFileReply(PP_Instance instance, 81 void OnNexeTempFileReply(PP_Instance instance,
61 bool is_hit, 82 bool is_hit,
62 IPC::PlatformFileForTransit file); 83 IPC::PlatformFileForTransit file);
63 void CleanupCacheRequests(); 84 void CleanupCacheRequests();
85 void OnEnsurePnaclInstalledReply(PP_Instance instance, bool success);
86 void CleanupEnsurePnaclRequests();
64 87
65 scoped_refptr<base::MessageLoopProxy> io_message_loop_; 88 scoped_refptr<base::MessageLoopProxy> io_message_loop_;
66 IPC::Channel* channel_;
67 89
68 // Should be accessed on the io thread. 90 // Should be accessed on the io thread.
91 IPC::Channel* channel_;
69 CacheRequestInfoMap pending_cache_requests_; 92 CacheRequestInfoMap pending_cache_requests_;
70 93 EnsurePnaclInstalledList pending_ensure_pnacl_requests_;
71 DISALLOW_COPY_AND_ASSIGN(PnaclTranslationResourceHost); 94 DISALLOW_COPY_AND_ASSIGN(PnaclTranslationResourceHost);
72 }; 95 };
73 96
74 #endif // CHROME_RENDERER_PEPPER_PNACL_TRANSLATION_RESOURCE_HOST_H_ 97 #endif // CHROME_RENDERER_PEPPER_PNACL_TRANSLATION_RESOURCE_HOST_H_
OLDNEW
« no previous file with comments | « chrome/browser/nacl_host/nacl_host_message_filter.cc ('k') | chrome/renderer/pepper/pnacl_translation_resource_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698