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

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: int64_t to int64 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 9
10 #include "base/basictypes.h"
10 #include "components/nacl/common/pnacl_types.h" 11 #include "components/nacl/common/pnacl_types.h"
11 #include "ipc/ipc_channel_proxy.h" 12 #include "ipc/ipc_channel_proxy.h"
12 #include "ipc/ipc_platform_file.h" 13 #include "ipc/ipc_platform_file.h"
13 #include "ppapi/c/private/pp_file_handle.h" 14 #include "ppapi/c/private/pp_file_handle.h"
14 #include "ppapi/shared_impl/tracked_callback.h" 15 #include "ppapi/shared_impl/tracked_callback.h"
15 16
16 // A class to keep track of requests made to the browser for resources that the 17 // 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 18 // PNaCl translator needs (e.g. descriptors for the translator nexes, temp
18 // files, and cached translations). 19 // files, and cached translations).
19 20
20 // "Resource" might not be the best name for the various things that pnacl 21 // "Resource" might not be the best name for the various things that pnacl
21 // needs from the browser since "Resource" is a Pepper thing... 22 // needs from the browser since "Resource" is a Pepper thing...
22 class PnaclTranslationResourceHost : public IPC::ChannelProxy::MessageFilter { 23 class PnaclTranslationResourceHost : public IPC::ChannelProxy::MessageFilter {
23 public: 24 public:
24 explicit PnaclTranslationResourceHost( 25 explicit PnaclTranslationResourceHost(
25 const scoped_refptr<base::MessageLoopProxy>& io_message_loop); 26 const scoped_refptr<base::MessageLoopProxy>& io_message_loop);
26 void RequestNexeFd(int render_view_id, 27 void RequestNexeFd(int render_view_id,
27 PP_Instance instance, 28 PP_Instance instance,
28 const nacl::PnaclCacheInfo& cache_info, 29 const nacl::PnaclCacheInfo& cache_info,
29 PP_Bool* is_hit, 30 PP_Bool* is_hit,
30 PP_FileHandle* file_handle, 31 PP_FileHandle* file_handle,
31 scoped_refptr<ppapi::TrackedCallback> callback); 32 scoped_refptr<ppapi::TrackedCallback> callback);
32 void ReportTranslationFinished(PP_Instance instance); 33 void ReportTranslationFinished(PP_Instance instance);
33 34
35 // Ensure that PNaCl resources (pnacl-llc.nexe, linker, libs) are installed.
36 void EnsurePnaclInstalled(PP_Instance instance,
37 scoped_refptr<ppapi::TrackedCallback> callback);
38
34 protected: 39 protected:
35 virtual ~PnaclTranslationResourceHost(); 40 virtual ~PnaclTranslationResourceHost();
36 41
37 private: 42 private:
38 class CacheRequestInfo { 43 class CacheRequestInfo {
39 public: 44 public:
40 CacheRequestInfo(PP_Bool* hit, 45 CacheRequestInfo(PP_Bool* hit,
41 PP_FileHandle* handle, 46 PP_FileHandle* handle,
42 scoped_refptr<ppapi::TrackedCallback> cb); 47 scoped_refptr<ppapi::TrackedCallback> cb);
43 48
44 ~CacheRequestInfo(); 49 ~CacheRequestInfo();
45 50
46 PP_Bool* is_hit; 51 PP_Bool* is_hit;
47 PP_FileHandle* file_handle; 52 PP_FileHandle* file_handle;
48 scoped_refptr<ppapi::TrackedCallback> callback; 53 scoped_refptr<ppapi::TrackedCallback> callback;
49 }; 54 };
50 55
51 // Maps the instance with an outstanding cache request to the info 56 // Maps the instance with an outstanding cache request to the info
52 // about that request. 57 // about that request.
53 typedef std::map<PP_Instance, CacheRequestInfo> CacheRequestInfoMap; 58 typedef std::map<PP_Instance, CacheRequestInfo> CacheRequestInfoMap;
59 // Maps the instance to an outstanding ensure pnacl installed request.
dmichael (off chromium) 2013/08/01 17:33:49 s/ensure pnacl installed/EnsurePnaclInstalled migh
jvoung (off chromium) 2013/08/01 23:14:07 Done.
60 typedef std::map<PP_Instance, scoped_refptr<ppapi::TrackedCallback> >
61 EnsurePnaclInstalledMap;
dmichael (off chromium) 2013/08/01 17:37:00 By the way... what happens if a particular plugin
jvoung (off chromium) 2013/08/01 23:14:07 It could actually happen, if you load multiple PNa
54 // IPC::ChannelProxy::MessageFilter implementation. 62 // IPC::ChannelProxy::MessageFilter implementation.
55 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 63 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
56 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE; 64 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE;
57 virtual void OnFilterRemoved() OVERRIDE; 65 virtual void OnFilterRemoved() OVERRIDE;
58 virtual void OnChannelClosing() OVERRIDE; 66 virtual void OnChannelClosing() OVERRIDE;
59 67
60 void OnNexeTempFileReply(PP_Instance instance, 68 void OnNexeTempFileReply(PP_Instance instance,
61 bool is_hit, 69 bool is_hit,
62 IPC::PlatformFileForTransit file); 70 IPC::PlatformFileForTransit file);
63 void CleanupCacheRequests(); 71 void CleanupCacheRequests();
72 void OnEnsurePnaclInstalledReply(PP_Instance instance,
73 bool success);
74 void OnEnsurePnaclInstalledProgress(PP_Instance instance,
75 int64 current_progress,
76 int64 total);
77 void CleanupEnsurePnaclRequests();
64 78
65 scoped_refptr<base::MessageLoopProxy> io_message_loop_; 79 scoped_refptr<base::MessageLoopProxy> io_message_loop_;
66 IPC::Channel* channel_; 80 IPC::Channel* channel_;
dmichael (off chromium) 2013/08/01 17:33:49 ^^^ it looks like channel_ should also only be acc
jvoung (off chromium) 2013/08/01 23:14:07 Yes, I'll put it under the comment as well.
67 81
68 // Should be accessed on the io thread. 82 // Should be accessed on the io thread.
69 CacheRequestInfoMap pending_cache_requests_; 83 CacheRequestInfoMap pending_cache_requests_;
84 EnsurePnaclInstalledMap pending_ensure_pnacl_requests_;
70 85
71 DISALLOW_COPY_AND_ASSIGN(PnaclTranslationResourceHost); 86 DISALLOW_COPY_AND_ASSIGN(PnaclTranslationResourceHost);
72 }; 87 };
73 88
74 #endif // CHROME_RENDERER_PEPPER_PNACL_TRANSLATION_RESOURCE_HOST_H_ 89 #endif // CHROME_RENDERER_PEPPER_PNACL_TRANSLATION_RESOURCE_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698