Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / xwalk / experimental / native_file_system / native_file_system_extension.h
1 // Copyright (c) 2014 Intel Corporation. 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 XWALK_EXPERIMENTAL_NATIVE_FILE_SYSTEM_NATIVE_FILE_SYSTEM_EXTENSION_H_
6 #define XWALK_EXPERIMENTAL_NATIVE_FILE_SYSTEM_NATIVE_FILE_SYSTEM_EXTENSION_H_
7
8 #include <string>
9
10 #include "base/values.h"
11 #include "content/public/browser/render_process_host.h"
12 #include "xwalk/extensions/browser/xwalk_extension_function_handler.h"
13 #include "xwalk/extensions/common/xwalk_extension.h"
14
15 namespace xwalk {
16 namespace experimental {
17
18 using extensions::XWalkExtension;
19 using extensions::XWalkExtensionFunctionHandler;
20 using extensions::XWalkExtensionFunctionInfo;
21 using extensions::XWalkExtensionInstance;
22
23 class NativeFileSystemExtension : public XWalkExtension {
24  public:
25   explicit NativeFileSystemExtension(content::RenderProcessHost* host);
26   virtual ~NativeFileSystemExtension();
27
28   // XWalkExtension implementation.
29   virtual XWalkExtensionInstance* CreateInstance() OVERRIDE;
30
31  private:
32   content::RenderProcessHost* host_;
33 };
34
35 class NativeFileSystemInstance : public XWalkExtensionInstance {
36  public:
37   explicit NativeFileSystemInstance(content::RenderProcessHost* host);
38
39   // XWalkExtensionInstance implementation.
40   virtual void HandleMessage(scoped_ptr<base::Value> msg) OVERRIDE;
41
42  private:
43   XWalkExtensionFunctionHandler handler_;
44   content::RenderProcessHost* host_;
45 };
46
47 class FileSystemChecker
48     : public base::RefCountedThreadSafe<FileSystemChecker> {
49  public:
50   FileSystemChecker(
51       int process_id,
52       const std::string& path,
53       const std::string& root_name,
54       const std::string& promise_id,
55       XWalkExtensionInstance* instance);
56   void DoTask();
57
58  private:
59   void RegisterFileSystemsAndSendResponse();
60
61   int process_id_;
62   std::string path_;
63   std::string root_name_;
64   std::string promise_id_;
65   XWalkExtensionInstance* instance_;
66
67   DISALLOW_COPY_AND_ASSIGN(FileSystemChecker);
68 };
69
70 }  // namespace experimental
71 }  // namespace xwalk
72
73 #endif  // XWALK_EXPERIMENTAL_NATIVE_FILE_SYSTEM_NATIVE_FILE_SYSTEM_EXTENSION_H_