Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Side by Side Diff: webkit/pending/CachedScript.cpp

Issue 6500: Cleaning up the unfork (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/pending/CachedResource.h ('k') | webkit/pending/CanvasRenderingContext2D.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 This file is part of the KDE libraries
3
4 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
5 Copyright (C) 2001 Dirk Mueller (mueller@kde.org)
6 Copyright (C) 2002 Waldo Bastian (bastian@kde.org)
7 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
8 Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
9
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Library General Public
12 License as published by the Free Software Foundation; either
13 version 2 of the License, or (at your option) any later version.
14
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Library General Public License for more details.
19
20 You should have received a copy of the GNU Library General Public License
21 along with this library; see the file COPYING.LIB. If not, write to
22 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 Boston, MA 02110-1301, USA.
24
25 This class provides all functionality needed for loading images, style sheet s and html
26 pages from the web. It has a memory cache for these objects.
27 */
28
29 #include "config.h"
30 #include "CachedScript.h"
31
32 #include "CachedResourceClient.h"
33 #include "CachedResourceClientWalker.h"
34 #include <wtf/Vector.h>
35
36 namespace WebCore {
37
38 CachedScript::CachedScript(const String& url, const String& charset)
39 : CachedResource(url, Script)
40 , m_encoding(charset)
41 {
42 // It's javascript we want.
43 // But some websites think their scripts are <some wrong mimetype here>
44 // and refuse to serve them if we only accept application/x-javascript.
45 setAccept("*/*");
46 if (!m_encoding.isValid())
47 m_encoding = Latin1Encoding();
48 }
49
50 CachedScript::~CachedScript()
51 {
52 }
53
54 void CachedScript::addClient(CachedResourceClient* c)
55 {
56 CachedResource::addClient(c);
57 if (!m_loading)
58 c->notifyFinished(this);
59 }
60
61 void CachedScript::setEncoding(const String& chs)
62 {
63 TextEncoding encoding(chs);
64 if (encoding.isValid())
65 m_encoding = encoding;
66 }
67
68 String CachedScript::encoding() const
69 {
70 return m_encoding.name();
71 }
72
73 void CachedScript::data(PassRefPtr<SharedBuffer> data, bool allDataReceived)
74 {
75 if (!allDataReceived)
76 return;
77
78 m_data = data;
79 setEncodedSize(m_data.get() ? m_data->size() : 0);
80 if (m_data.get()) {
81 m_script = m_encoding.decode(m_data->data(), encodedSize());
82 m_data = 0; // We no longer need the raw buffer.
83 }
84 m_loading = false;
85 checkNotify();
86 }
87
88 void CachedScript::checkNotify()
89 {
90 if (m_loading)
91 return;
92
93 CachedResourceClientWalker w(m_clients);
94 while (CachedResourceClient* c = w.next())
95 c->notifyFinished(this);
96 }
97
98 void CachedScript::error()
99 {
100 m_loading = false;
101 m_errorOccurred = true;
102 checkNotify();
103 }
104
105 }
OLDNEW
« no previous file with comments | « webkit/pending/CachedResource.h ('k') | webkit/pending/CanvasRenderingContext2D.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698