Home | History | Annotate | Download | only in nacl_io
      1 // 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 LIBRARIES_NACL_IO_MOUNT_HTML5FS_H_
      6 #define LIBRARIES_NACL_IO_MOUNT_HTML5FS_H_
      7 
      8 #include <pthread.h>
      9 
     10 #include "nacl_io/mount.h"
     11 #include "nacl_io/pepper_interface.h"
     12 #include "nacl_io/typed_mount_factory.h"
     13 #include "sdk_util/simple_lock.h"
     14 
     15 namespace nacl_io {
     16 
     17 class MountNode;
     18 
     19 class MountHtml5Fs : public Mount {
     20  public:
     21   virtual Error Access(const Path& path, int a_mode);
     22   virtual Error Open(const Path& path, int mode, ScopedMountNode* 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 
     28   PP_Resource filesystem_resource() { return filesystem_resource_; }
     29 
     30  protected:
     31   MountHtml5Fs();
     32 
     33   virtual Error Init(int dev, StringMap_t& args, PepperInterface* ppapi);
     34   virtual void Destroy();
     35 
     36   Error BlockUntilFilesystemOpen();
     37 
     38  private:
     39   static void FilesystemOpenCallbackThunk(void* user_data, int32_t result);
     40   void FilesystemOpenCallback(int32_t result);
     41 
     42   PP_Resource filesystem_resource_;
     43   bool filesystem_open_has_result_;  // protected by lock_.
     44   Error filesystem_open_error_;      // protected by lock_.
     45 
     46   pthread_cond_t filesystem_open_cond_;
     47   sdk_util::SimpleLock filesysem_open_lock_;
     48 
     49   friend class TypedMountFactory<MountHtml5Fs>;
     50 };
     51 
     52 }  // namespace nacl_io
     53 
     54 #endif  // LIBRARIES_NACL_IO_MOUNT_HTML5FS_H_
     55