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

Unified Diff: ppapi/proxy/ext_crx_file_system_private_resource.cc

Issue 14188019: CRX FileSystem Pepper private API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 8 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: ppapi/proxy/ext_crx_file_system_private_resource.cc
diff --git a/ppapi/proxy/ext_crx_file_system_private_resource.cc b/ppapi/proxy/ext_crx_file_system_private_resource.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a30404e75b1e81112c5f9b709f54c426ce708ead
--- /dev/null
+++ b/ppapi/proxy/ext_crx_file_system_private_resource.cc
@@ -0,0 +1,80 @@
+// Copyright (c) 2013 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/ext_crx_file_system_private_resource.h"
+
+#include "base/bind.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/proxy/resource_message_params.h"
+#include "ppapi/shared_impl/host_resource.h"
+#include "ppapi/shared_impl/tracked_callback.h"
+#include "ppapi/thunk/enter.h"
+
+namespace ppapi {
+namespace proxy {
+
+ExtCrxFileSystemPrivateResource::ExtCrxFileSystemPrivateResource(
+ Connection connection, PP_Instance instance)
+ : PluginResource(connection, instance), opened_(false) {
+ SendCreate(BROWSER, PpapiHostMsg_Ext_CrxFileSystem_Create());
+}
+
+ExtCrxFileSystemPrivateResource::~ExtCrxFileSystemPrivateResource() {
+}
+
+thunk::PPB_Ext_CrxFileSystem_Private_API*
+ExtCrxFileSystemPrivateResource::AsPPB_Ext_CrxFileSystem_Private_API() {
+ return this;
+}
+
+int32_t ExtCrxFileSystemPrivateResource::Open(
+ PP_Instance /* unused */,
+ PP_Resource* file_system_resource,
+ scoped_refptr<TrackedCallback> callback) {
+ if (!file_system_resource)
+ return PP_ERROR_BADARGUMENT;
+
+ if (opened_)
+ return PP_ERROR_FAILED;
+
yzshen1 2013/05/06 17:34:57 What if a second call to Open() happens before |op
victorhsieh 2013/05/06 18:32:02 Now it works like FileSystem: Open can be called o
+ Call<PpapiPluginMsg_Ext_CrxFileSystem_BrowserOpenReply>(BROWSER,
+ PpapiHostMsg_Ext_CrxFileSystem_BrowserOpen(),
+ base::Bind(&ExtCrxFileSystemPrivateResource::OnBrowserOpenComplete, this,
+ file_system_resource,
+ callback));
+ return PP_OK_COMPLETIONPENDING;
+}
+
+void ExtCrxFileSystemPrivateResource::OnBrowserOpenComplete(
+ PP_Resource* file_system_resource,
+ scoped_refptr<TrackedCallback> callback,
+ const ResourceMessageReplyParams& params,
+ const std::string& fsid) {
+ if (!TrackedCallback::IsPending(callback))
+ return;
+
+ if (params.result() != PP_OK) {
+ callback->Run(params.result());
+ return;
+ }
+
+ thunk::EnterResourceCreationNoLock enter(pp_instance());
+ if (enter.failed()) {
+ callback->Run(enter.retval());
+ return;
+ }
+
+ *file_system_resource = enter.functions()->CreateIsolatedFileSystem(
+ pp_instance(), fsid.c_str());
+ if (*file_system_resource > 0) {
yzshen1 2013/05/06 17:34:57 nit: Please use != 0. (for consistency)
victorhsieh 2013/05/06 18:32:02 Done.
+ opened_ = true;
+ callback->Run(PP_OK);
+ } else {
+ callback->Run(PP_ERROR_FAILED);
+ }
+}
+
+} // namespace proxy
+} // namespace ppapi

Powered by Google App Engine
This is Rietveld 408576698