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

Side by Side Diff: Source/core/fetch/Resource.h

Issue 1170503003: Remove resource type-specific fetching logic from ResourceFetcher (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Null-check Document::loader() before calling startPreload() Created 5 years, 6 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 | « Source/core/fetch/RawResource.cpp ('k') | Source/core/fetch/ResourceFetcher.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
3 Copyright (C) 2001 Dirk Mueller <mueller@kde.org> 3 Copyright (C) 2001 Dirk Mueller <mueller@kde.org>
4 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 4 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 }; 78 };
79 79
80 enum Status { 80 enum Status {
81 Unknown, // let cache decide what to do with it 81 Unknown, // let cache decide what to do with it
82 Pending, // only partially loaded 82 Pending, // only partially loaded
83 Cached, // regular case 83 Cached, // regular case
84 LoadError, 84 LoadError,
85 DecodeError 85 DecodeError
86 }; 86 };
87 87
88 // Exposed for testing.
88 Resource(const ResourceRequest&, Type); 89 Resource(const ResourceRequest&, Type);
89 #if ENABLE(OILPAN) 90 #if ENABLE(OILPAN)
90 virtual ~Resource(); 91 virtual ~Resource();
91 #else 92 #else
92 protected: 93 protected:
93 // Only deleteIfPossible should delete this. 94 // Only deleteIfPossible should delete this.
94 virtual ~Resource(); 95 virtual ~Resource();
95 public: 96 public:
96 #endif 97 #endif
97 virtual void dispose(); 98 virtual void dispose();
98 DECLARE_VIRTUAL_TRACE(); 99 DECLARE_VIRTUAL_TRACE();
99 static unsigned instanceCount() { return s_instanceCount; } 100 static unsigned instanceCount() { return s_instanceCount; }
100 101
101 virtual void load(ResourceFetcher*, const ResourceLoaderOptions&); 102 virtual void load(ResourceFetcher*, const ResourceLoaderOptions&);
102 103
103 virtual void setEncoding(const String&) { } 104 virtual void setEncoding(const String&) { }
104 virtual String encoding() const { return String(); } 105 virtual String encoding() const { return String(); }
105 virtual void appendData(const char*, unsigned); 106 virtual void appendData(const char*, unsigned);
106 virtual void error(Resource::Status); 107 virtual void error(Resource::Status);
108 virtual void setCORSFailed() { }
107 109
108 void setNeedsSynchronousCacheHit(bool needsSynchronousCacheHit) { m_needsSyn chronousCacheHit = needsSynchronousCacheHit; } 110 void setNeedsSynchronousCacheHit(bool needsSynchronousCacheHit) { m_needsSyn chronousCacheHit = needsSynchronousCacheHit; }
109 111
110 void setResourceError(const ResourceError& error) { m_error = error; } 112 void setResourceError(const ResourceError& error) { m_error = error; }
111 const ResourceError& resourceError() const { return m_error; } 113 const ResourceError& resourceError() const { return m_error; }
112 114
113 void setIdentifier(unsigned long identifier) { m_identifier = identifier; } 115 void setIdentifier(unsigned long identifier) { m_identifier = identifier; }
114 unsigned long identifier() const { return m_identifier; } 116 unsigned long identifier() const { return m_identifier; }
115 117
116 virtual bool shouldIgnoreHTTPStatusCodeErrors() const { return false; } 118 virtual bool shouldIgnoreHTTPStatusCodeErrors() const { return false; }
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 411
410 // These handles will need to be updated to point to the m_resourceToRevalid ate in case we get 304 response. 412 // These handles will need to be updated to point to the m_resourceToRevalid ate in case we get 304 response.
411 HashSet<ResourcePtrBase*> m_handlesToRevalidate; 413 HashSet<ResourcePtrBase*> m_handlesToRevalidate;
412 414
413 // Ordered list of all redirects followed while fetching this resource. 415 // Ordered list of all redirects followed while fetching this resource.
414 Vector<RedirectPair> m_redirectChain; 416 Vector<RedirectPair> m_redirectChain;
415 417
416 static unsigned s_instanceCount; 418 static unsigned s_instanceCount;
417 }; 419 };
418 420
421 class ResourceFactory {
422 public:
423 virtual Resource* create(const ResourceRequest&, const String&) const = 0;
424 Resource::Type type() const { return m_type; }
425
426 protected:
427 ResourceFactory(Resource::Type type) : m_type(type) { }
428
429 Resource::Type m_type;
430 };
431
419 #if !LOG_DISABLED 432 #if !LOG_DISABLED
420 // Intended to be used in LOG statements. 433 // Intended to be used in LOG statements.
421 const char* ResourceTypeName(Resource::Type); 434 const char* ResourceTypeName(Resource::Type);
422 #endif 435 #endif
423 436
424 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ 437 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \
425 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->type() = = Resource::typeName, resource.type() == Resource::typeName); \ 438 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->type() = = Resource::typeName, resource.type() == Resource::typeName); \
426 inline typeName##Resource* to##typeName##Resource(const ResourcePtr<Resource >& ptr) { return to##typeName##Resource(ptr.get()); } 439 inline typeName##Resource* to##typeName##Resource(const ResourcePtr<Resource >& ptr) { return to##typeName##Resource(ptr.get()); }
427 440
428 } 441 }
429 442
430 #endif 443 #endif
OLDNEW
« no previous file with comments | « Source/core/fetch/RawResource.cpp ('k') | Source/core/fetch/ResourceFetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698