2
* Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
3
* Copyright (C) 2009 Jan Michael Alonzo
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
9
* 1. Redistributions of source code must retain the above copyright
10
* notice, this list of conditions and the following disclaimer.
11
* 2. Redistributions in binary form must reproduce the above copyright
12
* notice, this list of conditions and the following disclaimer in the
13
* documentation and/or other materials provided with the distribution.
14
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
15
* its contributors may be used to endorse or promote products derived
16
* from this software without specific prior written permission.
18
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
#include "DocumentLoaderGtk.h"
33
#include "webkitwebdatasource.h"
34
#include "webkitwebdatasourceprivate.h"
35
#include <wtf/gobject/GRefPtr.h>
37
using namespace WebCore;
41
DocumentLoader::DocumentLoader(const ResourceRequest& request, const SubstituteData& substituteData)
42
: WebCore::DocumentLoader(request, substituteData)
43
, m_isDataSourceReffed(false)
48
void DocumentLoader::setDataSource(WebKitWebDataSource* dataSource)
50
ASSERT(!m_dataSource);
52
m_dataSource = dataSource;
56
void DocumentLoader::detachDataSource()
61
void DocumentLoader::attachToFrame()
63
WebCore::DocumentLoader::attachToFrame();
70
// We may get to here without having a datasource, when the data
71
// is coming from the page cache.
72
GRefPtr<WebKitWebDataSource> dataSource(adoptGRef(kitNew(this)));
73
setDataSource(dataSource.get());
76
void DocumentLoader::detachFromFrame()
78
WebCore::DocumentLoader::detachFromFrame();
80
if (m_loadingResources.isEmpty())
84
void DocumentLoader::increaseLoadCount(unsigned long identifier)
88
if (m_loadingResources.contains(identifier))
90
m_loadingResources.add(identifier);
94
void DocumentLoader::decreaseLoadCount(unsigned long identifier)
96
HashSet<unsigned long>::iterator it = m_loadingResources.find(identifier);
98
// It is valid for a load to be cancelled before it's started.
99
if (it == m_loadingResources.end())
102
m_loadingResources.remove(it);
104
if (m_loadingResources.isEmpty() && !frame())
108
// helper methos to avoid ref count churn
109
void DocumentLoader::refDataSource()
111
if (!m_dataSource || m_isDataSourceReffed)
113
m_isDataSourceReffed = true;
114
g_object_ref(m_dataSource);
116
void DocumentLoader::unrefDataSource()
118
if (!m_isDataSourceReffed)
120
ASSERT(m_dataSource);
121
m_isDataSourceReffed = false;
122
g_object_unref(m_dataSource);
126
} // end namespace WebKit