| 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 30 matching lines...) Expand all Loading... |
| 41 class Resource; | 41 class Resource; |
| 42 class ResourceError; | 42 class ResourceError; |
| 43 class ResourceFetcher; | 43 class ResourceFetcher; |
| 44 | 44 |
| 45 class CORE_EXPORT ResourceLoader final : public GarbageCollectedFinalized<Resour
ceLoader>, protected WebURLLoaderClient { | 45 class CORE_EXPORT ResourceLoader final : public GarbageCollectedFinalized<Resour
ceLoader>, protected WebURLLoaderClient { |
| 46 public: | 46 public: |
| 47 static ResourceLoader* create(ResourceFetcher*, Resource*); | 47 static ResourceLoader* create(ResourceFetcher*, Resource*); |
| 48 ~ResourceLoader() override; | 48 ~ResourceLoader() override; |
| 49 DECLARE_TRACE(); | 49 DECLARE_TRACE(); |
| 50 | 50 |
| 51 // Promptly release m_loader. | |
| 52 EAGERLY_FINALIZE(); | |
| 53 | |
| 54 void start(ResourceRequest&); | 51 void start(ResourceRequest&); |
| 55 | |
| 56 void cancel(); | 52 void cancel(); |
| 57 void cancel(const ResourceError&); | |
| 58 | 53 |
| 59 void setDefersLoading(bool); | 54 void setDefersLoading(bool); |
| 60 | 55 |
| 61 void didChangePriority(ResourceLoadPriority, int intraPriorityValue); | 56 void didChangePriority(ResourceLoadPriority, int intraPriorityValue); |
| 62 | 57 |
| 63 // WebURLLoaderClient | 58 // WebURLLoaderClient |
| 59 // |
| 60 // A succesful load will consist of: |
| 61 // 0+ willFollowRedirect() |
| 62 // 0+ didSendData() |
| 63 // 1 didReceiveResponse() |
| 64 // 0-1 didReceiveCachedMetadata() |
| 65 // 0+ didReceiveData() or didDownloadData(), but never both |
| 66 // 1 didFinishLoading() |
| 67 // A failed load is indicated by 1 didFail(), which can occur at any time |
| 68 // before didFinishLoading(), including synchronous inside one of the other |
| 69 // callbacks via ResourceLoader::cancel() |
| 64 void willFollowRedirect(WebURLLoader*, WebURLRequest&, const WebURLResponse&
redirectResponse) override; | 70 void willFollowRedirect(WebURLLoader*, WebURLRequest&, const WebURLResponse&
redirectResponse) override; |
| 65 void didSendData(WebURLLoader*, unsigned long long bytesSent, unsigned long
long totalBytesToBeSent) override; | 71 void didSendData(WebURLLoader*, unsigned long long bytesSent, unsigned long
long totalBytesToBeSent) override; |
| 66 void didReceiveResponse(WebURLLoader*, const WebURLResponse&) override; | 72 void didReceiveResponse(WebURLLoader*, const WebURLResponse&) override; |
| 67 void didReceiveResponse(WebURLLoader*, const WebURLResponse&, WebDataConsume
rHandle*) override; | 73 void didReceiveResponse(WebURLLoader*, const WebURLResponse&, WebDataConsume
rHandle*) override; |
| 74 void didReceiveCachedMetadata(WebURLLoader*, const char* data, int length) o
verride; |
| 68 void didReceiveData(WebURLLoader*, const char*, int, int encodedDataLength)
override; | 75 void didReceiveData(WebURLLoader*, const char*, int, int encodedDataLength)
override; |
| 69 void didReceiveCachedMetadata(WebURLLoader*, const char* data, int length) o
verride; | 76 void didDownloadData(WebURLLoader*, int, int) override; |
| 70 void didFinishLoading(WebURLLoader*, double finishTime, int64_t encodedDataL
ength) override; | 77 void didFinishLoading(WebURLLoader*, double finishTime, int64_t encodedDataL
ength) override; |
| 71 void didFail(WebURLLoader*, const WebURLError&) override; | 78 void didFail(WebURLLoader*, const WebURLError&) override; |
| 72 void didDownloadData(WebURLLoader*, int, int) override; | |
| 73 | 79 |
| 74 void didFinishLoadingOnePart(double finishTime, int64_t encodedDataLength); | 80 void didFinishLoadingFirstPartInMultipart(); |
| 75 | 81 |
| 76 private: | 82 private: |
| 77 // Assumes ResourceFetcher and Resource are non-null. | 83 // Assumes ResourceFetcher and Resource are non-null. |
| 78 ResourceLoader(ResourceFetcher*, Resource*); | 84 ResourceLoader(ResourceFetcher*, Resource*); |
| 79 | 85 |
| 80 void requestSynchronously(ResourceRequest&); | 86 void requestSynchronously(ResourceRequest&); |
| 81 | 87 |
| 82 bool responseNeedsAccessControlCheck() const; | 88 bool responseNeedsAccessControlCheck() const; |
| 83 | 89 |
| 84 ResourceRequest& applyOptions(ResourceRequest&) const; | |
| 85 | |
| 86 void releaseResources(); | |
| 87 | |
| 88 OwnPtr<WebURLLoader> m_loader; | 90 OwnPtr<WebURLLoader> m_loader; |
| 89 Member<ResourceFetcher> m_fetcher; | 91 Member<ResourceFetcher> m_fetcher; |
| 90 | |
| 91 bool m_notifiedLoadComplete; | |
| 92 | |
| 93 enum ConnectionState { | |
| 94 ConnectionStateNew, | |
| 95 ConnectionStateStarted, | |
| 96 ConnectionStateReceivedResponse, | |
| 97 ConnectionStateReceivingData, | |
| 98 ConnectionStateFinishedLoading, | |
| 99 ConnectionStateReleased | |
| 100 }; | |
| 101 | |
| 102 Member<Resource> m_resource; | 92 Member<Resource> m_resource; |
| 103 | |
| 104 // Used for sanity checking to make sure we don't experience illegal state | |
| 105 // transitions. | |
| 106 ConnectionState m_state; | |
| 107 }; | 93 }; |
| 108 | 94 |
| 109 } // namespace blink | 95 } // namespace blink |
| 110 | 96 |
| 111 #endif | 97 #endif |
| OLD | NEW |