Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Side by Side Diff: webkit/plugins/ppapi/ppb_file_system_impl.cc

Issue 7006022: Revert 87415 - Convert more interfaces to the new thunk system. This goes up to and including (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/plugins/ppapi/ppb_file_system_impl.h ('k') | webkit/plugins/ppapi/ppb_find_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/plugins/ppapi/ppb_file_system_impl.h" 5 #include "webkit/plugins/ppapi/ppb_file_system_impl.h"
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/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/Source/WebKit/chromium/public/WebDocument.h" 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h"
14 #include "webkit/fileapi/file_system_types.h" 14 #include "webkit/fileapi/file_system_types.h"
15 #include "webkit/plugins/ppapi/common.h" 15 #include "webkit/plugins/ppapi/common.h"
16 #include "webkit/plugins/ppapi/file_callbacks.h" 16 #include "webkit/plugins/ppapi/file_callbacks.h"
17 #include "webkit/plugins/ppapi/plugin_delegate.h" 17 #include "webkit/plugins/ppapi/plugin_delegate.h"
18 #include "webkit/plugins/ppapi/plugin_module.h" 18 #include "webkit/plugins/ppapi/plugin_module.h"
19 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 19 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
20 #include "webkit/plugins/ppapi/ppb_directory_reader_impl.h" 20 #include "webkit/plugins/ppapi/ppb_directory_reader_impl.h"
21 #include "webkit/plugins/ppapi/resource.h" 21 #include "webkit/plugins/ppapi/resource.h"
22 #include "webkit/plugins/ppapi/resource_tracker.h" 22 #include "webkit/plugins/ppapi/resource_tracker.h"
23 23
24 using ppapi::thunk::PPB_FileSystem_API;
25
26 namespace webkit { 24 namespace webkit {
27 namespace ppapi { 25 namespace ppapi {
28 26
29 PPB_FileSystem_Impl::PPB_FileSystem_Impl(PluginInstance* instance, 27 namespace {
30 PP_FileSystemType_Dev type)
31 : Resource(instance),
32 instance_(instance),
33 type_(type),
34 opened_(false),
35 called_open_(false) {
36 DCHECK(type_ != PP_FILESYSTEMTYPE_INVALID);
37 }
38 28
39 PPB_FileSystem_Impl::~PPB_FileSystem_Impl() { 29 PP_Resource Create(PP_Instance instance, PP_FileSystemType_Dev type) {
40 }
41
42 // static
43 PP_Resource PPB_FileSystem_Impl::Create(PP_Instance instance,
44 PP_FileSystemType_Dev type) {
45 PluginInstance* plugin_instance = 30 PluginInstance* plugin_instance =
46 ResourceTracker::Get()->GetInstance(instance); 31 ResourceTracker::Get()->GetInstance(instance);
47 if (!plugin_instance) 32 if (!plugin_instance)
48 return 0; 33 return 0;
49 34
50 if (type != PP_FILESYSTEMTYPE_EXTERNAL && 35 if (type != PP_FILESYSTEMTYPE_EXTERNAL &&
51 type != PP_FILESYSTEMTYPE_LOCALPERSISTENT && 36 type != PP_FILESYSTEMTYPE_LOCALPERSISTENT &&
52 type != PP_FILESYSTEMTYPE_LOCALTEMPORARY) 37 type != PP_FILESYSTEMTYPE_LOCALTEMPORARY)
53 return 0; 38 return 0;
54 39
55 PPB_FileSystem_Impl* file_system = 40 PPB_FileSystem_Impl* file_system =
56 new PPB_FileSystem_Impl(plugin_instance, type); 41 new PPB_FileSystem_Impl(plugin_instance, type);
57 return file_system->GetReference(); 42 return file_system->GetReference();
58 } 43 }
59 44
60 PPB_FileSystem_API* PPB_FileSystem_Impl::AsPPB_FileSystem_API() { 45 PP_Bool IsFileSystem(PP_Resource resource) {
46 scoped_refptr<PPB_FileSystem_Impl> file_system(
47 Resource::GetAs<PPB_FileSystem_Impl>(resource));
48 return BoolToPPBool(!!file_system.get());
49 }
50
51 int32_t Open(PP_Resource file_system_id,
52 int64 expected_size,
53 PP_CompletionCallback callback) {
54 scoped_refptr<PPB_FileSystem_Impl> file_system(
55 Resource::GetAs<PPB_FileSystem_Impl>(file_system_id));
56 if (!file_system)
57 return PP_ERROR_BADRESOURCE;
58
59 // Should not allow multiple opens.
60 if (file_system->called_open())
61 return PP_ERROR_FAILED;
62 file_system->set_called_open();
63
64 if ((file_system->type() != PP_FILESYSTEMTYPE_LOCALPERSISTENT) &&
65 (file_system->type() != PP_FILESYSTEMTYPE_LOCALTEMPORARY))
66 return PP_ERROR_FAILED;
67
68 PluginInstance* instance = file_system->instance();
69 fileapi::FileSystemType file_system_type =
70 (file_system->type() == PP_FILESYSTEMTYPE_LOCALTEMPORARY ?
71 fileapi::kFileSystemTypeTemporary :
72 fileapi::kFileSystemTypePersistent);
73 if (!instance->delegate()->OpenFileSystem(
74 instance->container()->element().document().frame()->url(),
75 file_system_type, expected_size,
76 new FileCallbacks(instance->module()->AsWeakPtr(), file_system_id,
77 callback, NULL, file_system, NULL)))
78 return PP_ERROR_FAILED;
79
80 return PP_OK_COMPLETIONPENDING;
81 }
82
83 PP_FileSystemType_Dev GetType(PP_Resource resource) {
84 scoped_refptr<PPB_FileSystem_Impl> file_system(
85 Resource::GetAs<PPB_FileSystem_Impl>(resource));
86 if (!file_system)
87 return PP_FILESYSTEMTYPE_INVALID;
88 return file_system->type();
89 }
90
91 const PPB_FileSystem_Dev ppb_filesystem = {
92 &Create,
93 &IsFileSystem,
94 &Open,
95 &GetType
96 };
97
98 } // namespace
99
100 PPB_FileSystem_Impl::PPB_FileSystem_Impl(PluginInstance* instance,
101 PP_FileSystemType_Dev type)
102 : Resource(instance),
103 instance_(instance),
104 type_(type),
105 opened_(false),
106 called_open_(false) {
107 DCHECK(type_ != PP_FILESYSTEMTYPE_INVALID);
108 }
109
110 PPB_FileSystem_Impl* PPB_FileSystem_Impl::AsPPB_FileSystem_Impl() {
61 return this; 111 return this;
62 } 112 }
63 113
64 int32_t PPB_FileSystem_Impl::Open(int64_t expected_size, 114 const PPB_FileSystem_Dev* PPB_FileSystem_Impl::GetInterface() {
65 PP_CompletionCallback callback) { 115 return &ppb_filesystem;
66 // Should not allow multiple opens.
67 if (called_open_)
68 return PP_ERROR_FAILED;
69 called_open_ = true;
70
71 if (type_ != PP_FILESYSTEMTYPE_LOCALPERSISTENT &&
72 type_ != PP_FILESYSTEMTYPE_LOCALTEMPORARY)
73 return PP_ERROR_FAILED;
74
75 fileapi::FileSystemType file_system_type =
76 (type_ == PP_FILESYSTEMTYPE_LOCALTEMPORARY ?
77 fileapi::kFileSystemTypeTemporary :
78 fileapi::kFileSystemTypePersistent);
79 if (!instance()->delegate()->OpenFileSystem(
80 instance()->container()->element().document().frame()->url(),
81 file_system_type, expected_size,
82 new FileCallbacks(instance()->module()->AsWeakPtr(),
83 GetReferenceNoAddRef(),
84 callback, NULL,
85 scoped_refptr<PPB_FileSystem_Impl>(this), NULL)))
86 return PP_ERROR_FAILED;
87 return PP_OK_COMPLETIONPENDING;
88 }
89
90 PP_FileSystemType_Dev PPB_FileSystem_Impl::GetType() {
91 return type_;
92 } 116 }
93 117
94 } // namespace ppapi 118 } // namespace ppapi
95 } // namespace webkit 119 } // namespace webkit
96 120
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppb_file_system_impl.h ('k') | webkit/plugins/ppapi/ppb_find_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698