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

Unified Diff: components/nacl/browser/nacl_host_impl.h

Issue 2514323004: Convert NaCl renderer-browser messages to mojo. (Closed)
Patch Set: rebase Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: components/nacl/browser/nacl_host_impl.h
diff --git a/components/nacl/browser/nacl_host_message_filter.h b/components/nacl/browser/nacl_host_impl.h
similarity index 24%
rename from components/nacl/browser/nacl_host_message_filter.h
rename to components/nacl/browser/nacl_host_impl.h
index 561922934b62106c4c1fc6325fa0d56fd1162054..53830ef8336b16c258ce8e04671be00e5e446fc5 100644
--- a/components/nacl/browser/nacl_host_message_filter.h
+++ b/components/nacl/browser/nacl_host_impl.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef COMPONENTS_NACL_BROWSER_NACL_HOST_MESSAGE_FILTER_H_
-#define COMPONENTS_NACL_BROWSER_NACL_HOST_MESSAGE_FILTER_H_
+#ifndef COMPONENTS_NACL_BROWSER_NACL_HOST_IMPL_H_
+#define COMPONENTS_NACL_BROWSER_NACL_HOST_IMPL_H_
#include <vector>
@@ -11,95 +11,89 @@
#include "base/files/file_path.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
+#include "components/nacl/common/nacl.mojom.h"
#include "content/public/browser/browser_message_filter.h"
+#include "mojo/public/cpp/bindings/binding.h"
#include "ppapi/shared_impl/ppapi_permissions.h"
class GURL;
namespace nacl {
-struct NaClLaunchParams;
struct NaClResourcePrefetchResult;
struct PnaclCacheInfo;
}
-namespace net {
-class HostResolver;
-class URLRequestContextGetter;
-}
-
namespace nacl {
-// This class filters out incoming Chrome-specific IPC messages for the renderer
-// process on the IPC thread.
-class NaClHostMessageFilter : public content::BrowserMessageFilter {
+// This class implements the NaClHost mojo interface on the IO thread.
+class NaClHostImpl : public mojom::NaClHost,
+ public base::RefCountedThreadSafe<NaClHostImpl> {
public:
- NaClHostMessageFilter(int render_process_id,
- bool is_off_the_record,
- const base::FilePath& profile_directory,
- net::URLRequestContextGetter* request_context);
+ NaClHostImpl(int render_process_id,
+ bool is_off_the_record,
+ const base::FilePath& profile_directory,
+ mojom::NaClHostRequest request);
- // content::BrowserMessageFilter methods:
- bool OnMessageReceived(const IPC::Message& message) override;
- void OnChannelClosing() override;
-
- int render_process_id() { return render_process_id_; }
- bool off_the_record() { return off_the_record_; }
- const base::FilePath& profile_directory() const { return profile_directory_; }
- net::HostResolver* GetHostResolver();
+ static void Create(int render_process_id,
+ bool is_off_the_record,
+ const base::FilePath& profile_directory,
+ mojom::NaClHostRequest request);
private:
- friend class content::BrowserThread;
- friend class base::DeleteHelper<NaClHostMessageFilter>;
+ friend class base::RefCountedThreadSafe<NaClHostImpl>;
+
+ ~NaClHostImpl() override;
- ~NaClHostMessageFilter() override;
+ void OnConnectionError();
- void OnLaunchNaCl(const NaClLaunchParams& launch_params,
- IPC::Message* reply_msg);
- void BatchOpenResourceFiles(const nacl::NaClLaunchParams& launch_params,
- IPC::Message* reply_msg,
+ void LaunchNaCl(mojom::NaClLaunchParamsPtr launch_params,
+ const LaunchNaClCallback& callback) override;
+ void BatchOpenResourceFiles(mojom::NaClLaunchParamsPtr launch_params,
+ const LaunchNaClCallback& callback,
ppapi::PpapiPermissions permissions);
- void LaunchNaClContinuation(
- const nacl::NaClLaunchParams& launch_params,
- IPC::Message* reply_msg);
+ void LaunchNaClContinuation(mojom::NaClLaunchParamsPtr launch_params,
+ const LaunchNaClCallback& callback);
void LaunchNaClContinuationOnIOThread(
- const nacl::NaClLaunchParams& launch_params,
- IPC::Message* reply_msg,
+ mojom::NaClLaunchParamsPtr launch_params,
+ const LaunchNaClCallback& callback,
const std::vector<NaClResourcePrefetchResult>& prefetched_resource_files,
ppapi::PpapiPermissions permissions);
- void OnGetReadonlyPnaclFd(const std::string& filename,
- bool is_executable,
- IPC::Message* reply_msg);
- void OnNaClCreateTemporaryFile(IPC::Message* reply_msg);
- void OnNaClGetNumProcessors(int* num_processors);
- void OnGetNexeFd(int render_view_id,
- int pp_instance,
- const PnaclCacheInfo& cache_info);
- void OnTranslationFinished(int instance, bool success);
- void OnMissingArchError(int render_view_id);
- void OnOpenNaClExecutable(int render_view_id,
- const GURL& file_url,
- bool enable_validation_caching,
- IPC::Message* reply_msg);
- void SyncReturnTemporaryFile(IPC::Message* reply_msg,
- base::File file);
- void AsyncReturnTemporaryFile(int pp_instance,
- const base::File& file,
- bool is_hit);
- void OnNaClDebugEnabledForURL(const GURL& nmf_url, bool* should_debug);
-
- int render_process_id_;
+ void GetReadonlyPnaclFd(const std::string& filename,
+ bool is_executable,
+ const GetReadonlyPnaclFdCallback& callback) override;
+ void NaClCreateTemporaryFile(
+ const NaClCreateTemporaryFileCallback& callback) override;
+ void NaClGetNumProcessors(
+ const NaClGetNumProcessorsCallback& callback) override;
+ void NexeTempFileRequest(
+ int render_view_id,
+ int pp_instance,
+ const PnaclCacheInfo& cache_info,
+ const NexeTempFileRequestCallback& callback) override;
+ void ReportTranslationFinished(int instance, bool success) override;
+ void MissingArchError(int render_view_id) override;
+ void OpenNaClExecutable(int render_view_id,
+ const GURL& file_url,
+ bool enable_validation_caching,
+ const OpenNaClExecutableCallback& callback) override;
+ void NaClDebugEnabledForURL(
+ const GURL& nmf_url,
+ const NaClDebugEnabledForURLCallback& callback) override;
+
+ const int render_process_id_;
// off_the_record_ is copied from the profile partly so that it can be
// read on the IO thread.
- bool off_the_record_;
+ const bool off_the_record_;
base::FilePath profile_directory_;
- scoped_refptr<net::URLRequestContextGetter> request_context_;
+ scoped_refptr<NaClHostImpl> self_;
+ mojo::Binding<mojom::NaClHost> binding_;
- base::WeakPtrFactory<NaClHostMessageFilter> weak_ptr_factory_;
+ base::WeakPtrFactory<NaClHostImpl> weak_ptr_factory_;
- DISALLOW_COPY_AND_ASSIGN(NaClHostMessageFilter);
+ DISALLOW_COPY_AND_ASSIGN(NaClHostImpl);
};
} // namespace nacl
-#endif // COMPONENTS_NACL_BROWSER_NACL_HOST_MESSAGE_FILTER_H_
+#endif // COMPONENTS_NACL_BROWSER_NACL_HOST_IMPL_H_

Powered by Google App Engine
This is Rietveld 408576698