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

Unified Diff: ppapi/proxy/mojo_resource.cc

Issue 598183002: Pepper: PPB_Mojo prototype. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « ppapi/proxy/mojo_resource.h ('k') | ppapi/proxy/ppapi_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/mojo_resource.cc
diff --git a/ppapi/proxy/mojo_resource.cc b/ppapi/proxy/mojo_resource.cc
new file mode 100644
index 0000000000000000000000000000000000000000..152cd9045c0319595acd978e28942d67bfc398fa
--- /dev/null
+++ b/ppapi/proxy/mojo_resource.cc
@@ -0,0 +1,49 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ppapi/proxy/mojo_resource.h"
+
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/proxy/ppapi_messages.h"
+
+namespace ppapi {
+namespace proxy {
+
+MojoResource::MojoResource(Connection connection, PP_Instance instance)
+ : PluginResource(connection, instance) {
+ SendCreate(BROWSER, PpapiHostMsg_Mojo_Create());
+}
+
+MojoResource::~MojoResource() {
+}
+
+thunk::PPB_Mojo_API* MojoResource::AsPPB_Mojo_API() {
+ return this;
+}
+
+int32_t MojoResource::GetHandle(PP_Instance instance,
+ uint32_t* out_mojo_handle,
+ scoped_refptr<TrackedCallback> callback) {
+ Call<PpapiPluginMsg_Mojo_GetHandleReply>(
+ BROWSER,
+ PpapiHostMsg_Mojo_GetHandle(),
+ base::Bind(&MojoResource::GetHandleComplete,
+ this, out_mojo_handle, callback));
+ return PP_OK_COMPLETIONPENDING;
+}
+
+void MojoResource::GetHandleComplete(uint32_t* out_mojo_handle,
+ scoped_refptr<TrackedCallback> callback,
+ const ResourceMessageReplyParams& params) {
+ IPC::PlatformFileForTransit transit_file;
+ if (!params.TakeFileHandleAtIndex(0, &transit_file)) {
+ callback->Run(PP_ERROR_FAILED);
+ return;
+ }
+ *out_mojo_handle = transit_file.fd;
+ callback->Run(PP_OK);
+}
+
+} // namespace proxy
+} // namespace ppapi
« no previous file with comments | « ppapi/proxy/mojo_resource.h ('k') | ppapi/proxy/ppapi_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698