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

Side by Side Diff: components/nacl/browser/nacl_host_impl.h

Issue 2514323004: Convert NaCl renderer-browser messages to mojo. (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « components/nacl/browser/nacl_file_host.cc ('k') | components/nacl/browser/nacl_host_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 COMPONENTS_NACL_BROWSER_NACL_HOST_MESSAGE_FILTER_H_ 5 #ifndef COMPONENTS_NACL_BROWSER_NACL_HOST_IMPL_H_
6 #define COMPONENTS_NACL_BROWSER_NACL_HOST_MESSAGE_FILTER_H_ 6 #define COMPONENTS_NACL_BROWSER_NACL_HOST_IMPL_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/files/file.h" 10 #include "base/files/file.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "components/nacl/common/nacl.mojom.h"
14 #include "content/public/browser/browser_message_filter.h" 15 #include "content/public/browser/browser_message_filter.h"
16 #include "mojo/public/cpp/bindings/binding.h"
15 #include "ppapi/shared_impl/ppapi_permissions.h" 17 #include "ppapi/shared_impl/ppapi_permissions.h"
16 18
17 class GURL; 19 class GURL;
18 20
19 namespace nacl { 21 namespace nacl {
20 struct NaClLaunchParams;
21 struct NaClResourcePrefetchResult; 22 struct NaClResourcePrefetchResult;
22 struct PnaclCacheInfo; 23 struct PnaclCacheInfo;
23 }
24 24
25 namespace net { 25 // This class implements the NaClHost mojo interface on the IO thread.
26 class HostResolver; 26 class NaClHostImpl : public mojom::NaClHost,
27 class URLRequestContextGetter; 27 public base::RefCountedThreadSafe<NaClHostImpl> {
28 } 28 public:
29 NaClHostImpl(int render_process_id,
30 bool is_off_the_record,
31 const base::FilePath& profile_directory,
32 mojom::NaClHostRequest request);
29 33
30 namespace nacl { 34 static void Create(int render_process_id,
31 35 bool is_off_the_record,
32 // This class filters out incoming Chrome-specific IPC messages for the renderer 36 const base::FilePath& profile_directory,
33 // process on the IPC thread. 37 mojom::NaClHostRequest request);
34 class NaClHostMessageFilter : public content::BrowserMessageFilter {
35 public:
36 NaClHostMessageFilter(int render_process_id,
37 bool is_off_the_record,
38 const base::FilePath& profile_directory,
39 net::URLRequestContextGetter* request_context);
40
41 // content::BrowserMessageFilter methods:
42 bool OnMessageReceived(const IPC::Message& message) override;
43 void OnChannelClosing() override;
44
45 int render_process_id() { return render_process_id_; }
46 bool off_the_record() { return off_the_record_; }
47 const base::FilePath& profile_directory() const { return profile_directory_; }
48 net::HostResolver* GetHostResolver();
49 38
50 private: 39 private:
51 friend class content::BrowserThread; 40 friend class base::RefCountedThreadSafe<NaClHostImpl>;
52 friend class base::DeleteHelper<NaClHostMessageFilter>;
53 41
54 ~NaClHostMessageFilter() override; 42 ~NaClHostImpl() override;
55 43
56 void OnLaunchNaCl(const NaClLaunchParams& launch_params, 44 void OnConnectionError();
57 IPC::Message* reply_msg); 45
58 void BatchOpenResourceFiles(const nacl::NaClLaunchParams& launch_params, 46 void LaunchNaCl(mojom::NaClLaunchParamsPtr launch_params,
59 IPC::Message* reply_msg, 47 const LaunchNaClCallback& callback) override;
48 void BatchOpenResourceFiles(mojom::NaClLaunchParamsPtr launch_params,
49 const LaunchNaClCallback& callback,
60 ppapi::PpapiPermissions permissions); 50 ppapi::PpapiPermissions permissions);
61 void LaunchNaClContinuation( 51 void LaunchNaClContinuation(mojom::NaClLaunchParamsPtr launch_params,
62 const nacl::NaClLaunchParams& launch_params, 52 const LaunchNaClCallback& callback);
63 IPC::Message* reply_msg);
64 void LaunchNaClContinuationOnIOThread( 53 void LaunchNaClContinuationOnIOThread(
65 const nacl::NaClLaunchParams& launch_params, 54 mojom::NaClLaunchParamsPtr launch_params,
66 IPC::Message* reply_msg, 55 const LaunchNaClCallback& callback,
67 const std::vector<NaClResourcePrefetchResult>& prefetched_resource_files, 56 const std::vector<NaClResourcePrefetchResult>& prefetched_resource_files,
68 ppapi::PpapiPermissions permissions); 57 ppapi::PpapiPermissions permissions);
69 void OnGetReadonlyPnaclFd(const std::string& filename, 58 void GetReadonlyPnaclFd(const std::string& filename,
70 bool is_executable, 59 bool is_executable,
71 IPC::Message* reply_msg); 60 const GetReadonlyPnaclFdCallback& callback) override;
72 void OnNaClCreateTemporaryFile(IPC::Message* reply_msg); 61 void NaClCreateTemporaryFile(
73 void OnNaClGetNumProcessors(int* num_processors); 62 const NaClCreateTemporaryFileCallback& callback) override;
74 void OnGetNexeFd(int render_view_id, 63 void NaClGetNumProcessors(
75 int pp_instance, 64 const NaClGetNumProcessorsCallback& callback) override;
76 const PnaclCacheInfo& cache_info); 65 void NexeTempFileRequest(
77 void OnTranslationFinished(int instance, bool success); 66 int render_view_id,
78 void OnMissingArchError(int render_view_id); 67 int pp_instance,
79 void OnOpenNaClExecutable(int render_view_id, 68 const PnaclCacheInfo& cache_info,
80 const GURL& file_url, 69 const NexeTempFileRequestCallback& callback) override;
81 bool enable_validation_caching, 70 void ReportTranslationFinished(int instance, bool success) override;
82 IPC::Message* reply_msg); 71 void MissingArchError(int render_view_id) override;
83 void SyncReturnTemporaryFile(IPC::Message* reply_msg, 72 void OpenNaClExecutable(int render_view_id,
84 base::File file); 73 const GURL& file_url,
85 void AsyncReturnTemporaryFile(int pp_instance, 74 bool enable_validation_caching,
86 const base::File& file, 75 const OpenNaClExecutableCallback& callback) override;
87 bool is_hit); 76 void NaClDebugEnabledForURL(
88 void OnNaClDebugEnabledForURL(const GURL& nmf_url, bool* should_debug); 77 const GURL& nmf_url,
78 const NaClDebugEnabledForURLCallback& callback) override;
89 79
90 int render_process_id_; 80 const int render_process_id_;
91 81
92 // off_the_record_ is copied from the profile partly so that it can be 82 // off_the_record_ is copied from the profile partly so that it can be
93 // read on the IO thread. 83 // read on the IO thread.
94 bool off_the_record_; 84 const bool off_the_record_;
95 base::FilePath profile_directory_; 85 base::FilePath profile_directory_;
96 scoped_refptr<net::URLRequestContextGetter> request_context_; 86 scoped_refptr<NaClHostImpl> self_;
87 mojo::Binding<mojom::NaClHost> binding_;
97 88
98 base::WeakPtrFactory<NaClHostMessageFilter> weak_ptr_factory_; 89 base::WeakPtrFactory<NaClHostImpl> weak_ptr_factory_;
99 90
100 DISALLOW_COPY_AND_ASSIGN(NaClHostMessageFilter); 91 DISALLOW_COPY_AND_ASSIGN(NaClHostImpl);
101 }; 92 };
102 93
103 } // namespace nacl 94 } // namespace nacl
104 95
105 #endif // COMPONENTS_NACL_BROWSER_NACL_HOST_MESSAGE_FILTER_H_ 96 #endif // COMPONENTS_NACL_BROWSER_NACL_HOST_IMPL_H_
OLDNEW
« no previous file with comments | « components/nacl/browser/nacl_file_host.cc ('k') | components/nacl/browser/nacl_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698