~ubuntu-branches/ubuntu/maverick/webkit/maverick

« back to all changes in this revision

Viewing changes to WebCore/loader/DocLoader.h

  • Committer: Bazaar Package Importer
  • Author(s): Mike Hommey
  • Date: 2007-08-19 15:54:12 UTC
  • Revision ID: james.westby@ubuntu.com-20070819155412-uxxg1h9plpghmtbi
Tags: upstream-0~svn25144
ImportĀ upstreamĀ versionĀ 0~svn25144

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
 
3
    Copyright (C) 2001 Dirk Mueller <mueller@kde.org>
 
4
    Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
 
5
 
 
6
    This library is free software; you can redistribute it and/or
 
7
    modify it under the terms of the GNU Library General Public
 
8
    License as published by the Free Software Foundation; either
 
9
    version 2 of the License, or (at your option) any later version.
 
10
 
 
11
    This library is distributed in the hope that it will be useful,
 
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
    Library General Public License for more details.
 
15
 
 
16
    You should have received a copy of the GNU Library General Public License
 
17
    along with this library; see the file COPYING.LIB.  If not, write to
 
18
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
19
    Boston, MA 02111-1307, USA.
 
20
 
 
21
    This class provides all functionality needed for loading images, style sheets and html
 
22
    pages from the web. It has a memory cache for these objects.
 
23
*/
 
24
 
 
25
#ifndef DocLoader_h
 
26
#define DocLoader_h
 
27
 
 
28
#include "CachedResource.h"
 
29
#include "CachePolicy.h"
 
30
#include "StringHash.h"
 
31
#include <wtf/HashMap.h>
 
32
#include <wtf/HashSet.h>
 
33
 
 
34
namespace WebCore {
 
35
 
 
36
class CachedCSSStyleSheet;
 
37
class CachedImage;
 
38
class CachedScript;
 
39
class CachedXSLStyleSheet;
 
40
class Document;
 
41
class Frame;
 
42
class HTMLImageLoader;
 
43
class KURL;
 
44
 
 
45
// The DocLoader manages the loading of scripts/images/stylesheets for a single document.
 
46
class DocLoader
 
47
{
 
48
friend class Cache;
 
49
friend class HTMLImageLoader;
 
50
 
 
51
public:
 
52
    DocLoader(Frame*, Document*);
 
53
    ~DocLoader();
 
54
 
 
55
    CachedImage* requestImage(const String& url);
 
56
    CachedCSSStyleSheet* requestCSSStyleSheet(const String& url, const String& charset, bool isUserStyleSheet = false);
 
57
    CachedCSSStyleSheet* requestUserCSSStyleSheet(const String& url, const String& charset);
 
58
    CachedScript* requestScript(const String& url, const String& charset);
 
59
 
 
60
#if ENABLE(XSLT)
 
61
    CachedXSLStyleSheet* requestXSLStyleSheet(const String& url);
 
62
#endif
 
63
#if ENABLE(XBL)
 
64
    CachedXBLDocument* requestXBLDocument(const String &url);
 
65
#endif
 
66
 
 
67
    CachedResource* cachedResource(const String& url) const { return m_docResources.get(url); }
 
68
    const HashMap<String, CachedResource*>& allCachedResources() const { return m_docResources; }
 
69
 
 
70
    bool autoLoadImages() const { return m_autoLoadImages; }
 
71
    void setAutoLoadImages(bool);
 
72
    
 
73
    CachePolicy cachePolicy() const { return m_cachePolicy; }
 
74
    void setCachePolicy(CachePolicy);
 
75
    
 
76
    Frame* frame() const { return m_frame; }
 
77
    Document* doc() const { return m_doc; }
 
78
 
 
79
    void removeCachedResource(CachedResource*) const;
 
80
 
 
81
    void setLoadInProgress(bool);
 
82
    bool loadInProgress() const { return m_loadInProgress; }
 
83
    
 
84
    void setAllowStaleResources(bool allowStaleResources) { m_allowStaleResources = allowStaleResources; }
 
85
 
 
86
#if USE(LOW_BANDWIDTH_DISPLAY)
 
87
    void replaceDocument(Document* doc) { m_doc = doc; }
 
88
#endif
 
89
 
 
90
    void incrementRequestCount();
 
91
    void decrementRequestCount();
 
92
    int requestCount();
 
93
private:
 
94
    CachedResource* requestResource(CachedResource::Type, const String& url, const String* charset = 0, bool skipCanLoadCheck = false, bool sendResourceLoadCallbacks = true);
 
95
 
 
96
    void checkForReload(const KURL&);
 
97
    void checkCacheObjectStatus(CachedResource*);
 
98
    
 
99
    Cache* m_cache;
 
100
    HashSet<String> m_reloadedURLs;
 
101
    mutable HashMap<String, CachedResource*> m_docResources;
 
102
    CachePolicy m_cachePolicy;
 
103
    Frame* m_frame;
 
104
    Document *m_doc;
 
105
    
 
106
    int m_requestCount;
 
107
    
 
108
    //29 bits left
 
109
    bool m_autoLoadImages : 1;
 
110
    bool m_loadInProgress : 1;
 
111
    bool m_allowStaleResources : 1;
 
112
};
 
113
 
 
114
}
 
115
 
 
116
#endif