• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 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 #ifndef LIBRARIES_NACL_IO_HTML5FS_HTML5_FS_H_
6 #define LIBRARIES_NACL_IO_HTML5FS_HTML5_FS_H_
7 
8 #include <pthread.h>
9 
10 #include "nacl_io/filesystem.h"
11 #include "nacl_io/pepper_interface.h"
12 #include "nacl_io/typed_fs_factory.h"
13 #include "sdk_util/simple_lock.h"
14 
15 namespace nacl_io {
16 
17 class Node;
18 
19 class Html5Fs : public Filesystem {
20  public:
21   virtual Error Access(const Path& path, int a_mode);
22   virtual Error Open(const Path& path, int mode, ScopedNode* out_node);
23   virtual Error Unlink(const Path& path);
24   virtual Error Mkdir(const Path& path, int permissions);
25   virtual Error Rmdir(const Path& path);
26   virtual Error Remove(const Path& path);
27   virtual Error Rename(const Path& path, const Path& newpath);
28 
filesystem_resource()29   PP_Resource filesystem_resource() { return filesystem_resource_; }
30 
31  protected:
32   static const int REMOVE_DIR = 1;
33   static const int REMOVE_FILE = 2;
34   static const int REMOVE_ALL = REMOVE_DIR | REMOVE_FILE;
35 
36   Html5Fs();
37 
38   virtual Error Init(const FsInitArgs& args);
39   virtual void Destroy();
40 
41   virtual Error RemoveInternal(const Path& path, int remove_type);
42   Error BlockUntilFilesystemOpen();
43 
44  private:
45   static void FilesystemOpenCallbackThunk(void* user_data, int32_t result);
46   void FilesystemOpenCallback(int32_t result);
47   Path GetFullPath(const Path& path);
48 
49   PP_Resource filesystem_resource_;
50   bool filesystem_open_has_result_;  // protected by lock_.
51   Error filesystem_open_error_;      // protected by lock_.
52 
53   pthread_cond_t filesystem_open_cond_;
54   sdk_util::SimpleLock filesysem_open_lock_;
55   std::string prefix_;
56 
57   friend class TypedFsFactory<Html5Fs>;
58 };
59 
60 }  // namespace nacl_io
61 
62 #endif  // LIBRARIES_NACL_IO_HTML5FS_HTML5_FS_H_
63