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 plugins { |
| 25 namespace ppapi { |
24 | 26 |
25 namespace { | 27 namespace { |
26 | 28 |
27 PP_Resource Create(PP_Instance instance, PP_FileSystemType_Dev type) { | 29 PP_Resource Create(PP_Instance instance, PP_FileSystemType_Dev type) { |
28 PluginInstance* plugin_instance = | 30 PluginInstance* plugin_instance = |
29 ResourceTracker::Get()->GetInstance(instance); | 31 ResourceTracker::Get()->GetInstance(instance); |
30 if (!plugin_instance) | 32 if (!plugin_instance) |
31 return 0; | 33 return 0; |
32 | 34 |
33 FileSystem* file_system = new FileSystem(plugin_instance, type); | 35 PPB_FileSystem_Impl* file_system = |
| 36 new PPB_FileSystem_Impl(plugin_instance, type); |
34 return file_system->GetReference(); | 37 return file_system->GetReference(); |
35 } | 38 } |
36 | 39 |
37 int32_t Open(PP_Resource file_system_id, | 40 int32_t Open(PP_Resource file_system_id, |
38 int64 expected_size, | 41 int64 expected_size, |
39 PP_CompletionCallback callback) { | 42 PP_CompletionCallback callback) { |
40 scoped_refptr<FileSystem> file_system( | 43 scoped_refptr<PPB_FileSystem_Impl> file_system( |
41 Resource::GetAs<FileSystem>(file_system_id)); | 44 Resource::GetAs<PPB_FileSystem_Impl>(file_system_id)); |
42 if (!file_system) | 45 if (!file_system) |
43 return PP_ERROR_BADRESOURCE; | 46 return PP_ERROR_BADRESOURCE; |
44 | 47 |
45 if (file_system->opened()) | 48 if (file_system->opened()) |
46 return PP_OK; | 49 return PP_OK; |
47 | 50 |
48 if ((file_system->type() != PP_FILESYSTEMTYPE_LOCALPERSISTENT) && | 51 if ((file_system->type() != PP_FILESYSTEMTYPE_LOCALPERSISTENT) && |
49 (file_system->type() != PP_FILESYSTEMTYPE_LOCALTEMPORARY)) | 52 (file_system->type() != PP_FILESYSTEMTYPE_LOCALTEMPORARY)) |
50 return PP_ERROR_FAILED; | 53 return PP_ERROR_FAILED; |
51 | 54 |
(...skipping 12 matching lines...) Expand all Loading... |
64 return PP_ERROR_WOULDBLOCK; | 67 return PP_ERROR_WOULDBLOCK; |
65 } | 68 } |
66 | 69 |
67 const PPB_FileSystem_Dev ppb_filesystem = { | 70 const PPB_FileSystem_Dev ppb_filesystem = { |
68 &Create, | 71 &Create, |
69 &Open | 72 &Open |
70 }; | 73 }; |
71 | 74 |
72 } // namespace | 75 } // namespace |
73 | 76 |
74 FileSystem::FileSystem(PluginInstance* instance, PP_FileSystemType_Dev type) | 77 PPB_FileSystem_Impl::PPB_FileSystem_Impl(PluginInstance* instance, |
| 78 PP_FileSystemType_Dev type) |
75 : Resource(instance->module()), | 79 : Resource(instance->module()), |
76 instance_(instance), | 80 instance_(instance), |
77 type_(type), | 81 type_(type), |
78 opened_(false) { | 82 opened_(false) { |
79 } | 83 } |
80 | 84 |
81 FileSystem* FileSystem::AsFileSystem() { | 85 PPB_FileSystem_Impl* PPB_FileSystem_Impl::AsFileSystem() { |
82 return this; | 86 return this; |
83 } | 87 } |
84 | 88 |
85 const PPB_FileSystem_Dev* FileSystem::GetInterface() { | 89 const PPB_FileSystem_Dev* PPB_FileSystem_Impl::GetInterface() { |
86 return &ppb_filesystem; | 90 return &ppb_filesystem; |
87 } | 91 } |
88 | 92 |
89 } // namespace pepper | 93 } // namespace ppapi |
| 94 } // namespace plugins |
| 95 } // namespace webkit |
| 96 |
OLD | NEW |