1/*
2 * Copyright (C) 2013 Research In Motion Limited. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
17 */
18
19#include "config.h"
20#include "BlobStream.h"
21
22#include "ResourceHandle.h"
23
24using BlackBerry::Platform::FilterStream;
25
26namespace WebCore {
27
28BlobStream::BlobStream(const ResourceResponse& response, ResourceHandle* handle)
29    : FilterStream()
30    , m_response(response)
31{
32    registerStreamId();
33    handle->setClient(this);
34}
35
36BlobStream::~BlobStream()
37{
38}
39
40void BlobStream::didReceiveData(ResourceHandle*, const char* data, int len, int)
41{
42    notifyDataReceived(BlackBerry::Platform::createNetworkBufferByWrappingData(data, len));
43}
44
45void BlobStream::didFinishLoading(ResourceHandle*, double)
46{
47    notifyClose(FilterStream::StatusSuccess);
48}
49
50void BlobStream::didFail(ResourceHandle*, const ResourceError&)
51{
52    notifyClose(FilterStream::StatusErrorIO);
53}
54
55BlackBerry::Platform::String BlobStream::url() const
56{
57    return m_response.url().string();
58}
59
60const BlackBerry::Platform::String BlobStream::mimeType() const
61{
62    return m_response.mimeType();
63}
64
65} // namespace WebCore
66