cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / ppapi / proxy / ext_crx_file_system_private_resource.cc
blobbe4c3f7bbd53d10f4525d81c0e47faabacd1d0f8
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.
5 #include "ppapi/proxy/ext_crx_file_system_private_resource.h"
7 #include "base/bind.h"
8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/c/pp_file_info.h"
10 #include "ppapi/proxy/file_system_resource.h"
11 #include "ppapi/proxy/ppapi_messages.h"
12 #include "ppapi/proxy/resource_message_params.h"
13 #include "ppapi/shared_impl/host_resource.h"
14 #include "ppapi/shared_impl/tracked_callback.h"
15 #include "ppapi/thunk/enter.h"
17 namespace ppapi {
18 namespace proxy {
20 namespace {
21 void RunTrackedCallback(scoped_refptr<TrackedCallback> callback,
22 int32_t rc) {
23 callback->Run(rc);
25 } // namespace
27 ExtCrxFileSystemPrivateResource::ExtCrxFileSystemPrivateResource(
28 Connection connection, PP_Instance instance)
29 : PluginResource(connection, instance), called_open_(false) {
30 SendCreate(BROWSER, PpapiHostMsg_Ext_CrxFileSystem_Create());
33 ExtCrxFileSystemPrivateResource::~ExtCrxFileSystemPrivateResource() {
36 thunk::PPB_Ext_CrxFileSystem_Private_API*
37 ExtCrxFileSystemPrivateResource::AsPPB_Ext_CrxFileSystem_Private_API() {
38 return this;
41 int32_t ExtCrxFileSystemPrivateResource::Open(
42 PP_Instance /* unused */,
43 PP_Resource* file_system_resource,
44 scoped_refptr<TrackedCallback> callback) {
45 if (called_open_)
46 return PP_ERROR_FAILED;
47 called_open_ = true;
49 if (!file_system_resource)
50 return PP_ERROR_BADARGUMENT;
52 Call<PpapiPluginMsg_Ext_CrxFileSystem_BrowserOpenReply>(BROWSER,
53 PpapiHostMsg_Ext_CrxFileSystem_BrowserOpen(),
54 base::Bind(&ExtCrxFileSystemPrivateResource::OnBrowserOpenComplete, this,
55 file_system_resource,
56 callback));
57 return PP_OK_COMPLETIONPENDING;
60 void ExtCrxFileSystemPrivateResource::OnBrowserOpenComplete(
61 PP_Resource* file_system_resource,
62 scoped_refptr<TrackedCallback> callback,
63 const ResourceMessageReplyParams& params,
64 const std::string& fsid) {
65 if (!TrackedCallback::IsPending(callback))
66 return;
68 if (params.result() != PP_OK) {
69 callback->Run(params.result());
70 return;
73 FileSystemResource* fs = new FileSystemResource(
74 connection(), pp_instance(), PP_FILESYSTEMTYPE_ISOLATED);
75 *file_system_resource = fs->GetReference();
76 if (*file_system_resource == 0)
77 callback->Run(PP_ERROR_FAILED);
78 fs->InitIsolatedFileSystem(fsid, base::Bind(&RunTrackedCallback, callback));
81 } // namespace proxy
82 } // namespace ppapi