OLD | NEW |
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 24 matching lines...) Expand all Loading... |
35 #include "bindings/modules/v8/V8DOMFileSystem.h" | 35 #include "bindings/modules/v8/V8DOMFileSystem.h" |
36 #include "bindings/modules/v8/V8DirectoryEntry.h" | 36 #include "bindings/modules/v8/V8DirectoryEntry.h" |
37 #include "bindings/modules/v8/V8FileEntry.h" | 37 #include "bindings/modules/v8/V8FileEntry.h" |
38 #include "core/dom/Document.h" | 38 #include "core/dom/Document.h" |
39 #include "modules/filesystem/DOMFileSystem.h" | 39 #include "modules/filesystem/DOMFileSystem.h" |
40 #include "modules/filesystem/DirectoryEntry.h" | 40 #include "modules/filesystem/DirectoryEntry.h" |
41 #include "modules/filesystem/FileEntry.h" | 41 #include "modules/filesystem/FileEntry.h" |
42 #include "web/WebLocalFrameImpl.h" | 42 #include "web/WebLocalFrameImpl.h" |
43 #include <v8.h> | 43 #include <v8.h> |
44 | 44 |
45 using namespace blink; | |
46 | |
47 namespace blink { | 45 namespace blink { |
48 | 46 |
49 WebDOMFileSystem WebDOMFileSystem::fromV8Value(v8::Handle<v8::Value> value) | 47 WebDOMFileSystem WebDOMFileSystem::fromV8Value(v8::Handle<v8::Value> value) |
50 { | 48 { |
51 if (!V8DOMFileSystem::hasInstance(value, v8::Isolate::GetCurrent())) | 49 if (!V8DOMFileSystem::hasInstance(value, v8::Isolate::GetCurrent())) |
52 return WebDOMFileSystem(); | 50 return WebDOMFileSystem(); |
53 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value); | 51 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value); |
54 DOMFileSystem* domFileSystem = V8DOMFileSystem::toNative(object); | 52 DOMFileSystem* domFileSystem = V8DOMFileSystem::toNative(object); |
55 ASSERT(domFileSystem); | 53 ASSERT(domFileSystem); |
56 return WebDOMFileSystem(domFileSystem); | 54 return WebDOMFileSystem(domFileSystem); |
57 } | 55 } |
58 | 56 |
59 WebURL WebDOMFileSystem::createFileSystemURL(v8::Handle<v8::Value> value) | 57 WebURL WebDOMFileSystem::createFileSystemURL(v8::Handle<v8::Value> value) |
60 { | 58 { |
61 const FileEntry* const entry = V8FileEntry::toNativeWithTypeCheck(v8::Isolat
e::GetCurrent(), value); | 59 const FileEntry* const entry = V8FileEntry::toNativeWithTypeCheck(v8::Isolat
e::GetCurrent(), value); |
62 if (entry) | 60 if (entry) |
63 return entry->filesystem()->createFileSystemURL(entry); | 61 return entry->filesystem()->createFileSystemURL(entry); |
64 return WebURL(); | 62 return WebURL(); |
65 } | 63 } |
66 | 64 |
67 WebDOMFileSystem WebDOMFileSystem::create( | 65 WebDOMFileSystem WebDOMFileSystem::create( |
68 WebLocalFrame* frame, | 66 WebLocalFrame* frame, |
69 WebFileSystemType type, | 67 WebFileSystemType type, |
70 const WebString& name, | 68 const WebString& name, |
71 const WebURL& rootURL, | 69 const WebURL& rootURL, |
72 SerializableType serializableType) | 70 SerializableType serializableType) |
73 { | 71 { |
74 ASSERT(frame && toWebLocalFrameImpl(frame)->frame()); | 72 ASSERT(frame && toWebLocalFrameImpl(frame)->frame()); |
75 DOMFileSystem* domFileSystem = DOMFileSystem::create(toWebLocalFrameImpl(fra
me)->frame()->document(), name, static_cast<blink::FileSystemType>(type), rootUR
L); | 73 DOMFileSystem* domFileSystem = DOMFileSystem::create(toWebLocalFrameImpl(fra
me)->frame()->document(), name, static_cast<FileSystemType>(type), rootURL); |
76 if (serializableType == SerializableTypeSerializable) | 74 if (serializableType == SerializableTypeSerializable) |
77 domFileSystem->makeClonable(); | 75 domFileSystem->makeClonable(); |
78 return WebDOMFileSystem(domFileSystem); | 76 return WebDOMFileSystem(domFileSystem); |
79 } | 77 } |
80 | 78 |
81 void WebDOMFileSystem::reset() | 79 void WebDOMFileSystem::reset() |
82 { | 80 { |
83 m_private.reset(); | 81 m_private.reset(); |
84 } | 82 } |
85 | 83 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 return toV8(DirectoryEntry::create(m_private.get(), path), creationConte
xt, isolate); | 135 return toV8(DirectoryEntry::create(m_private.get(), path), creationConte
xt, isolate); |
138 ASSERT(entryType == EntryTypeFile); | 136 ASSERT(entryType == EntryTypeFile); |
139 return toV8(FileEntry::create(m_private.get(), path), creationContext, isola
te); | 137 return toV8(FileEntry::create(m_private.get(), path), creationContext, isola
te); |
140 } | 138 } |
141 | 139 |
142 WebDOMFileSystem::WebDOMFileSystem(DOMFileSystem* domFileSystem) | 140 WebDOMFileSystem::WebDOMFileSystem(DOMFileSystem* domFileSystem) |
143 : m_private(domFileSystem) | 141 : m_private(domFileSystem) |
144 { | 142 { |
145 } | 143 } |
146 | 144 |
147 WebDOMFileSystem& WebDOMFileSystem::operator=(blink::DOMFileSystem* domFileSyste
m) | 145 WebDOMFileSystem& WebDOMFileSystem::operator=(DOMFileSystem* domFileSystem) |
148 { | 146 { |
149 m_private = domFileSystem; | 147 m_private = domFileSystem; |
150 return *this; | 148 return *this; |
151 } | 149 } |
152 | 150 |
153 } // namespace blink | 151 } // namespace blink |
OLD | NEW |