- add sources.
[platform/framework/web/crosswalk.git] / src / ppapi / proxy / ext_crx_file_system_private_resource.h
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 // CRX filesystem is a filesystem that allows an extension to read its own
6 // package directory tree.  See ppapi/examples/crxfs for example.
7 //
8 // IMPLEMENTATION
9 //
10 // The implementation involves both browser and renderer.  In order to provide
11 // readonly access to CRX filesystem (i.e. extension directory), we create an
12 // "isolated filesystem" pointing to current extension directory in browser.
13 // Then browser grants read permission to renderer, and tells plugin the
14 // filesystem id, or fsid.
15 //
16 // Once the plugin receives the fsid, it creates a PPB_FileSystem and forwards
17 // the fsid to PepperFileSystemHost in order to construct root url.
18
19 #ifndef PPAPI_PROXY_EXT_CRX_FILE_SYSTEM_PRIVATE_RESOURCE_H_
20 #define PPAPI_PROXY_EXT_CRX_FILE_SYSTEM_PRIVATE_RESOURCE_H_
21
22 #include <string>
23
24 #include "base/memory/ref_counted.h"
25 #include "ppapi/proxy/connection.h"
26 #include "ppapi/proxy/plugin_resource.h"
27 #include "ppapi/proxy/ppapi_proxy_export.h"
28 #include "ppapi/thunk/ppb_ext_crx_file_system_private_api.h"
29
30 namespace ppapi {
31
32 class TrackedCallback;
33
34 namespace proxy {
35
36 class ResourceMessageReplyParams;
37
38 class PPAPI_PROXY_EXPORT ExtCrxFileSystemPrivateResource
39     : public PluginResource,
40       public thunk::PPB_Ext_CrxFileSystem_Private_API {
41  public:
42   ExtCrxFileSystemPrivateResource(Connection connection, PP_Instance instance);
43   virtual ~ExtCrxFileSystemPrivateResource();
44
45   // Resource overrides.
46   virtual thunk::PPB_Ext_CrxFileSystem_Private_API*
47       AsPPB_Ext_CrxFileSystem_Private_API() OVERRIDE;
48
49   // PPB_Ext_CrxFileSystem_Private_API implementation.
50   virtual int32_t Open(PP_Instance instance,
51                        PP_Resource* file_system_resource,
52                        scoped_refptr<TrackedCallback> callback) OVERRIDE;
53
54  private:
55   void OnBrowserOpenComplete(PP_Resource* file_system_resource,
56                              scoped_refptr<TrackedCallback> callback,
57                              const ResourceMessageReplyParams& params,
58                              const std::string& fsid);
59
60   bool called_open_;
61
62   DISALLOW_COPY_AND_ASSIGN(ExtCrxFileSystemPrivateResource);
63 };
64
65 }  // namespace proxy
66 }  // namespace ppapi
67
68 #endif  // PPAPI_PROXY_EXT_CRX_FILE_SYSTEM_PRIVATE_RESOURCE_H_