This source file includes following definitions.
- fromV8Value
- create
- reset
- assign
- name
- type
- rootURL
- toV8Value
- createV8Entry
#include "config.h"
#include "WebDOMFileSystem.h"
#include "V8DOMFileSystem.h"
#include "V8DirectoryEntry.h"
#include "V8FileEntry.h"
#include "WebFrameImpl.h"
#include "bindings/v8/WrapperTypeInfo.h"
#include "core/dom/Document.h"
#include "modules/filesystem/DOMFileSystem.h"
#include "modules/filesystem/DirectoryEntry.h"
#include "modules/filesystem/FileEntry.h"
#include <v8.h>
using namespace WebCore;
namespace blink {
WebDOMFileSystem WebDOMFileSystem::fromV8Value(v8::Handle<v8::Value> value)
{
if (!V8DOMFileSystem::hasInstance(value, v8::Isolate::GetCurrent()))
return WebDOMFileSystem();
v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value);
DOMFileSystem* domFileSystem = V8DOMFileSystem::toNative(object);
ASSERT(domFileSystem);
return WebDOMFileSystem(domFileSystem);
}
WebDOMFileSystem WebDOMFileSystem::create(
WebLocalFrame* frame,
WebFileSystemType type,
const WebString& name,
const WebURL& rootURL,
SerializableType serializableType)
{
ASSERT(frame && toWebFrameImpl(frame)->frame());
RefPtrWillBeRawPtr<DOMFileSystem> domFileSystem = DOMFileSystem::create(toWebFrameImpl(frame)->frame()->document(), name, static_cast<WebCore::FileSystemType>(type), rootURL);
if (serializableType == SerializableTypeSerializable)
domFileSystem->makeClonable();
return WebDOMFileSystem(domFileSystem);
}
void WebDOMFileSystem::reset()
{
m_private.reset();
}
void WebDOMFileSystem::assign(const WebDOMFileSystem& other)
{
m_private = other.m_private;
}
WebString WebDOMFileSystem::name() const
{
ASSERT(m_private.get());
return m_private->name();
}
WebFileSystem::Type WebDOMFileSystem::type() const
{
ASSERT(m_private.get());
switch (m_private->type()) {
case FileSystemTypeTemporary:
return WebFileSystem::TypeTemporary;
case FileSystemTypePersistent:
return WebFileSystem::TypePersistent;
case FileSystemTypeIsolated:
return WebFileSystem::TypeIsolated;
case FileSystemTypeExternal:
return WebFileSystem::TypeExternal;
default:
ASSERT_NOT_REACHED();
return WebFileSystem::TypeTemporary;
}
}
WebURL WebDOMFileSystem::rootURL() const
{
ASSERT(m_private.get());
return m_private->rootURL();
}
v8::Handle<v8::Value> WebDOMFileSystem::toV8Value()
{
if (!m_private.get())
return v8::Handle<v8::Value>();
return toV8(m_private.get(), v8::Handle<v8::Object>(), toIsolate(m_private->executionContext()));
}
v8::Handle<v8::Value> WebDOMFileSystem::createV8Entry(
const WebString& path,
EntryType entryType)
{
if (!m_private.get())
return v8::Handle<v8::Value>();
if (entryType == EntryTypeDirectory)
return toV8(DirectoryEntry::create(m_private.get(), path), v8::Handle<v8::Object>(), toIsolate(m_private->executionContext()));
ASSERT(entryType == EntryTypeFile);
return toV8(FileEntry::create(m_private.get(), path), v8::Handle<v8::Object>(), toIsolate(m_private->executionContext()));
}
WebDOMFileSystem::WebDOMFileSystem(const PassRefPtrWillBeRawPtr<DOMFileSystem>& domFileSystem)
: m_private(domFileSystem)
{
}
WebDOMFileSystem& WebDOMFileSystem::operator=(const PassRefPtrWillBeRawPtr<WebCore::DOMFileSystem>& domFileSystem)
{
m_private = domFileSystem;
return *this;
}
}