blob: 96e88c1a324b683b6857d9a2fb4d05c4d2c31789 [file] [log] [blame]
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001// Copyright (c) 2012 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#ifndef PPAPI_CPP_FILE_SYSTEM_H_
6#define PPAPI_CPP_FILE_SYSTEM_H_
7
8#include "ppapi/c/pp_file_info.h"
9#include "ppapi/c/pp_instance.h"
10#include "ppapi/c/pp_stdint.h"
11#include "ppapi/c/pp_time.h"
12#include "ppapi/cpp/instance.h"
13#include "ppapi/cpp/resource.h"
14
15/// @file
16/// This file defines the API to create a file system associated with a file.
17
18namespace pp {
19
20class CompletionCallback;
21
22/// The <code>FileSystem</code> class identifies the file system type
23/// associated with a file.
24class FileSystem : public Resource {
25 public:
26 /// Constructs an is_null() filesystem resource. If you use this constructor,
27 /// you will have to assign it to a "real" FileSystem object before you can
28 /// use it.
29 FileSystem();
30
Torne (Richard Coles)b2df76e2013-05-13 16:52:09 +010031 /// The copy constructor for <code>FileSystem</code>.
32 ///
33 /// @param[in] other A reference to a <code>FileSystem</code>.
34 FileSystem(const FileSystem& other);
35
Torne (Richard Coles)0f1bc082013-11-06 12:27:47 +000036 /// Constructs a <code>FileSystem</code> from a <code>Resource</code>.
37 ///
38 /// @param[in] resource A <code>Resource</code> containing a file system.
39 explicit FileSystem(const Resource& resource);
40
Torne (Richard Coles)b2df76e2013-05-13 16:52:09 +010041 /// A constructor used when you have received a PP_Resource as a return
42 /// value that has already been reference counted.
43 ///
44 /// @param[in] resource A PP_Resource corresponding to a PPB_FileSystem.
45 FileSystem(PassRef, PP_Resource resource);
46
Torne (Richard Coles)58218062012-11-14 11:43:16 +000047 /// This constructor creates a file system object of the given type.
48 ///
49 /// @param[in] instance The instance with which this resource will be
50 /// associated.
51 ///
52 /// @param[in] type A file system type as defined by
53 /// <code>PP_FileSystemType</code> enum.
54 FileSystem(const InstanceHandle& instance, PP_FileSystemType type);
55
56 /// Open() opens the file system. A file system must be opened before running
57 /// any other operation on it.
58 ///
59 /// @param[in] expected_size The expected size of the file system. Note that
60 /// this does not request quota; to do that, you must either invoke
61 /// requestQuota from JavaScript:
62 /// http://www.html5rocks.com/en/tutorials/file/filesystem/#toc-requesting-quota
63 /// or set the unlimitedStorage permission for Chrome Web Store apps:
64 /// http://code.google.com/chrome/extensions/manifest.html#permissions
65 ///
66 /// @param[in] cc A <code>PP_CompletionCallback</code> to be called upon
67 /// completion of Open().
68 ///
69 /// @return An int32_t containing an error code from <code>pp_errors.h</code>.
70 int32_t Open(int64_t expected_size, const CompletionCallback& cc);
Torne (Richard Coles)0f1bc082013-11-06 12:27:47 +000071
72 /// Checks whether a <code>Resource</code> is a file system, to test whether
73 /// it is appropriate for use with the <code>FileSystem</code> constructor.
74 ///
75 /// @param[in] resource A <code>Resource</code> to test.
76 ///
77 /// @return True if <code>resource</code> is a file system.
78 static bool IsFileSystem(const Resource& resource);
Torne (Richard Coles)58218062012-11-14 11:43:16 +000079};
80
81} // namespace pp
82
83#endif // PPAPI_CPP_FILE_SYSTEM_H_