OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "webkit/glue/plugins/pepper_file_system.h" | 5 #include "webkit/plugins/ppapi/ppb_file_system_impl.h" |
6 | 6 |
7 #include "base/ref_counted.h" | 7 #include "base/ref_counted.h" |
8 #include "ppapi/c/dev/ppb_file_system_dev.h" | 8 #include "ppapi/c/dev/ppb_file_system_dev.h" |
9 #include "ppapi/c/pp_completion_callback.h" | 9 #include "ppapi/c/pp_completion_callback.h" |
10 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" | 10 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" |
11 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h" | 11 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h" |
12 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" | 12 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" |
13 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h" | 13 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h" |
14 #include "webkit/fileapi/file_system_types.h" | 14 #include "webkit/fileapi/file_system_types.h" |
15 #include "webkit/glue/plugins/pepper_directory_reader.h" | 15 #include "webkit/plugins/ppapi/file_callbacks.h" |
16 #include "webkit/glue/plugins/pepper_file_callbacks.h" | 16 #include "webkit/plugins/ppapi/plugin_delegate.h" |
17 #include "webkit/glue/plugins/pepper_plugin_delegate.h" | 17 #include "webkit/plugins/ppapi/plugin_instance.h" |
18 #include "webkit/glue/plugins/pepper_plugin_instance.h" | 18 #include "webkit/plugins/ppapi/plugin_module.h" |
19 #include "webkit/glue/plugins/pepper_plugin_module.h" | 19 #include "webkit/plugins/ppapi/ppb_directory_reader_impl.h" |
20 #include "webkit/glue/plugins/pepper_resource.h" | 20 #include "webkit/plugins/ppapi/resource.h" |
21 #include "webkit/glue/plugins/pepper_resource_tracker.h" | 21 #include "webkit/plugins/ppapi/resource_tracker.h" |
22 | 22 |
23 namespace pepper { | 23 namespace webkit { |
| 24 namespace ppapi { |
24 | 25 |
25 namespace { | 26 namespace { |
26 | 27 |
27 PP_Resource Create(PP_Instance instance, PP_FileSystemType_Dev type) { | 28 PP_Resource Create(PP_Instance instance, PP_FileSystemType_Dev type) { |
28 PluginInstance* plugin_instance = | 29 PluginInstance* plugin_instance = |
29 ResourceTracker::Get()->GetInstance(instance); | 30 ResourceTracker::Get()->GetInstance(instance); |
30 if (!plugin_instance) | 31 if (!plugin_instance) |
31 return 0; | 32 return 0; |
32 | 33 |
33 FileSystem* file_system = new FileSystem(plugin_instance, type); | 34 PPB_FileSystem_Impl* file_system = |
| 35 new PPB_FileSystem_Impl(plugin_instance, type); |
34 return file_system->GetReference(); | 36 return file_system->GetReference(); |
35 } | 37 } |
36 | 38 |
37 int32_t Open(PP_Resource file_system_id, | 39 int32_t Open(PP_Resource file_system_id, |
38 int64 expected_size, | 40 int64 expected_size, |
39 PP_CompletionCallback callback) { | 41 PP_CompletionCallback callback) { |
40 scoped_refptr<FileSystem> file_system( | 42 scoped_refptr<PPB_FileSystem_Impl> file_system( |
41 Resource::GetAs<FileSystem>(file_system_id)); | 43 Resource::GetAs<PPB_FileSystem_Impl>(file_system_id)); |
42 if (!file_system) | 44 if (!file_system) |
43 return PP_ERROR_BADRESOURCE; | 45 return PP_ERROR_BADRESOURCE; |
44 | 46 |
45 if (file_system->opened()) | 47 if (file_system->opened()) |
46 return PP_OK; | 48 return PP_OK; |
47 | 49 |
48 if ((file_system->type() != PP_FILESYSTEMTYPE_LOCALPERSISTENT) && | 50 if ((file_system->type() != PP_FILESYSTEMTYPE_LOCALPERSISTENT) && |
49 (file_system->type() != PP_FILESYSTEMTYPE_LOCALTEMPORARY)) | 51 (file_system->type() != PP_FILESYSTEMTYPE_LOCALTEMPORARY)) |
50 return PP_ERROR_FAILED; | 52 return PP_ERROR_FAILED; |
51 | 53 |
(...skipping 12 matching lines...) Expand all Loading... |
64 return PP_ERROR_WOULDBLOCK; | 66 return PP_ERROR_WOULDBLOCK; |
65 } | 67 } |
66 | 68 |
67 const PPB_FileSystem_Dev ppb_filesystem = { | 69 const PPB_FileSystem_Dev ppb_filesystem = { |
68 &Create, | 70 &Create, |
69 &Open | 71 &Open |
70 }; | 72 }; |
71 | 73 |
72 } // namespace | 74 } // namespace |
73 | 75 |
74 FileSystem::FileSystem(PluginInstance* instance, PP_FileSystemType_Dev type) | 76 PPB_FileSystem_Impl::PPB_FileSystem_Impl(PluginInstance* instance, |
| 77 PP_FileSystemType_Dev type) |
75 : Resource(instance->module()), | 78 : Resource(instance->module()), |
76 instance_(instance), | 79 instance_(instance), |
77 type_(type), | 80 type_(type), |
78 opened_(false) { | 81 opened_(false) { |
79 } | 82 } |
80 | 83 |
81 FileSystem* FileSystem::AsFileSystem() { | 84 PPB_FileSystem_Impl* PPB_FileSystem_Impl::AsPPB_FileSystem_Impl() { |
82 return this; | 85 return this; |
83 } | 86 } |
84 | 87 |
85 const PPB_FileSystem_Dev* FileSystem::GetInterface() { | 88 const PPB_FileSystem_Dev* PPB_FileSystem_Impl::GetInterface() { |
86 return &ppb_filesystem; | 89 return &ppb_filesystem; |
87 } | 90 } |
88 | 91 |
89 } // namespace pepper | 92 } // namespace ppapi |
| 93 } // namespace webkit |
| 94 |
OLD | NEW |