OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FILE_SYSTEM_BROWSER_HOST_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FILE_SYSTEM_BROWSER_HOST_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FILE_SYSTEM_BROWSER_HOST_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FILE_SYSTEM_BROWSER_HOST_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "content/common/content_export.h" |
13 #include "ppapi/c/pp_file_info.h" | 14 #include "ppapi/c/pp_file_info.h" |
14 #include "ppapi/c/private/ppb_isolated_file_system_private.h" | 15 #include "ppapi/c/private/ppb_isolated_file_system_private.h" |
15 #include "ppapi/host/host_message_context.h" | 16 #include "ppapi/host/host_message_context.h" |
16 #include "ppapi/host/resource_host.h" | 17 #include "ppapi/host/resource_host.h" |
17 #include "url/gurl.h" | 18 #include "url/gurl.h" |
18 #include "webkit/browser/fileapi/file_system_context.h" | 19 #include "webkit/browser/fileapi/file_system_context.h" |
19 #include "webkit/common/fileapi/file_system_types.h" | 20 #include "webkit/common/fileapi/file_system_types.h" |
20 | 21 |
21 namespace content { | 22 namespace content { |
22 | 23 |
23 class BrowserPpapiHost; | 24 class BrowserPpapiHost; |
24 | 25 |
25 class PepperFileSystemBrowserHost | 26 class CONTENT_EXPORT PepperFileSystemBrowserHost |
26 : public ppapi::host::ResourceHost, | 27 : public ppapi::host::ResourceHost, |
27 public base::SupportsWeakPtr<PepperFileSystemBrowserHost> { | 28 public base::SupportsWeakPtr<PepperFileSystemBrowserHost> { |
28 public: | 29 public: |
29 // Creates a new PepperFileSystemBrowserHost for a file system of a given | 30 // Creates a new PepperFileSystemBrowserHost for a file system of a given |
30 // |type|. The host must be opened before use. | 31 // |type|. The host must be opened before use. |
31 PepperFileSystemBrowserHost(BrowserPpapiHost* host, | 32 PepperFileSystemBrowserHost(BrowserPpapiHost* host, |
32 PP_Instance instance, | 33 PP_Instance instance, |
33 PP_Resource resource, | 34 PP_Resource resource, |
34 PP_FileSystemType type); | 35 PP_FileSystemType type); |
35 virtual ~PepperFileSystemBrowserHost(); | 36 virtual ~PepperFileSystemBrowserHost(); |
(...skipping 12 matching lines...) Expand all Loading... |
48 | 49 |
49 // Supports FileRefs direct access on the host side. | 50 // Supports FileRefs direct access on the host side. |
50 PP_FileSystemType GetType() const { return type_; } | 51 PP_FileSystemType GetType() const { return type_; } |
51 bool IsOpened() const { return opened_; } | 52 bool IsOpened() const { return opened_; } |
52 GURL GetRootUrl() const { return root_url_; } | 53 GURL GetRootUrl() const { return root_url_; } |
53 scoped_refptr<fileapi::FileSystemContext> GetFileSystemContext() const { | 54 scoped_refptr<fileapi::FileSystemContext> GetFileSystemContext() const { |
54 return fs_context_; | 55 return fs_context_; |
55 } | 56 } |
56 | 57 |
57 private: | 58 private: |
| 59 friend class PepperFileSystemBrowserHostTest; |
| 60 |
58 void OpenExistingWithContext( | 61 void OpenExistingWithContext( |
59 const base::Closure& callback, | 62 const base::Closure& callback, |
60 scoped_refptr<fileapi::FileSystemContext> fs_context); | 63 scoped_refptr<fileapi::FileSystemContext> fs_context); |
61 void GotFileSystemContext( | 64 void GotFileSystemContext( |
62 ppapi::host::ReplyMessageContext reply_context, | 65 ppapi::host::ReplyMessageContext reply_context, |
63 fileapi::FileSystemType file_system_type, | 66 fileapi::FileSystemType file_system_type, |
64 scoped_refptr<fileapi::FileSystemContext> fs_context); | 67 scoped_refptr<fileapi::FileSystemContext> fs_context); |
65 void GotIsolatedFileSystemContext( | |
66 ppapi::host::ReplyMessageContext reply_context, | |
67 scoped_refptr<fileapi::FileSystemContext> fs_context); | |
68 void OpenFileSystemComplete( | 68 void OpenFileSystemComplete( |
69 ppapi::host::ReplyMessageContext reply_context, | 69 ppapi::host::ReplyMessageContext reply_context, |
70 const GURL& root, | 70 const GURL& root, |
71 const std::string& name, | 71 const std::string& name, |
72 base::PlatformFileError error); | 72 base::PlatformFileError error); |
| 73 void GotIsolatedFileSystemContext( |
| 74 ppapi::host::ReplyMessageContext reply_context, |
| 75 const std::string& fsid, |
| 76 PP_IsolatedFileSystemType_Private type, |
| 77 scoped_refptr<fileapi::FileSystemContext> fs_context); |
| 78 void OpenPluginPrivateFileSystem( |
| 79 ppapi::host::ReplyMessageContext reply_context, |
| 80 const std::string& fsid, |
| 81 scoped_refptr<fileapi::FileSystemContext> fs_context); |
| 82 void OpenPluginPrivateFileSystemComplete( |
| 83 ppapi::host::ReplyMessageContext reply_context, |
| 84 const std::string& fsid, |
| 85 base::PlatformFileError error); |
73 | 86 |
74 int32_t OnHostMsgOpen(ppapi::host::HostMessageContext* context, | 87 int32_t OnHostMsgOpen(ppapi::host::HostMessageContext* context, |
75 int64_t expected_size); | 88 int64_t expected_size); |
76 int32_t OnHostMsgInitIsolatedFileSystem( | 89 int32_t OnHostMsgInitIsolatedFileSystem( |
77 ppapi::host::HostMessageContext* context, | 90 ppapi::host::HostMessageContext* context, |
78 const std::string& fsid, | 91 const std::string& fsid, |
79 PP_IsolatedFileSystemType_Private type); | 92 PP_IsolatedFileSystemType_Private type); |
80 | 93 |
| 94 void SendReplyForIsolatedFileSystem( |
| 95 ppapi::host::ReplyMessageContext reply_context, |
| 96 const std::string& fsid, |
| 97 int32_t error); |
| 98 |
| 99 std::string GetPluginMimeType() const; |
| 100 |
| 101 // Returns plugin ID generated from plugin's MIME type. |
| 102 std::string GeneratePluginId(const std::string& mime_type) const; |
| 103 |
81 BrowserPpapiHost* browser_ppapi_host_; | 104 BrowserPpapiHost* browser_ppapi_host_; |
82 | 105 |
83 PP_FileSystemType type_; | 106 PP_FileSystemType type_; |
84 bool opened_; // whether open is successful. | 107 bool opened_; // whether open is successful. |
85 GURL root_url_; | 108 GURL root_url_; |
86 scoped_refptr<fileapi::FileSystemContext> fs_context_; | 109 scoped_refptr<fileapi::FileSystemContext> fs_context_; |
87 bool called_open_; // whether open has been called. | 110 bool called_open_; // whether open has been called. |
88 | 111 |
| 112 std::string fsid_; // used only for isolated filesystems. |
| 113 |
89 base::WeakPtrFactory<PepperFileSystemBrowserHost> weak_factory_; | 114 base::WeakPtrFactory<PepperFileSystemBrowserHost> weak_factory_; |
90 | 115 |
91 DISALLOW_COPY_AND_ASSIGN(PepperFileSystemBrowserHost); | 116 DISALLOW_COPY_AND_ASSIGN(PepperFileSystemBrowserHost); |
92 }; | 117 }; |
93 | 118 |
94 } // namespace content | 119 } // namespace content |
95 | 120 |
96 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FILE_SYSTEM_BROWSER_HOST_
H_ | 121 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FILE_SYSTEM_BROWSER_HOST_
H_ |
OLD | NEW |