Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / content / browser / renderer_host / pepper / pepper_external_file_ref_backend.h
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 CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_EXTERNAL_FILE_REF_BACKEND_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_EXTERNAL_FILE_REF_BACKEND_H_
7
8 #include <string>
9
10 #include "base/files/file.h"
11 #include "base/files/file_path.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/task_runner.h"
14 #include "content/browser/renderer_host/pepper/pepper_file_ref_host.h"
15 #include "ppapi/c/pp_instance.h"
16 #include "ppapi/c/pp_resource.h"
17 #include "ppapi/c/pp_time.h"
18 #include "ppapi/host/ppapi_host.h"
19
20 namespace content {
21
22 // Implementations of FileRef operations for external filesystems.
23 class PepperExternalFileRefBackend : public PepperFileRefBackend {
24  public:
25   PepperExternalFileRefBackend(ppapi::host::PpapiHost* host,
26                                int render_process_id,
27                                const base::FilePath& path);
28   ~PepperExternalFileRefBackend() override;
29
30   // PepperFileRefBackend overrides.
31   int32_t MakeDirectory(ppapi::host::ReplyMessageContext context,
32                         int32_t make_directory_flags) override;
33   int32_t Touch(ppapi::host::ReplyMessageContext context,
34                 PP_Time last_accessed_time,
35                 PP_Time last_modified_time) override;
36   int32_t Delete(ppapi::host::ReplyMessageContext context) override;
37   int32_t Rename(ppapi::host::ReplyMessageContext context,
38                  PepperFileRefHost* new_file_ref) override;
39   int32_t Query(ppapi::host::ReplyMessageContext context) override;
40   int32_t ReadDirectoryEntries(
41       ppapi::host::ReplyMessageContext context) override;
42   int32_t GetAbsolutePath(ppapi::host::ReplyMessageContext context) override;
43   storage::FileSystemURL GetFileSystemURL() const override;
44   base::FilePath GetExternalFilePath() const override;
45
46   int32_t CanRead() const override;
47   int32_t CanWrite() const override;
48   int32_t CanCreate() const override;
49   int32_t CanReadWrite() const override;
50
51  private:
52   // Generic reply callback.
53   void DidFinish(ppapi::host::ReplyMessageContext reply_context,
54                  const IPC::Message& msg,
55                  base::File::Error error);
56
57   // Operation specific callbacks.
58   void GetMetadataComplete(ppapi::host::ReplyMessageContext reply_context,
59                            base::File::Error error,
60                            const base::File::Info& file_info);
61
62   ppapi::host::PpapiHost* host_;
63   base::FilePath path_;
64   int render_process_id_;
65
66   scoped_refptr<base::TaskRunner> task_runner_;
67
68   base::WeakPtrFactory<PepperExternalFileRefBackend> weak_factory_;
69
70   DISALLOW_COPY_AND_ASSIGN(PepperExternalFileRefBackend);
71 };
72
73 }  // namespace content
74
75 #endif  // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_EXTERNAL_FILE_REF_BACKEND_H_