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

Side by Side 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, 7 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
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ppapi/proxy/ext_crx_file_system_private_resource.h"
6
7 #include "base/bind.h"
8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/proxy/ppapi_messages.h"
10 #include "ppapi/proxy/resource_message_params.h"
11 #include "ppapi/shared_impl/host_resource.h"
12 #include "ppapi/shared_impl/tracked_callback.h"
13 #include "ppapi/thunk/enter.h"
14
15 namespace ppapi {
16 namespace proxy {
17
18 ExtCrxFileSystemPrivateResource::ExtCrxFileSystemPrivateResource(
19 Connection connection, PP_Instance instance)
20 : PluginResource(connection, instance), opened_(false) {
21 SendCreate(BROWSER, PpapiHostMsg_Ext_CrxFileSystem_Create());
22 }
23
24 ExtCrxFileSystemPrivateResource::~ExtCrxFileSystemPrivateResource() {
25 }
26
27 thunk::PPB_Ext_CrxFileSystem_Private_API*
28 ExtCrxFileSystemPrivateResource::AsPPB_Ext_CrxFileSystem_Private_API() {
29 return this;
30 }
31
32 int32_t ExtCrxFileSystemPrivateResource::Open(
33 PP_Instance /* unused */,
34 PP_Resource* file_system_resource,
35 scoped_refptr<TrackedCallback> callback) {
36 if (!file_system_resource)
37 return PP_ERROR_BADARGUMENT;
38
39 if (opened_)
40 return PP_ERROR_FAILED;
41
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
42 Call<PpapiPluginMsg_Ext_CrxFileSystem_BrowserOpenReply>(BROWSER,
43 PpapiHostMsg_Ext_CrxFileSystem_BrowserOpen(),
44 base::Bind(&ExtCrxFileSystemPrivateResource::OnBrowserOpenComplete, this,
45 file_system_resource,
46 callback));
47 return PP_OK_COMPLETIONPENDING;
48 }
49
50 void ExtCrxFileSystemPrivateResource::OnBrowserOpenComplete(
51 PP_Resource* file_system_resource,
52 scoped_refptr<TrackedCallback> callback,
53 const ResourceMessageReplyParams& params,
54 const std::string& fsid) {
55 if (!TrackedCallback::IsPending(callback))
56 return;
57
58 if (params.result() != PP_OK) {
59 callback->Run(params.result());
60 return;
61 }
62
63 thunk::EnterResourceCreationNoLock enter(pp_instance());
64 if (enter.failed()) {
65 callback->Run(enter.retval());
66 return;
67 }
68
69 *file_system_resource = enter.functions()->CreateIsolatedFileSystem(
70 pp_instance(), fsid.c_str());
71 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.
72 opened_ = true;
73 callback->Run(PP_OK);
74 } else {
75 callback->Run(PP_ERROR_FAILED);
76 }
77 }
78
79 } // namespace proxy
80 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698