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/web/WebDOMFileSystem.cpp

Issue 2297043002: Web expose FileSystemFileEntry, FileSystemDirectoryEntry and friends (Closed)
Patch Set: Rebased Created 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 "public/web/WebDOMFileSystem.h" 31 #include "public/web/WebDOMFileSystem.h"
32 32
33 #include "bindings/core/v8/WrapperTypeInfo.h" 33 #include "bindings/core/v8/WrapperTypeInfo.h"
34 #include "bindings/modules/v8/V8DOMFileSystem.h" 34 #include "bindings/modules/v8/V8FileSystem.h"
35 #include "bindings/modules/v8/V8DirectoryEntry.h" 35 #include "bindings/modules/v8/V8FileSystemEntry.h"
36 #include "bindings/modules/v8/V8FileEntry.h"
37 #include "core/dom/Document.h" 36 #include "core/dom/Document.h"
38 #include "modules/filesystem/DOMFileSystem.h" 37 #include "modules/filesystem/FileSystem.h"
39 #include "modules/filesystem/DirectoryEntry.h" 38 #include "modules/filesystem/FileSystemDirectoryEntry.h"
40 #include "modules/filesystem/FileEntry.h" 39 #include "modules/filesystem/FileSystemFileEntry.h"
41 #include "web/WebLocalFrameImpl.h" 40 #include "web/WebLocalFrameImpl.h"
42 #include <v8.h> 41 #include <v8.h>
43 42
44 namespace blink { 43 namespace blink {
45 44
46 WebDOMFileSystem WebDOMFileSystem::fromV8Value(v8::Local<v8::Value> value) { 45 WebDOMFileSystem WebDOMFileSystem::fromV8Value(v8::Local<v8::Value> value) {
47 if (!V8DOMFileSystem::hasInstance(value, v8::Isolate::GetCurrent())) 46 if (!V8FileSystem::hasInstance(value, v8::Isolate::GetCurrent()))
48 return WebDOMFileSystem(); 47 return WebDOMFileSystem();
49 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value); 48 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value);
50 DOMFileSystem* domFileSystem = V8DOMFileSystem::toImpl(object); 49 FileSystem* fileSystem = V8FileSystem::toImpl(object);
51 DCHECK(domFileSystem); 50 DCHECK(fileSystem);
52 return WebDOMFileSystem(domFileSystem); 51 return WebDOMFileSystem(fileSystem);
53 } 52 }
54 53
55 WebURL WebDOMFileSystem::createFileSystemURL(v8::Local<v8::Value> value) { 54 WebURL WebDOMFileSystem::createFileSystemURL(v8::Local<v8::Value> value) {
56 const Entry* const entry = 55 const FileSystemEntry* const entry =
57 V8Entry::toImplWithTypeCheck(v8::Isolate::GetCurrent(), value); 56 V8FileSystemEntry::toImplWithTypeCheck(v8::Isolate::GetCurrent(), value);
58 if (entry) 57 if (entry)
59 return entry->filesystem()->createFileSystemURL(entry); 58 return entry->filesystem()->createFileSystemURL(entry);
60 return WebURL(); 59 return WebURL();
61 } 60 }
62 61
63 WebDOMFileSystem WebDOMFileSystem::create(WebLocalFrame* frame, 62 WebDOMFileSystem WebDOMFileSystem::create(WebLocalFrame* frame,
64 WebFileSystemType type, 63 WebFileSystemType type,
65 const WebString& name, 64 const WebString& name,
66 const WebURL& rootURL, 65 const WebURL& rootURL,
67 SerializableType serializableType) { 66 SerializableType serializableType) {
68 DCHECK(frame); 67 DCHECK(frame);
69 DCHECK(toWebLocalFrameImpl(frame)->frame()); 68 DCHECK(toWebLocalFrameImpl(frame)->frame());
70 DOMFileSystem* domFileSystem = 69 FileSystem* fileSystem =
71 DOMFileSystem::create(toWebLocalFrameImpl(frame)->frame()->document(), 70 FileSystem::create(toWebLocalFrameImpl(frame)->frame()->document(), name,
72 name, static_cast<FileSystemType>(type), rootURL); 71 static_cast<FileSystemType>(type), rootURL);
73 if (serializableType == SerializableTypeSerializable) 72 if (serializableType == SerializableTypeSerializable)
74 domFileSystem->makeClonable(); 73 fileSystem->makeClonable();
75 return WebDOMFileSystem(domFileSystem); 74 return WebDOMFileSystem(fileSystem);
76 } 75 }
77 76
78 void WebDOMFileSystem::reset() { 77 void WebDOMFileSystem::reset() {
79 m_private.reset(); 78 m_private.reset();
80 } 79 }
81 80
82 void WebDOMFileSystem::assign(const WebDOMFileSystem& other) { 81 void WebDOMFileSystem::assign(const WebDOMFileSystem& other) {
83 m_private = other.m_private; 82 m_private = other.m_private;
84 } 83 }
85 84
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 const WebString& path, 124 const WebString& path,
126 EntryType entryType, 125 EntryType entryType,
127 v8::Local<v8::Object> creationContext, 126 v8::Local<v8::Object> creationContext,
128 v8::Isolate* isolate) { 127 v8::Isolate* isolate) {
129 // We no longer use |creationContext| because it's often misused and points 128 // We no longer use |creationContext| because it's often misused and points
130 // to a context faked by user script. 129 // to a context faked by user script.
131 DCHECK(creationContext->CreationContext() == isolate->GetCurrentContext()); 130 DCHECK(creationContext->CreationContext() == isolate->GetCurrentContext());
132 if (!m_private.get()) 131 if (!m_private.get())
133 return v8::Local<v8::Value>(); 132 return v8::Local<v8::Value>();
134 if (entryType == EntryTypeDirectory) 133 if (entryType == EntryTypeDirectory)
135 return toV8(DirectoryEntry::create(m_private.get(), path), 134 return toV8(FileSystemDirectoryEntry::create(m_private.get(), path),
136 isolate->GetCurrentContext()->Global(), isolate); 135 isolate->GetCurrentContext()->Global(), isolate);
137 DCHECK_EQ(entryType, EntryTypeFile); 136 DCHECK_EQ(entryType, EntryTypeFile);
138 return toV8(FileEntry::create(m_private.get(), path), 137 return toV8(FileSystemFileEntry::create(m_private.get(), path),
139 isolate->GetCurrentContext()->Global(), isolate); 138 isolate->GetCurrentContext()->Global(), isolate);
140 } 139 }
141 140
142 WebDOMFileSystem::WebDOMFileSystem(DOMFileSystem* domFileSystem) 141 WebDOMFileSystem::WebDOMFileSystem(FileSystem* fileSystem)
143 : m_private(domFileSystem) {} 142 : m_private(fileSystem) {}
144 143
145 WebDOMFileSystem& WebDOMFileSystem::operator=(DOMFileSystem* domFileSystem) { 144 WebDOMFileSystem& WebDOMFileSystem::operator=(FileSystem* fileSystem) {
146 m_private = domFileSystem; 145 m_private = fileSystem;
147 return *this; 146 return *this;
148 } 147 }
149 148
150 } // namespace blink 149 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/modules_idl_files.gni ('k') | third_party/WebKit/public/web/WebDOMFileSystem.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698