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

Side by Side Diff: Source/core/inspector/InspectorFileSystemAgent.cpp

Issue 23537011: FileAPI: Add WebFileSystem::resolveURL (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 3 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
« no previous file with comments | « no previous file | Source/core/platform/AsyncFileSystemCallbacks.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 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 else if (m_type == DOMFileSystemBase::temporaryPathPrefix) 156 else if (m_type == DOMFileSystemBase::temporaryPathPrefix)
157 type = FileSystemTypeTemporary; 157 type = FileSystemTypeTemporary;
158 else { 158 else {
159 errorCallback->handleEvent(FileError::create(FileError::SYNTAX_ERR).get( )); 159 errorCallback->handleEvent(FileError::create(FileError::SYNTAX_ERR).get( ));
160 return; 160 return;
161 } 161 }
162 162
163 RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallb ack>::create(this, &FileSystemRootRequest::didGetEntry); 163 RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallb ack>::create(this, &FileSystemRootRequest::didGetEntry);
164 OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::creat e(successCallback, errorCallback, scriptExecutionContext, type, "/"); 164 OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::creat e(successCallback, errorCallback, scriptExecutionContext, type, "/");
165 165
166 LocalFileSystem::from(scriptExecutionContext)->readFileSystem(scriptExecutio nContext, type, fileSystemCallbacks.release()); 166 // TODO(nhiroki)
167 LocalFileSystem::from(scriptExecutionContext)->readFileSystem(scriptExecutio nContext, KURL(), fileSystemCallbacks.release());
167 } 168 }
168 169
169 bool FileSystemRootRequest::didGetEntry(Entry* entry) 170 bool FileSystemRootRequest::didGetEntry(Entry* entry)
170 { 171 {
171 RefPtr<TypeBuilder::FileSystem::Entry> result = TypeBuilder::FileSystem::Ent ry::create() 172 RefPtr<TypeBuilder::FileSystem::Entry> result = TypeBuilder::FileSystem::Ent ry::create()
172 .setUrl(entry->toURL()) 173 .setUrl(entry->toURL())
173 .setName("/") 174 .setName("/")
174 .setIsDirectory(true); 175 .setIsDirectory(true);
175 reportResult(static_cast<FileError::ErrorCode>(0), result); 176 reportResult(static_cast<FileError::ErrorCode>(0), result);
176 return true; 177 return true;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 FileSystemType type; 227 FileSystemType type;
227 String path; 228 String path;
228 if (!DOMFileSystemBase::crackFileSystemURL(m_url, type, path)) { 229 if (!DOMFileSystemBase::crackFileSystemURL(m_url, type, path)) {
229 errorCallback->handleEvent(FileError::create(FileError::SYNTAX_ERR).get( )); 230 errorCallback->handleEvent(FileError::create(FileError::SYNTAX_ERR).get( ));
230 return; 231 return;
231 } 232 }
232 233
233 RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallb ack>::create(this, &DirectoryContentRequest::didGetEntry); 234 RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallb ack>::create(this, &DirectoryContentRequest::didGetEntry);
234 OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::creat e(successCallback, errorCallback, scriptExecutionContext, type, path); 235 OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::creat e(successCallback, errorCallback, scriptExecutionContext, type, path);
235 236
236 LocalFileSystem::from(scriptExecutionContext)->readFileSystem(scriptExecutio nContext, type, fileSystemCallbacks.release()); 237 LocalFileSystem::from(scriptExecutionContext)->readFileSystem(scriptExecutio nContext, m_url, fileSystemCallbacks.release());
237 } 238 }
238 239
239 bool DirectoryContentRequest::didGetEntry(Entry* entry) 240 bool DirectoryContentRequest::didGetEntry(Entry* entry)
240 { 241 {
241 if (!entry->isDirectory()) { 242 if (!entry->isDirectory()) {
242 reportResult(FileError::TYPE_MISMATCH_ERR); 243 reportResult(FileError::TYPE_MISMATCH_ERR);
243 return true; 244 return true;
244 } 245 }
245 246
246 m_directoryReader = static_cast<DirectoryEntry*>(entry)->createReader(); 247 m_directoryReader = static_cast<DirectoryEntry*>(entry)->createReader();
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 bool m_isDirectory; 344 bool m_isDirectory;
344 }; 345 };
345 346
346 void MetadataRequest::start(ScriptExecutionContext* scriptExecutionContext) 347 void MetadataRequest::start(ScriptExecutionContext* scriptExecutionContext)
347 { 348 {
348 ASSERT(scriptExecutionContext); 349 ASSERT(scriptExecutionContext);
349 350
350 RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallbac k>::create(this, &MetadataRequest::didHitError); 351 RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallbac k>::create(this, &MetadataRequest::didHitError);
351 352
352 FileSystemType type; 353 FileSystemType type;
353 if (!DOMFileSystemBase::crackFileSystemURL(m_url, type, m_path)) { 354 if (!DOMFileSystemBase::crackFileSystemURL(m_url, type, m_path)) {
kinuko 2013/09/05 11:12:11 I guess we can skip this crackFileSystemURL (and p
nhiroki 2013/09/12 05:15:23 Removed.
354 errorCallback->handleEvent(FileError::create(FileError::SYNTAX_ERR).get( )); 355 errorCallback->handleEvent(FileError::create(FileError::SYNTAX_ERR).get( ));
355 return; 356 return;
356 } 357 }
357 358
358 RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallb ack>::create(this, &MetadataRequest::didGetEntry); 359 RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallb ack>::create(this, &MetadataRequest::didGetEntry);
359 OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::creat e(successCallback, errorCallback, scriptExecutionContext, type, m_path); 360 OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::creat e(successCallback, errorCallback, scriptExecutionContext, type, m_path);
kinuko 2013/09/05 11:12:11 Now that we can crack the given URL in the browser
nhiroki 2013/09/12 05:15:23 Done.
360 LocalFileSystem::from(scriptExecutionContext)->readFileSystem(scriptExecutio nContext, type, fileSystemCallbacks.release()); 361 LocalFileSystem::from(scriptExecutionContext)->readFileSystem(scriptExecutio nContext, m_url, fileSystemCallbacks.release());
361 } 362 }
362 363
363 bool MetadataRequest::didGetEntry(Entry* entry) 364 bool MetadataRequest::didGetEntry(Entry* entry)
364 { 365 {
365 if (!entry->filesystem()->scriptExecutionContext()) { 366 if (!entry->filesystem()->scriptExecutionContext()) {
366 reportResult(FileError::ABORT_ERR); 367 reportResult(FileError::ABORT_ERR);
367 return true; 368 return true;
368 } 369 }
369 370
370 RefPtr<MetadataCallback> successCallback = CallbackDispatcherFactory<Metadat aCallback>::create(this, &MetadataRequest::didGetMetadata); 371 RefPtr<MetadataCallback> successCallback = CallbackDispatcherFactory<Metadat aCallback>::create(this, &MetadataRequest::didGetMetadata);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 FileSystemType type; 458 FileSystemType type;
458 String path; 459 String path;
459 if (!DOMFileSystemBase::crackFileSystemURL(m_url, type, path)) { 460 if (!DOMFileSystemBase::crackFileSystemURL(m_url, type, path)) {
460 errorCallback->handleEvent(FileError::create(FileError::SYNTAX_ERR).get( )); 461 errorCallback->handleEvent(FileError::create(FileError::SYNTAX_ERR).get( ));
461 return; 462 return;
462 } 463 }
463 464
464 RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallb ack>::create(this, &FileContentRequest::didGetEntry); 465 RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallb ack>::create(this, &FileContentRequest::didGetEntry);
465 OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::creat e(successCallback, errorCallback, scriptExecutionContext, type, path); 466 OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::creat e(successCallback, errorCallback, scriptExecutionContext, type, path);
466 467
467 LocalFileSystem::from(scriptExecutionContext)->readFileSystem(scriptExecutio nContext, type, fileSystemCallbacks.release()); 468 LocalFileSystem::from(scriptExecutionContext)->readFileSystem(scriptExecutio nContext, m_url, fileSystemCallbacks.release());
468 } 469 }
469 470
470 bool FileContentRequest::didGetEntry(Entry* entry) 471 bool FileContentRequest::didGetEntry(Entry* entry)
471 { 472 {
472 if (entry->isDirectory()) { 473 if (entry->isDirectory()) {
473 reportResult(FileError::TYPE_MISMATCH_ERR); 474 reportResult(FileError::TYPE_MISMATCH_ERR);
474 return true; 475 return true;
475 } 476 }
476 477
477 if (!entry->filesystem()->scriptExecutionContext()) { 478 if (!entry->filesystem()->scriptExecutionContext()) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 errorCallback->handleEvent(FileError::create(FileError::SYNTAX_ERR).get( )); 571 errorCallback->handleEvent(FileError::create(FileError::SYNTAX_ERR).get( ));
571 return; 572 return;
572 } 573 }
573 574
574 if (path == "/") { 575 if (path == "/") {
575 OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = VoidCallbacks::cr eate(this, errorCallback); 576 OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = VoidCallbacks::cr eate(this, errorCallback);
576 LocalFileSystem::from(scriptExecutionContext)->deleteFileSystem(scriptEx ecutionContext, type, fileSystemCallbacks.release()); 577 LocalFileSystem::from(scriptExecutionContext)->deleteFileSystem(scriptEx ecutionContext, type, fileSystemCallbacks.release());
577 } else { 578 } else {
578 RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryC allback>::create(this, &DeleteEntryRequest::didGetEntry); 579 RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryC allback>::create(this, &DeleteEntryRequest::didGetEntry);
579 OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::c reate(successCallback, errorCallback, scriptExecutionContext, type, path); 580 OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::c reate(successCallback, errorCallback, scriptExecutionContext, type, path);
580 LocalFileSystem::from(scriptExecutionContext)->readFileSystem(scriptExec utionContext, type, fileSystemCallbacks.release()); 581 LocalFileSystem::from(scriptExecutionContext)->readFileSystem(scriptExec utionContext, m_url, fileSystemCallbacks.release());
581 } 582 }
582 } 583 }
583 584
584 bool DeleteEntryRequest::didGetEntry(Entry* entry) 585 bool DeleteEntryRequest::didGetEntry(Entry* entry)
585 { 586 {
586 RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallbac k>::create(this, &DeleteEntryRequest::didHitError); 587 RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallbac k>::create(this, &DeleteEntryRequest::didHitError);
587 if (entry->isDirectory()) { 588 if (entry->isDirectory()) {
588 DirectoryEntry* directoryEntry = static_cast<DirectoryEntry*>(entry); 589 DirectoryEntry* directoryEntry = static_cast<DirectoryEntry*>(entry);
589 directoryEntry->removeRecursively(this, errorCallback); 590 directoryEntry->removeRecursively(this, errorCallback);
590 } else 591 } else
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 for (Frame* frame = m_pageAgent->mainFrame(); frame; frame = frame->tree()-> traverseNext()) { 726 for (Frame* frame = m_pageAgent->mainFrame(); frame; frame = frame->tree()-> traverseNext()) {
726 if (frame->document() && frame->document()->securityOrigin()->isSameSche meHostPort(origin)) 727 if (frame->document() && frame->document()->securityOrigin()->isSameSche meHostPort(origin))
727 return frame->document(); 728 return frame->document();
728 } 729 }
729 730
730 *error = "No frame is available for the request"; 731 *error = "No frame is available for the request";
731 return 0; 732 return 0;
732 } 733 }
733 734
734 } // namespace WebCore 735 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/core/platform/AsyncFileSystemCallbacks.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698