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

Side by Side Diff: third_party/WebKit/Source/modules/filesystem/HTMLInputElementFileSystem.cpp

Issue 2815313002: Reland of Move ScriptState::GetExecutionContext (Part 5) (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "modules/filesystem/HTMLInputElementFileSystem.h" 31 #include "modules/filesystem/HTMLInputElementFileSystem.h"
32 32
33 #include "bindings/core/v8/ScriptState.h" 33 #include "bindings/core/v8/ScriptState.h"
34 #include "core/dom/ExecutionContext.h"
34 #include "core/fileapi/FileList.h" 35 #include "core/fileapi/FileList.h"
35 #include "core/html/HTMLInputElement.h" 36 #include "core/html/HTMLInputElement.h"
36 #include "modules/filesystem/DOMFilePath.h" 37 #include "modules/filesystem/DOMFilePath.h"
37 #include "modules/filesystem/DOMFileSystem.h" 38 #include "modules/filesystem/DOMFileSystem.h"
38 #include "modules/filesystem/DirectoryEntry.h" 39 #include "modules/filesystem/DirectoryEntry.h"
39 #include "modules/filesystem/Entry.h" 40 #include "modules/filesystem/Entry.h"
40 #include "modules/filesystem/FileEntry.h" 41 #include "modules/filesystem/FileEntry.h"
41 #include "platform/FileMetadata.h" 42 #include "platform/FileMetadata.h"
42 #include "platform/heap/Handle.h" 43 #include "platform/heap/Handle.h"
43 44
44 namespace blink { 45 namespace blink {
45 46
46 // static 47 // static
47 EntryHeapVector HTMLInputElementFileSystem::webkitEntries( 48 EntryHeapVector HTMLInputElementFileSystem::webkitEntries(
48 ScriptState* script_state, 49 ScriptState* script_state,
49 HTMLInputElement& input) { 50 HTMLInputElement& input) {
50 EntryHeapVector entries; 51 EntryHeapVector entries;
51 FileList* files = input.files(); 52 FileList* files = input.files();
52 53
53 if (!files) 54 if (!files)
54 return entries; 55 return entries;
55 56
56 DOMFileSystem* filesystem = DOMFileSystem::CreateIsolatedFileSystem( 57 DOMFileSystem* filesystem = DOMFileSystem::CreateIsolatedFileSystem(
57 script_state->GetExecutionContext(), input.DroppedFileSystemId()); 58 ExecutionContext::From(script_state), input.DroppedFileSystemId());
58 if (!filesystem) { 59 if (!filesystem) {
59 // Drag-drop isolated filesystem is not available. 60 // Drag-drop isolated filesystem is not available.
60 return entries; 61 return entries;
61 } 62 }
62 63
63 for (unsigned i = 0; i < files->length(); ++i) { 64 for (unsigned i = 0; i < files->length(); ++i) {
64 File* file = files->item(i); 65 File* file = files->item(i);
65 66
66 // FIXME: This involves synchronous file operation. 67 // FIXME: This involves synchronous file operation.
67 FileMetadata metadata; 68 FileMetadata metadata;
68 if (!GetFileMetadata(file->GetPath(), metadata)) 69 if (!GetFileMetadata(file->GetPath(), metadata))
69 continue; 70 continue;
70 71
71 // The dropped entries are mapped as top-level entries in the isolated 72 // The dropped entries are mapped as top-level entries in the isolated
72 // filesystem. 73 // filesystem.
73 String virtual_path = DOMFilePath::Append("/", file->name()); 74 String virtual_path = DOMFilePath::Append("/", file->name());
74 if (metadata.type == FileMetadata::kTypeDirectory) 75 if (metadata.type == FileMetadata::kTypeDirectory)
75 entries.push_back(DirectoryEntry::Create(filesystem, virtual_path)); 76 entries.push_back(DirectoryEntry::Create(filesystem, virtual_path));
76 else 77 else
77 entries.push_back(FileEntry::Create(filesystem, virtual_path)); 78 entries.push_back(FileEntry::Create(filesystem, virtual_path));
78 } 79 }
79 return entries; 80 return entries;
80 } 81 }
81 82
82 } // namespace blink 83 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/filesystem/Entry.cpp ('k') | third_party/WebKit/Source/modules/indexeddb/IDBFactory.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698