Add ICU message format support
[chromium-blink-merge.git] / content / browser / renderer_host / pepper / pepper_file_ref_host.h
blob5f6d11eb119a11979559dd946e3e331ed15e313e
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.
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FILE_REF_HOST_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FILE_REF_HOST_H_
8 #include <string>
10 #include "base/memory/weak_ptr.h"
11 #include "content/public/browser/browser_ppapi_host.h"
12 #include "ppapi/c/pp_file_info.h"
13 #include "ppapi/c/pp_instance.h"
14 #include "ppapi/c/pp_resource.h"
15 #include "ppapi/c/pp_time.h"
16 #include "ppapi/host/host_message_context.h"
17 #include "ppapi/host/resource_host.h"
18 #include "storage/browser/fileapi/file_system_url.h"
20 namespace content {
21 class PepperFileRefHost;
22 class PepperFileSystemBrowserHost;
24 // Internal and external filesystems have very different codepaths for
25 // performing FileRef operations. The logic is split into separate classes
26 // to make it easier to read.
27 class PepperFileRefBackend {
28 public:
29 virtual ~PepperFileRefBackend();
31 virtual int32_t MakeDirectory(ppapi::host::ReplyMessageContext context,
32 int32_t make_directory_flags) = 0;
33 virtual int32_t Touch(ppapi::host::ReplyMessageContext context,
34 PP_Time last_accessed_time,
35 PP_Time last_modified_time) = 0;
36 virtual int32_t Delete(ppapi::host::ReplyMessageContext context) = 0;
37 virtual int32_t Rename(ppapi::host::ReplyMessageContext context,
38 PepperFileRefHost* new_file_ref) = 0;
39 virtual int32_t Query(ppapi::host::ReplyMessageContext context) = 0;
40 virtual int32_t ReadDirectoryEntries(
41 ppapi::host::ReplyMessageContext context) = 0;
42 virtual int32_t GetAbsolutePath(ppapi::host::ReplyMessageContext context) = 0;
43 virtual storage::FileSystemURL GetFileSystemURL() const = 0;
44 virtual base::FilePath GetExternalFilePath() const = 0;
46 // Returns an error from the pp_errors.h enum.
47 virtual int32_t CanRead() const = 0;
48 virtual int32_t CanWrite() const = 0;
49 virtual int32_t CanCreate() const = 0;
50 virtual int32_t CanReadWrite() const = 0;
53 class CONTENT_EXPORT PepperFileRefHost
54 : public ppapi::host::ResourceHost,
55 public base::SupportsWeakPtr<PepperFileRefHost> {
56 public:
57 PepperFileRefHost(BrowserPpapiHost* host,
58 PP_Instance instance,
59 PP_Resource resource,
60 PP_Resource file_system,
61 const std::string& internal_path);
63 PepperFileRefHost(BrowserPpapiHost* host,
64 PP_Instance instance,
65 PP_Resource resource,
66 const base::FilePath& external_path);
68 ~PepperFileRefHost() override;
70 // ResourceHost overrides.
71 int32_t OnResourceMessageReceived(
72 const IPC::Message& msg,
73 ppapi::host::HostMessageContext* context) override;
74 bool IsFileRefHost() override;
76 // Required to support Rename().
77 PP_FileSystemType GetFileSystemType() const;
78 storage::FileSystemURL GetFileSystemURL() const;
80 // Required to support FileIO.
81 base::FilePath GetExternalFilePath() const;
82 base::WeakPtr<PepperFileSystemBrowserHost> GetFileSystemHost() const;
84 int32_t CanRead() const;
85 int32_t CanWrite() const;
86 int32_t CanCreate() const;
87 int32_t CanReadWrite() const;
89 private:
90 int32_t OnMakeDirectory(ppapi::host::HostMessageContext* context,
91 int32_t make_directory_flags);
92 int32_t OnTouch(ppapi::host::HostMessageContext* context,
93 PP_Time last_access_time,
94 PP_Time last_modified_time);
95 int32_t OnDelete(ppapi::host::HostMessageContext* context);
96 int32_t OnRename(ppapi::host::HostMessageContext* context,
97 PP_Resource new_file_ref);
98 int32_t OnQuery(ppapi::host::HostMessageContext* context);
99 int32_t OnReadDirectoryEntries(ppapi::host::HostMessageContext* context);
100 int32_t OnGetAbsolutePath(ppapi::host::HostMessageContext* context);
102 BrowserPpapiHost* host_;
103 scoped_ptr<PepperFileRefBackend> backend_;
104 base::WeakPtr<PepperFileSystemBrowserHost> file_system_host_;
105 PP_FileSystemType fs_type_;
107 DISALLOW_COPY_AND_ASSIGN(PepperFileRefHost);
110 } // namespace content
112 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FILE_REF_HOST_H_