summaryrefslogtreecommitdiffstats
path: root/native_client_sdk/src/libraries/nacl_io/mount_html5fs.h
blob: 06dad78d90c06e74275ba724c968d616bdc9b1f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef LIBRARIES_NACL_IO_MOUNT_HTML5FS_H_
#define LIBRARIES_NACL_IO_MOUNT_HTML5FS_H_

#include <pthread.h>

#include "nacl_io/mount.h"
#include "nacl_io/pepper_interface.h"
#include "nacl_io/typed_mount_factory.h"
#include "sdk_util/simple_lock.h"

namespace nacl_io {

class MountNode;

class MountHtml5Fs : public Mount {
 public:
  virtual Error Access(const Path& path, int a_mode);
  virtual Error Open(const Path& path, int mode, ScopedMountNode* out_node);
  virtual Error Unlink(const Path& path);
  virtual Error Mkdir(const Path& path, int permissions);
  virtual Error Rmdir(const Path& path);
  virtual Error Remove(const Path& path);
  virtual Error Rename(const Path& path, const Path& newpath);

  PP_Resource filesystem_resource() { return filesystem_resource_; }

 protected:
  MountHtml5Fs();

  virtual Error Init(const MountInitArgs& args);
  virtual void Destroy();

  Error BlockUntilFilesystemOpen();

 private:
  static void FilesystemOpenCallbackThunk(void* user_data, int32_t result);
  void FilesystemOpenCallback(int32_t result);

  PP_Resource filesystem_resource_;
  bool filesystem_open_has_result_;  // protected by lock_.
  Error filesystem_open_error_;      // protected by lock_.

  pthread_cond_t filesystem_open_cond_;
  sdk_util::SimpleLock filesysem_open_lock_;

  friend class TypedMountFactory<MountHtml5Fs>;
};

}  // namespace nacl_io

#endif  // LIBRARIES_NACL_IO_MOUNT_HTML5FS_H_