This source file includes following definitions.
- createFromFile
- fromV8Value
- reset
- assign
- uuid
- toV8Value
#include "config.h"
#include "WebBlob.h"
#include "V8Blob.h"
#include "bindings/v8/V8Binding.h"
#include "core/fileapi/Blob.h"
#include "platform/blob/BlobData.h"
#include "wtf/PassOwnPtr.h"
using namespace WebCore;
namespace blink {
WebBlob WebBlob::createFromFile(const WebString& path, long long size)
{
OwnPtr<BlobData> blobData = BlobData::create();
blobData->appendFile(path);
RefPtrWillBeRawPtr<Blob> blob = Blob::create(BlobDataHandle::create(blobData.release(), size));
return WebBlob(blob);
}
WebBlob WebBlob::fromV8Value(v8::Handle<v8::Value> value)
{
if (V8Blob::hasInstance(value, v8::Isolate::GetCurrent())) {
v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value);
Blob* blob = V8Blob::toNative(object);
ASSERT(blob);
return WebBlob(blob);
}
return WebBlob();
}
void WebBlob::reset()
{
m_private.reset();
}
void WebBlob::assign(const WebBlob& other)
{
m_private = other.m_private;
}
WebString WebBlob::uuid()
{
if (!m_private.get())
return WebString();
return m_private->uuid();
}
v8::Handle<v8::Value> WebBlob::toV8Value()
{
if (!m_private.get())
return v8::Handle<v8::Value>();
return toV8(m_private.get(), v8::Handle<v8::Object>(), v8::Isolate::GetCurrent());
}
WebBlob::WebBlob(const PassRefPtrWillBeRawPtr<WebCore::Blob>& blob)
: m_private(blob)
{
}
WebBlob& WebBlob::operator=(const PassRefPtrWillBeRawPtr<WebCore::Blob>& blob)
{
m_private = blob;
return *this;
}
}