Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / native_client_sdk / src / libraries / nacl_io / jsfs / js_fs_node.h
blob3c4f9ef2d6fc0f9ec330ad4790c105e1e00b370c
1 // Copyright 2014 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 #ifndef LIBRARIES_NACL_IO_JSFS_JS_FS_NODE_H_
6 #define LIBRARIES_NACL_IO_JSFS_JS_FS_NODE_H_
8 #include <pthread.h>
9 #include <stdarg.h>
11 #include <map>
13 #include <ppapi/c/pp_var.h>
15 #include "nacl_io/jsfs/js_fs.h"
16 #include "nacl_io/node.h"
18 namespace nacl_io {
20 class JsFsNode : public Node {
21 public:
22 typedef JsFs::RequestId RequestId;
24 protected:
25 JsFsNode(Filesystem* filesystem, int32_t fd);
26 virtual void Destroy();
28 public:
29 virtual bool CanOpen(int open_flags);
30 virtual Error GetStat(struct stat* stat);
31 virtual Error GetSize(off_t* out_size);
33 virtual Error FSync();
34 virtual Error FTruncate(off_t length);
35 virtual Error Read(const HandleAttr& attr,
36 void* buf,
37 size_t count,
38 int* out_bytes);
39 virtual Error Write(const HandleAttr& attr,
40 const void* buf,
41 size_t count,
42 int* out_bytes);
43 virtual Error GetDents(size_t offs,
44 struct dirent* pdir,
45 size_t count,
46 int* out_bytes);
48 int32_t fd() { return fd_; }
50 private:
51 bool SendRequestAndWait(ScopedVar* out_response, const char* format, ...);
52 int ScanVar(PP_Var var, const char* format, ...);
54 JsFs* filesystem() { return static_cast<JsFs*>(filesystem_); }
56 PepperInterface* ppapi_;
57 VarArrayInterface* array_iface_;
58 VarArrayBufferInterface* buffer_iface_;
59 VarInterface* var_iface_;
60 int32_t fd_;
62 friend class JsFs;
63 DISALLOW_COPY_AND_ASSIGN(JsFsNode);
66 } // namespace nacl_io
68 #endif // LIBRARIES_NACL_IO_JSFS_JS_FS_H_