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

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

Issue 5828003: Move the Pepper implementation from webkit/glue/plugins/pepper_* to... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years 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_ref_impl.h ('k') | webkit/plugins/ppapi/ppb_file_system_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) 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_ref.h" 5 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "ppapi/c/pp_errors.h" 9 #include "ppapi/c/pp_errors.h"
10 #include "webkit/glue/plugins/pepper_common.h" 10 #include "webkit/plugins/ppapi/common.h"
11 #include "webkit/glue/plugins/pepper_directory_reader.h" 11 #include "webkit/plugins/ppapi/file_callbacks.h"
12 #include "webkit/glue/plugins/pepper_file_callbacks.h" 12 #include "webkit/plugins/ppapi/plugin_delegate.h"
13 #include "webkit/glue/plugins/pepper_file_system.h" 13 #include "webkit/plugins/ppapi/plugin_instance.h"
14 #include "webkit/glue/plugins/pepper_plugin_delegate.h" 14 #include "webkit/plugins/ppapi/plugin_module.h"
15 #include "webkit/glue/plugins/pepper_plugin_instance.h" 15 #include "webkit/plugins/ppapi/ppb_directory_reader_impl.h"
16 #include "webkit/glue/plugins/pepper_plugin_module.h" 16 #include "webkit/plugins/ppapi/ppb_file_system_impl.h"
17 #include "webkit/glue/plugins/pepper_var.h" 17 #include "webkit/plugins/ppapi/var.h"
18 18
19 namespace pepper { 19 namespace webkit {
20 namespace ppapi {
20 21
21 namespace { 22 namespace {
22 23
23 bool IsValidLocalPath(const std::string& path) { 24 bool IsValidLocalPath(const std::string& path) {
24 // The path must start with '/' 25 // The path must start with '/'
25 if (path.empty() || path[0] != '/') 26 if (path.empty() || path[0] != '/')
26 return false; 27 return false;
27 28
28 // The path must contain valid UTF-8 characters. 29 // The path must contain valid UTF-8 characters.
29 if (!IsStringUTF8(path)) 30 if (!IsStringUTF8(path))
30 return false; 31 return false;
31 32
32 return true; 33 return true;
33 } 34 }
34 35
35 void TrimTrailingSlash(std::string* path) { 36 void TrimTrailingSlash(std::string* path) {
36 // If this path ends with a slash, then normalize it away unless path is the 37 // If this path ends with a slash, then normalize it away unless path is the
37 // root path. 38 // root path.
38 if (path->size() > 1 && path->at(path->size() - 1) == '/') 39 if (path->size() > 1 && path->at(path->size() - 1) == '/')
39 path->erase(path->size() - 1, 1); 40 path->erase(path->size() - 1, 1);
40 } 41 }
41 42
42 PP_Resource Create(PP_Resource file_system_id, const char* path) { 43 PP_Resource Create(PP_Resource file_system_id, const char* path) {
43 scoped_refptr<FileSystem> file_system( 44 scoped_refptr<PPB_FileSystem_Impl> file_system(
44 Resource::GetAs<FileSystem>(file_system_id)); 45 Resource::GetAs<PPB_FileSystem_Impl>(file_system_id));
45 if (!file_system) 46 if (!file_system)
46 return 0; 47 return 0;
47 48
48 if (!file_system->instance()) 49 if (!file_system->instance())
49 return 0; 50 return 0;
50 51
51 std::string validated_path(path); 52 std::string validated_path(path);
52 if (!IsValidLocalPath(validated_path)) 53 if (!IsValidLocalPath(validated_path))
53 return 0; 54 return 0;
54 TrimTrailingSlash(&validated_path); 55 TrimTrailingSlash(&validated_path);
55 56
56 FileRef* file_ref = new FileRef(file_system->instance()->module(), 57 PPB_FileRef_Impl* file_ref =
57 file_system, 58 new PPB_FileRef_Impl(file_system->instance()->module(),
58 validated_path); 59 file_system, validated_path);
59 return file_ref->GetReference(); 60 return file_ref->GetReference();
60 } 61 }
61 62
62 PP_Bool IsFileRef(PP_Resource resource) { 63 PP_Bool IsFileRef(PP_Resource resource) {
63 return BoolToPPBool(!!Resource::GetAs<FileRef>(resource)); 64 return BoolToPPBool(!!Resource::GetAs<PPB_FileRef_Impl>(resource));
64 } 65 }
65 66
66 PP_FileSystemType_Dev GetFileSystemType(PP_Resource file_ref_id) { 67 PP_FileSystemType_Dev GetFileSystemType(PP_Resource file_ref_id) {
67 scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id)); 68 scoped_refptr<PPB_FileRef_Impl> file_ref(
69 Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
68 if (!file_ref) 70 if (!file_ref)
69 return PP_FILESYSTEMTYPE_EXTERNAL; 71 return PP_FILESYSTEMTYPE_EXTERNAL;
70 return file_ref->GetFileSystemType(); 72 return file_ref->GetFileSystemType();
71 } 73 }
72 74
73 PP_Var GetName(PP_Resource file_ref_id) { 75 PP_Var GetName(PP_Resource file_ref_id) {
74 scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id)); 76 scoped_refptr<PPB_FileRef_Impl> file_ref(
77 Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
75 if (!file_ref) 78 if (!file_ref)
76 return PP_MakeUndefined(); 79 return PP_MakeUndefined();
77 return StringVar::StringToPPVar(file_ref->module(), file_ref->GetName()); 80 return StringVar::StringToPPVar(file_ref->module(), file_ref->GetName());
78 } 81 }
79 82
80 PP_Var GetPath(PP_Resource file_ref_id) { 83 PP_Var GetPath(PP_Resource file_ref_id) {
81 scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id)); 84 scoped_refptr<PPB_FileRef_Impl> file_ref(
85 Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
82 if (!file_ref) 86 if (!file_ref)
83 return PP_MakeUndefined(); 87 return PP_MakeUndefined();
84 88
85 if (file_ref->GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL) 89 if (file_ref->GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL)
86 return PP_MakeUndefined(); 90 return PP_MakeUndefined();
87 91
88 return StringVar::StringToPPVar(file_ref->module(), file_ref->GetPath()); 92 return StringVar::StringToPPVar(file_ref->module(), file_ref->GetPath());
89 } 93 }
90 94
91 PP_Resource GetParent(PP_Resource file_ref_id) { 95 PP_Resource GetParent(PP_Resource file_ref_id) {
92 scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id)); 96 scoped_refptr<PPB_FileRef_Impl> file_ref(
97 Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
93 if (!file_ref) 98 if (!file_ref)
94 return 0; 99 return 0;
95 100
96 if (file_ref->GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL) 101 if (file_ref->GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL)
97 return 0; 102 return 0;
98 103
99 scoped_refptr<FileRef> parent_ref(file_ref->GetParent()); 104 scoped_refptr<PPB_FileRef_Impl> parent_ref(file_ref->GetParent());
100 if (!parent_ref) 105 if (!parent_ref)
101 return 0; 106 return 0;
102 107
103 return parent_ref->GetReference(); 108 return parent_ref->GetReference();
104 } 109 }
105 110
106 int32_t MakeDirectory(PP_Resource directory_ref_id, 111 int32_t MakeDirectory(PP_Resource directory_ref_id,
107 PP_Bool make_ancestors, 112 PP_Bool make_ancestors,
108 PP_CompletionCallback callback) { 113 PP_CompletionCallback callback) {
109 scoped_refptr<FileRef> directory_ref( 114 scoped_refptr<PPB_FileRef_Impl> directory_ref(
110 Resource::GetAs<FileRef>(directory_ref_id)); 115 Resource::GetAs<PPB_FileRef_Impl>(directory_ref_id));
111 if (!directory_ref) 116 if (!directory_ref)
112 return PP_ERROR_BADRESOURCE; 117 return PP_ERROR_BADRESOURCE;
113 118
114 scoped_refptr<FileSystem> file_system = directory_ref->GetFileSystem(); 119 scoped_refptr<PPB_FileSystem_Impl> file_system = directory_ref->GetFileSystem( );
115 if (!file_system || !file_system->opened() || 120 if (!file_system || !file_system->opened() ||
116 (file_system->type() == PP_FILESYSTEMTYPE_EXTERNAL)) 121 (file_system->type() == PP_FILESYSTEMTYPE_EXTERNAL))
117 return PP_ERROR_NOACCESS; 122 return PP_ERROR_NOACCESS;
118 123
119 PluginInstance* instance = file_system->instance(); 124 PluginInstance* instance = file_system->instance();
120 if (!instance->delegate()->MakeDirectory( 125 if (!instance->delegate()->MakeDirectory(
121 directory_ref->GetSystemPath(), PPBoolToBool(make_ancestors), 126 directory_ref->GetSystemPath(), PPBoolToBool(make_ancestors),
122 new FileCallbacks(instance->module()->AsWeakPtr(), 127 new FileCallbacks(instance->module()->AsWeakPtr(),
123 callback, NULL, NULL, NULL))) 128 callback, NULL, NULL, NULL)))
124 return PP_ERROR_FAILED; 129 return PP_ERROR_FAILED;
125 130
126 return PP_ERROR_WOULDBLOCK; 131 return PP_ERROR_WOULDBLOCK;
127 } 132 }
128 133
129 int32_t Query(PP_Resource file_ref_id, 134 int32_t Query(PP_Resource file_ref_id,
130 PP_FileInfo_Dev* info, 135 PP_FileInfo_Dev* info,
131 PP_CompletionCallback callback) { 136 PP_CompletionCallback callback) {
132 scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id)); 137 scoped_refptr<PPB_FileRef_Impl> file_ref(
138 Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
133 if (!file_ref) 139 if (!file_ref)
134 return PP_ERROR_BADRESOURCE; 140 return PP_ERROR_BADRESOURCE;
135 141
136 scoped_refptr<FileSystem> file_system = file_ref->GetFileSystem(); 142 scoped_refptr<PPB_FileSystem_Impl> file_system = file_ref->GetFileSystem();
137 if (!file_system || !file_system->opened() || 143 if (!file_system || !file_system->opened() ||
138 (file_system->type() == PP_FILESYSTEMTYPE_EXTERNAL)) 144 (file_system->type() == PP_FILESYSTEMTYPE_EXTERNAL))
139 return PP_ERROR_NOACCESS; 145 return PP_ERROR_NOACCESS;
140 146
141 PluginInstance* instance = file_system->instance(); 147 PluginInstance* instance = file_system->instance();
142 if (!instance->delegate()->Query( 148 if (!instance->delegate()->Query(
143 file_ref->GetSystemPath(), 149 file_ref->GetSystemPath(),
144 new FileCallbacks(instance->module()->AsWeakPtr(), 150 new FileCallbacks(instance->module()->AsWeakPtr(),
145 callback, info, file_system, NULL))) 151 callback, info, file_system, NULL)))
146 return PP_ERROR_FAILED; 152 return PP_ERROR_FAILED;
147 153
148 return PP_ERROR_WOULDBLOCK; 154 return PP_ERROR_WOULDBLOCK;
149 } 155 }
150 156
151 int32_t Touch(PP_Resource file_ref_id, 157 int32_t Touch(PP_Resource file_ref_id,
152 PP_Time last_access_time, 158 PP_Time last_access_time,
153 PP_Time last_modified_time, 159 PP_Time last_modified_time,
154 PP_CompletionCallback callback) { 160 PP_CompletionCallback callback) {
155 scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id)); 161 scoped_refptr<PPB_FileRef_Impl> file_ref(
162 Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
156 if (!file_ref) 163 if (!file_ref)
157 return PP_ERROR_BADRESOURCE; 164 return PP_ERROR_BADRESOURCE;
158 165
159 scoped_refptr<FileSystem> file_system = file_ref->GetFileSystem(); 166 scoped_refptr<PPB_FileSystem_Impl> file_system = file_ref->GetFileSystem();
160 if (!file_system || !file_system->opened() || 167 if (!file_system || !file_system->opened() ||
161 (file_system->type() == PP_FILESYSTEMTYPE_EXTERNAL)) 168 (file_system->type() == PP_FILESYSTEMTYPE_EXTERNAL))
162 return PP_ERROR_NOACCESS; 169 return PP_ERROR_NOACCESS;
163 170
164 PluginInstance* instance = file_system->instance(); 171 PluginInstance* instance = file_system->instance();
165 if (!instance->delegate()->Touch( 172 if (!instance->delegate()->Touch(
166 file_ref->GetSystemPath(), base::Time::FromDoubleT(last_access_time), 173 file_ref->GetSystemPath(), base::Time::FromDoubleT(last_access_time),
167 base::Time::FromDoubleT(last_modified_time), 174 base::Time::FromDoubleT(last_modified_time),
168 new FileCallbacks(instance->module()->AsWeakPtr(), 175 new FileCallbacks(instance->module()->AsWeakPtr(),
169 callback, NULL, NULL, NULL))) 176 callback, NULL, NULL, NULL)))
170 return PP_ERROR_FAILED; 177 return PP_ERROR_FAILED;
171 178
172 return PP_ERROR_WOULDBLOCK; 179 return PP_ERROR_WOULDBLOCK;
173 } 180 }
174 181
175 int32_t Delete(PP_Resource file_ref_id, 182 int32_t Delete(PP_Resource file_ref_id,
176 PP_CompletionCallback callback) { 183 PP_CompletionCallback callback) {
177 scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id)); 184 scoped_refptr<PPB_FileRef_Impl> file_ref(
185 Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
178 if (!file_ref) 186 if (!file_ref)
179 return PP_ERROR_BADRESOURCE; 187 return PP_ERROR_BADRESOURCE;
180 188
181 scoped_refptr<FileSystem> file_system = file_ref->GetFileSystem(); 189 scoped_refptr<PPB_FileSystem_Impl> file_system = file_ref->GetFileSystem();
182 if (!file_system || !file_system->opened() || 190 if (!file_system || !file_system->opened() ||
183 (file_system->type() == PP_FILESYSTEMTYPE_EXTERNAL)) 191 (file_system->type() == PP_FILESYSTEMTYPE_EXTERNAL))
184 return PP_ERROR_NOACCESS; 192 return PP_ERROR_NOACCESS;
185 193
186 PluginInstance* instance = file_system->instance(); 194 PluginInstance* instance = file_system->instance();
187 if (!instance->delegate()->Delete( 195 if (!instance->delegate()->Delete(
188 file_ref->GetSystemPath(), 196 file_ref->GetSystemPath(),
189 new FileCallbacks(instance->module()->AsWeakPtr(), 197 new FileCallbacks(instance->module()->AsWeakPtr(),
190 callback, NULL, NULL, NULL))) 198 callback, NULL, NULL, NULL)))
191 return PP_ERROR_FAILED; 199 return PP_ERROR_FAILED;
192 200
193 return PP_ERROR_WOULDBLOCK; 201 return PP_ERROR_WOULDBLOCK;
194 } 202 }
195 203
196 int32_t Rename(PP_Resource file_ref_id, 204 int32_t Rename(PP_Resource file_ref_id,
197 PP_Resource new_file_ref_id, 205 PP_Resource new_file_ref_id,
198 PP_CompletionCallback callback) { 206 PP_CompletionCallback callback) {
199 scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id)); 207 scoped_refptr<PPB_FileRef_Impl> file_ref(
208 Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
200 if (!file_ref) 209 if (!file_ref)
201 return PP_ERROR_BADRESOURCE; 210 return PP_ERROR_BADRESOURCE;
202 211
203 scoped_refptr<FileRef> new_file_ref( 212 scoped_refptr<PPB_FileRef_Impl> new_file_ref(
204 Resource::GetAs<FileRef>(new_file_ref_id)); 213 Resource::GetAs<PPB_FileRef_Impl>(new_file_ref_id));
205 if (!new_file_ref) 214 if (!new_file_ref)
206 return PP_ERROR_BADRESOURCE; 215 return PP_ERROR_BADRESOURCE;
207 216
208 scoped_refptr<FileSystem> file_system = file_ref->GetFileSystem(); 217 scoped_refptr<PPB_FileSystem_Impl> file_system = file_ref->GetFileSystem();
209 if (!file_system || !file_system->opened() || 218 if (!file_system || !file_system->opened() ||
210 (file_system != new_file_ref->GetFileSystem()) || 219 (file_system != new_file_ref->GetFileSystem()) ||
211 (file_system->type() == PP_FILESYSTEMTYPE_EXTERNAL)) 220 (file_system->type() == PP_FILESYSTEMTYPE_EXTERNAL))
212 return PP_ERROR_NOACCESS; 221 return PP_ERROR_NOACCESS;
213 222
214 PluginInstance* instance = file_system->instance(); 223 PluginInstance* instance = file_system->instance();
215 if (!instance->delegate()->Rename( 224 if (!instance->delegate()->Rename(
216 file_ref->GetSystemPath(), new_file_ref->GetSystemPath(), 225 file_ref->GetSystemPath(), new_file_ref->GetSystemPath(),
217 new FileCallbacks(instance->module()->AsWeakPtr(), 226 new FileCallbacks(instance->module()->AsWeakPtr(),
218 callback, NULL, NULL, NULL))) 227 callback, NULL, NULL, NULL)))
(...skipping 11 matching lines...) Expand all
230 &GetParent, 239 &GetParent,
231 &MakeDirectory, 240 &MakeDirectory,
232 &Query, 241 &Query,
233 &Touch, 242 &Touch,
234 &Delete, 243 &Delete,
235 &Rename 244 &Rename
236 }; 245 };
237 246
238 } // namespace 247 } // namespace
239 248
240 FileRef::FileRef() 249 PPB_FileRef_Impl::PPB_FileRef_Impl()
241 : Resource(NULL), 250 : Resource(NULL),
242 file_system_(NULL) { 251 file_system_(NULL) {
243 } 252 }
244 253
245 FileRef::FileRef(PluginModule* module, 254 PPB_FileRef_Impl::PPB_FileRef_Impl(PluginModule* module,
246 scoped_refptr<FileSystem> file_system, 255 scoped_refptr<PPB_FileSystem_Impl> file_system,
247 const std::string& validated_path) 256 const std::string& validated_path)
248 : Resource(module), 257 : Resource(module),
249 file_system_(file_system), 258 file_system_(file_system),
250 virtual_path_(validated_path) { 259 virtual_path_(validated_path) {
251 } 260 }
252 261
253 FileRef::FileRef(PluginModule* module, 262 PPB_FileRef_Impl::PPB_FileRef_Impl(PluginModule* module,
254 const FilePath& external_file_path) 263 const FilePath& external_file_path)
255 : Resource(module), 264 : Resource(module),
256 file_system_(NULL), 265 file_system_(NULL),
257 system_path_(external_file_path) { 266 system_path_(external_file_path) {
258 } 267 }
259 268
260 FileRef::~FileRef() { 269 PPB_FileRef_Impl::~PPB_FileRef_Impl() {
261 } 270 }
262 271
263 // static 272 // static
264 const PPB_FileRef_Dev* FileRef::GetInterface() { 273 const PPB_FileRef_Dev* PPB_FileRef_Impl::GetInterface() {
265 return &ppb_fileref; 274 return &ppb_fileref;
266 } 275 }
267 276
268 FileRef* FileRef::AsFileRef() { 277 PPB_FileRef_Impl* PPB_FileRef_Impl::AsPPB_FileRef_Impl() {
269 return this; 278 return this;
270 } 279 }
271 280
272 std::string FileRef::GetName() const { 281 std::string PPB_FileRef_Impl::GetName() const {
273 if (GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL) { 282 if (GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL) {
274 FilePath::StringType path = system_path_.value(); 283 FilePath::StringType path = system_path_.value();
275 size_t pos = path.rfind(FilePath::kSeparators[0]); 284 size_t pos = path.rfind(FilePath::kSeparators[0]);
276 DCHECK(pos != FilePath::StringType::npos); 285 DCHECK(pos != FilePath::StringType::npos);
277 #if defined(OS_WIN) 286 #if defined(OS_WIN)
278 return WideToUTF8(path.substr(pos + 1)); 287 return WideToUTF8(path.substr(pos + 1));
279 #elif defined(OS_POSIX) 288 #elif defined(OS_POSIX)
280 return path.substr(pos + 1); 289 return path.substr(pos + 1);
281 #else 290 #else
282 #error "Unsupported platform." 291 #error "Unsupported platform."
283 #endif 292 #endif
284 } 293 }
285 294
286 if (virtual_path_.size() == 1 && virtual_path_[0] == '/') 295 if (virtual_path_.size() == 1 && virtual_path_[0] == '/')
287 return virtual_path_; 296 return virtual_path_;
288 297
289 // There should always be a leading slash at least! 298 // There should always be a leading slash at least!
290 size_t pos = virtual_path_.rfind('/'); 299 size_t pos = virtual_path_.rfind('/');
291 DCHECK(pos != std::string::npos); 300 DCHECK(pos != std::string::npos);
292 301
293 return virtual_path_.substr(pos + 1); 302 return virtual_path_.substr(pos + 1);
294 } 303 }
295 304
296 scoped_refptr<FileRef> FileRef::GetParent() { 305 scoped_refptr<PPB_FileRef_Impl> PPB_FileRef_Impl::GetParent() {
297 if (GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL) 306 if (GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL)
298 return new FileRef(); 307 return new PPB_FileRef_Impl();
299 308
300 // There should always be a leading slash at least! 309 // There should always be a leading slash at least!
301 size_t pos = virtual_path_.rfind('/'); 310 size_t pos = virtual_path_.rfind('/');
302 DCHECK(pos != std::string::npos); 311 DCHECK(pos != std::string::npos);
303 312
304 // If the path is "/foo", then we want to include the slash. 313 // If the path is "/foo", then we want to include the slash.
305 if (pos == 0) 314 if (pos == 0)
306 pos++; 315 pos++;
307 std::string parent_path = virtual_path_.substr(0, pos); 316 std::string parent_path = virtual_path_.substr(0, pos);
308 317
309 FileRef* parent_ref = new FileRef(module(), file_system_, parent_path); 318 PPB_FileRef_Impl* parent_ref = new PPB_FileRef_Impl(module(), file_system_,
319 parent_path);
310 return parent_ref; 320 return parent_ref;
311 } 321 }
312 322
313 scoped_refptr<FileSystem> FileRef::GetFileSystem() const { 323 scoped_refptr<PPB_FileSystem_Impl> PPB_FileRef_Impl::GetFileSystem() const {
314 return file_system_; 324 return file_system_;
315 } 325 }
316 326
317 PP_FileSystemType_Dev FileRef::GetFileSystemType() const { 327 PP_FileSystemType_Dev PPB_FileRef_Impl::GetFileSystemType() const {
318 if (!file_system_) 328 if (!file_system_)
319 return PP_FILESYSTEMTYPE_EXTERNAL; 329 return PP_FILESYSTEMTYPE_EXTERNAL;
320 330
321 return file_system_->type(); 331 return file_system_->type();
322 } 332 }
323 333
324 std::string FileRef::GetPath() const { 334 std::string PPB_FileRef_Impl::GetPath() const {
325 return virtual_path_; 335 return virtual_path_;
326 } 336 }
327 337
328 FilePath FileRef::GetSystemPath() const { 338 FilePath PPB_FileRef_Impl::GetSystemPath() const {
329 if (GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL) 339 if (GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL)
330 return system_path_; 340 return system_path_;
331 341
332 // Since |virtual_path_| starts with a '/', it is considered an absolute path 342 // Since |virtual_path_| starts with a '/', it is considered an absolute path
333 // on POSIX systems. We need to remove the '/' before calling Append() or we 343 // on POSIX systems. We need to remove the '/' before calling Append() or we
334 // will run into a DCHECK. 344 // will run into a DCHECK.
335 FilePath virtual_file_path( 345 FilePath virtual_file_path(
336 #if defined(OS_WIN) 346 #if defined(OS_WIN)
337 UTF8ToWide(virtual_path_.substr(1)) 347 UTF8ToWide(virtual_path_.substr(1))
338 #elif defined(OS_POSIX) 348 #elif defined(OS_POSIX)
339 virtual_path_.substr(1) 349 virtual_path_.substr(1)
340 #else 350 #else
341 #error "Unsupported platform." 351 #error "Unsupported platform."
342 #endif 352 #endif
343 ); 353 );
344 return file_system_->root_path().Append(virtual_file_path); 354 return file_system_->root_path().Append(virtual_file_path);
345 } 355 }
346 356
347 } // namespace pepper 357 } // namespace ppapi
358 } // namespace webkit
359
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppb_file_ref_impl.h ('k') | webkit/plugins/ppapi/ppb_file_system_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698