OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2011 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 27 matching lines...) Expand all Loading... |
38 #include "wtf/RefCounted.h" | 38 #include "wtf/RefCounted.h" |
39 | 39 |
40 namespace blink { | 40 namespace blink { |
41 | 41 |
42 class Resource; | 42 class Resource; |
43 class ResourceError; | 43 class ResourceError; |
44 class ResourceFetcher; | 44 class ResourceFetcher; |
45 | 45 |
46 class CORE_EXPORT ResourceLoader final : public GarbageCollectedFinalized<Resour
ceLoader>, protected WebURLLoaderClient { | 46 class CORE_EXPORT ResourceLoader final : public GarbageCollectedFinalized<Resour
ceLoader>, protected WebURLLoaderClient { |
47 public: | 47 public: |
48 static ResourceLoader* create(ResourceFetcher*, Resource*, const ResourceReq
uest&, const ResourceLoaderOptions&); | 48 static ResourceLoader* create(ResourceFetcher*, Resource*); |
49 ~ResourceLoader() override; | 49 ~ResourceLoader() override; |
50 DECLARE_TRACE(); | 50 DECLARE_TRACE(); |
51 | 51 |
52 // Promptly release m_loader. | 52 // Promptly release m_loader. |
53 EAGERLY_FINALIZE(); | 53 EAGERLY_FINALIZE(); |
54 | 54 |
55 void start(); | 55 void start(ResourceRequest&); |
56 void changeToSynchronous(); | |
57 | 56 |
58 void cancel(); | 57 void cancel(); |
59 void cancel(const ResourceError&); | 58 void cancel(const ResourceError&); |
60 void cancelIfNotFinishing(); | 59 void cancelIfNotFinishing(); |
61 | 60 |
62 Resource* cachedResource() { return m_resource.get(); } | 61 Resource* cachedResource() { return m_resource.get(); } |
63 const ResourceRequest& originalRequest() const { return m_originalRequest; } | |
64 | 62 |
65 void setDefersLoading(bool); | 63 void setDefersLoading(bool); |
66 | 64 |
67 void didChangePriority(ResourceLoadPriority, int intraPriorityValue); | 65 void didChangePriority(ResourceLoadPriority, int intraPriorityValue); |
68 | 66 |
69 // WebURLLoaderClient | 67 // WebURLLoaderClient |
70 void willFollowRedirect(WebURLLoader*, WebURLRequest&, const WebURLResponse&
redirectResponse) override; | 68 void willFollowRedirect(WebURLLoader*, WebURLRequest&, const WebURLResponse&
redirectResponse) override; |
71 void didSendData(WebURLLoader*, unsigned long long bytesSent, unsigned long
long totalBytesToBeSent) override; | 69 void didSendData(WebURLLoader*, unsigned long long bytesSent, unsigned long
long totalBytesToBeSent) override; |
72 void didReceiveResponse(WebURLLoader*, const WebURLResponse&) override; | 70 void didReceiveResponse(WebURLLoader*, const WebURLResponse&) override; |
73 void didReceiveResponse(WebURLLoader*, const WebURLResponse&, WebDataConsume
rHandle*) override; | 71 void didReceiveResponse(WebURLLoader*, const WebURLResponse&, WebDataConsume
rHandle*) override; |
74 void didReceiveData(WebURLLoader*, const char*, int, int encodedDataLength)
override; | 72 void didReceiveData(WebURLLoader*, const char*, int, int encodedDataLength)
override; |
75 void didReceiveCachedMetadata(WebURLLoader*, const char* data, int length) o
verride; | 73 void didReceiveCachedMetadata(WebURLLoader*, const char* data, int length) o
verride; |
76 void didFinishLoading(WebURLLoader*, double finishTime, int64_t encodedDataL
ength) override; | 74 void didFinishLoading(WebURLLoader*, double finishTime, int64_t encodedDataL
ength) override; |
77 void didFail(WebURLLoader*, const WebURLError&) override; | 75 void didFail(WebURLLoader*, const WebURLError&) override; |
78 void didDownloadData(WebURLLoader*, int, int) override; | 76 void didDownloadData(WebURLLoader*, int, int) override; |
79 | 77 |
80 bool loadingMultipartContent() const { return m_loadingMultipartContent; } | 78 bool loadingMultipartContent() const { return m_loadingMultipartContent; } |
81 | 79 |
82 private: | 80 private: |
83 // Assumes ResourceFetcher and Resource are non-null. | 81 // Assumes ResourceFetcher and Resource are non-null. |
84 ResourceLoader(ResourceFetcher*, Resource*, const ResourceLoaderOptions&); | 82 ResourceLoader(ResourceFetcher*, Resource*); |
85 | 83 |
86 void init(const ResourceRequest&); | 84 void requestSynchronously(ResourceRequest&); |
87 void requestSynchronously(); | |
88 | 85 |
89 void didFinishLoadingOnePart(double finishTime, int64_t encodedDataLength); | 86 void didFinishLoadingOnePart(double finishTime, int64_t encodedDataLength); |
90 | 87 |
91 bool responseNeedsAccessControlCheck() const; | 88 bool responseNeedsAccessControlCheck() const; |
92 | 89 |
93 ResourceRequest& applyOptions(ResourceRequest&) const; | 90 ResourceRequest& applyOptions(ResourceRequest&) const; |
94 | 91 |
95 void releaseResources(); | 92 void releaseResources(); |
96 | 93 |
97 OwnPtr<WebURLLoader> m_loader; | 94 OwnPtr<WebURLLoader> m_loader; |
98 Member<ResourceFetcher> m_fetcher; | 95 Member<ResourceFetcher> m_fetcher; |
99 | 96 |
100 ResourceRequest m_request; | |
101 ResourceRequest m_originalRequest; // Before redirects. | |
102 | |
103 bool m_notifiedLoadComplete; | 97 bool m_notifiedLoadComplete; |
104 | 98 |
105 bool m_loadingMultipartContent; | 99 bool m_loadingMultipartContent; |
106 ResourceLoaderOptions m_options; | |
107 | 100 |
108 enum ConnectionState { | 101 enum ConnectionState { |
109 ConnectionStateNew, | 102 ConnectionStateNew, |
110 ConnectionStateStarted, | 103 ConnectionStateStarted, |
111 ConnectionStateReceivedResponse, | 104 ConnectionStateReceivedResponse, |
112 ConnectionStateReceivingData, | 105 ConnectionStateReceivingData, |
113 ConnectionStateFinishedLoading, | 106 ConnectionStateFinishedLoading, |
114 ConnectionStateCanceled, | 107 ConnectionStateCanceled, |
115 ConnectionStateFailed, | 108 ConnectionStateFailed, |
116 ConnectionStateReleased | 109 ConnectionStateReleased |
117 }; | 110 }; |
118 bool isFinishing() { return m_state >= ConnectionStateFinishedLoading && m_s
tate <= ConnectionStateFailed; } | 111 bool isFinishing() { return m_state >= ConnectionStateFinishedLoading && m_s
tate <= ConnectionStateFailed; } |
119 | 112 |
120 RefPtrWillBeMember<Resource> m_resource; | 113 RefPtrWillBeMember<Resource> m_resource; |
121 | 114 |
122 // Used for sanity checking to make sure we don't experience illegal state | 115 // Used for sanity checking to make sure we don't experience illegal state |
123 // transitions. | 116 // transitions. |
124 ConnectionState m_state; | 117 ConnectionState m_state; |
125 }; | 118 }; |
126 | 119 |
127 } // namespace blink | 120 } // namespace blink |
128 | 121 |
129 #endif | 122 #endif |
OLD | NEW |