OLD | NEW |
---|---|
(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) { | |
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_Resource* file_system_resource, | |
34 scoped_refptr<TrackedCallback> callback) { | |
35 DCHECK(file_system_resource); | |
yzshen1
2013/05/02 23:22:01
Please return failure if necessary instead of DCHE
victorhsieh
2013/05/03 17:26:58
Done.
| |
36 | |
37 if (!TrackedCallback::IsPending(callback)) | |
yzshen1
2013/05/02 23:22:01
If you want to check whether it is in progress, yo
victorhsieh
2013/05/03 17:26:58
Done.
| |
38 return PP_ERROR_INPROGRESS; | |
39 | |
40 Call<PpapiPluginMsg_Ext_CrxFileSystem_BrowserOpenReply>(BROWSER, | |
41 PpapiHostMsg_Ext_CrxFileSystem_BrowserOpen(), | |
42 base::Bind(&ExtCrxFileSystemPrivateResource::OnBrowserOpenComplete, this, | |
43 file_system_resource, | |
44 callback)); | |
45 return PP_OK_COMPLETIONPENDING; | |
46 } | |
47 | |
48 void ExtCrxFileSystemPrivateResource::OnBrowserOpenComplete( | |
49 PP_Resource* file_system_resource, | |
50 scoped_refptr<TrackedCallback> callback, | |
51 const ResourceMessageReplyParams& params, | |
52 const std::string& fsid) { | |
yzshen1
2013/05/02 23:22:01
Test whether callback is still pending before doin
victorhsieh
2013/05/03 17:26:58
Done.
| |
53 if (params.result() != PP_OK) { | |
54 callback->Run(params.result()); | |
55 return; | |
56 } | |
57 | |
58 thunk::EnterResourceCreationNoLock enter(pp_instance()); | |
59 if (enter.failed()) { | |
60 callback->Run(enter.retval()); | |
61 return; | |
yzshen1
2013/05/02 23:22:01
[I don't know the answer but would like to make su
victorhsieh
2013/05/03 17:26:58
Isolated filesystem will live until the end of ren
| |
62 } | |
63 | |
64 *file_system_resource = enter.functions()->CreateIsolatedFileSystem( | |
65 pp_instance(), fsid.c_str()); | |
66 callback->Run(*file_system_resource > 0 ? PP_OK : PP_ERROR_FAILED); | |
67 } | |
68 | |
69 } // namespace proxy | |
70 } // namespace ppapi | |
OLD | NEW |