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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/callback.h" |
9 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
10 #include "ppapi/c/pp_file_info.h" | 11 #include "ppapi/c/pp_file_info.h" |
11 #include "ppapi/host/host_message_context.h" | 12 #include "ppapi/host/host_message_context.h" |
12 #include "ppapi/host/resource_host.h" | 13 #include "ppapi/host/resource_host.h" |
13 #include "url/gurl.h" | 14 #include "url/gurl.h" |
14 #include "webkit/browser/fileapi/file_system_context.h" | 15 #include "webkit/browser/fileapi/file_system_context.h" |
15 #include "webkit/common/fileapi/file_system_types.h" | 16 #include "webkit/common/fileapi/file_system_types.h" |
16 | 17 |
17 namespace content { | 18 namespace content { |
18 | 19 |
19 class BrowserPpapiHost; | 20 class BrowserPpapiHost; |
20 | 21 |
21 class PepperFileSystemBrowserHost : | 22 class PepperFileSystemBrowserHost : |
22 public ppapi::host::ResourceHost, | 23 public ppapi::host::ResourceHost, |
23 public base::SupportsWeakPtr<PepperFileSystemBrowserHost> { | 24 public base::SupportsWeakPtr<PepperFileSystemBrowserHost> { |
24 public: | 25 public: |
25 // Creates a new PepperFileSystemBrowserHost for a file system of a given | 26 // Creates a new PepperFileSystemBrowserHost for a file system of a given |
26 // |type|. The host must be opened before use. | 27 // |type|. The host must be opened before use. |
27 PepperFileSystemBrowserHost(BrowserPpapiHost* host, | 28 PepperFileSystemBrowserHost(BrowserPpapiHost* host, |
28 PP_Instance instance, | 29 PP_Instance instance, |
29 PP_Resource resource, | 30 PP_Resource resource, |
30 PP_FileSystemType type); | 31 PP_FileSystemType type); |
31 // Creates a new PepperFileSystemBrowserHost with an existing file system at | |
32 // the given |root_url| and of the given |type|. The file system at |root_url| | |
33 // must already be opened. Once created, the PepperFileSystemBrowserHost may | |
34 // be used without being opened. | |
35 PepperFileSystemBrowserHost(BrowserPpapiHost* host, | |
36 PP_Instance instance, | |
37 PP_Resource resource, | |
38 const GURL& root_url, | |
39 PP_FileSystemType type); | |
40 virtual ~PepperFileSystemBrowserHost(); | 32 virtual ~PepperFileSystemBrowserHost(); |
41 | 33 |
| 34 // Opens the PepperFileSystemBrowserHost to use an existing file system at the |
| 35 // given |root_url|. The file system at |root_url| must already be opened and |
| 36 // have the type given by GetType(). |
| 37 // Calls |callback| when complete. |
| 38 void OpenExisting(const GURL& root_url, const base::Closure& callback); |
| 39 |
42 // ppapi::host::ResourceHost override. | 40 // ppapi::host::ResourceHost override. |
43 virtual int32_t OnResourceMessageReceived( | 41 virtual int32_t OnResourceMessageReceived( |
44 const IPC::Message& msg, | 42 const IPC::Message& msg, |
45 ppapi::host::HostMessageContext* context) OVERRIDE; | 43 ppapi::host::HostMessageContext* context) OVERRIDE; |
46 virtual bool IsFileSystemHost() OVERRIDE; | 44 virtual bool IsFileSystemHost() OVERRIDE; |
47 | 45 |
48 // Supports FileRefs direct access on the host side. | 46 // Supports FileRefs direct access on the host side. |
49 PP_FileSystemType GetType() const { return type_; } | 47 PP_FileSystemType GetType() const { return type_; } |
50 bool IsOpened() const { return opened_; } | 48 bool IsOpened() const { return opened_; } |
51 GURL GetRootUrl() const { return root_url_; } | 49 GURL GetRootUrl() const { return root_url_; } |
52 scoped_refptr<fileapi::FileSystemContext> GetFileSystemContext() const { | 50 scoped_refptr<fileapi::FileSystemContext> GetFileSystemContext() const { |
53 return fs_context_; | 51 return fs_context_; |
54 } | 52 } |
55 | 53 |
56 private: | 54 private: |
| 55 void OpenExistingWithContext( |
| 56 const base::Closure& callback, |
| 57 scoped_refptr<fileapi::FileSystemContext> fs_context); |
57 void GotFileSystemContext( | 58 void GotFileSystemContext( |
58 ppapi::host::ReplyMessageContext reply_context, | 59 ppapi::host::ReplyMessageContext reply_context, |
59 fileapi::FileSystemType file_system_type, | 60 fileapi::FileSystemType file_system_type, |
60 scoped_refptr<fileapi::FileSystemContext> fs_context); | 61 scoped_refptr<fileapi::FileSystemContext> fs_context); |
61 void GotIsolatedFileSystemContext( | 62 void GotIsolatedFileSystemContext( |
62 ppapi::host::ReplyMessageContext reply_context, | 63 ppapi::host::ReplyMessageContext reply_context, |
63 scoped_refptr<fileapi::FileSystemContext> fs_context); | 64 scoped_refptr<fileapi::FileSystemContext> fs_context); |
64 void OpenFileSystemComplete( | 65 void OpenFileSystemComplete( |
65 ppapi::host::ReplyMessageContext reply_context, | 66 ppapi::host::ReplyMessageContext reply_context, |
66 const GURL& root, | 67 const GURL& root, |
(...skipping 15 matching lines...) Expand all Loading... |
82 bool called_open_; // whether open has been called. | 83 bool called_open_; // whether open has been called. |
83 | 84 |
84 base::WeakPtrFactory<PepperFileSystemBrowserHost> weak_factory_; | 85 base::WeakPtrFactory<PepperFileSystemBrowserHost> weak_factory_; |
85 | 86 |
86 DISALLOW_COPY_AND_ASSIGN(PepperFileSystemBrowserHost); | 87 DISALLOW_COPY_AND_ASSIGN(PepperFileSystemBrowserHost); |
87 }; | 88 }; |
88 | 89 |
89 } // namespace content | 90 } // namespace content |
90 | 91 |
91 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FILE_SYSTEM_BROWSER_HOST_
H_ | 92 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FILE_SYSTEM_BROWSER_HOST_
H_ |
OLD | NEW |