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

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
« no previous file with comments | « ppapi/proxy/ext_crx_file_system_private_resource.h ('k') | ppapi/proxy/file_system_resource.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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), called_open_(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 (called_open_)
37 return PP_ERROR_FAILED;
38 called_open_ = true;
39
40 if (!file_system_resource)
41 return PP_ERROR_BADARGUMENT;
42
43 Call<PpapiPluginMsg_Ext_CrxFileSystem_BrowserOpenReply>(BROWSER,
44 PpapiHostMsg_Ext_CrxFileSystem_BrowserOpen(),
45 base::Bind(&ExtCrxFileSystemPrivateResource::OnBrowserOpenComplete, this,
46 file_system_resource,
47 callback));
48 return PP_OK_COMPLETIONPENDING;
49 }
50
51 void ExtCrxFileSystemPrivateResource::OnBrowserOpenComplete(
52 PP_Resource* file_system_resource,
53 scoped_refptr<TrackedCallback> callback,
54 const ResourceMessageReplyParams& params,
55 const std::string& fsid) {
56 if (!TrackedCallback::IsPending(callback))
57 return;
58
59 if (params.result() != PP_OK) {
60 callback->Run(params.result());
61 return;
62 }
63
64 thunk::EnterResourceCreationNoLock enter(pp_instance());
65 if (enter.failed()) {
66 callback->Run(enter.retval());
67 return;
68 }
69
70 *file_system_resource = enter.functions()->CreateIsolatedFileSystem(
71 pp_instance(), fsid.c_str());
72 if (*file_system_resource != 0) {
73 callback->Run(PP_OK);
74 } else {
75 callback->Run(PP_ERROR_FAILED);
76 }
77 }
78
79 } // namespace proxy
80 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/ext_crx_file_system_private_resource.h ('k') | ppapi/proxy/file_system_resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698