| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2013, Intel Corporation | 3 * Copyright (C) 2013, Intel Corporation |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 #include "core/CoreExport.h" | 35 #include "core/CoreExport.h" |
| 36 #include "core/fetch/RawResource.h" | 36 #include "core/fetch/RawResource.h" |
| 37 #include "core/fetch/ResourceOwner.h" | 37 #include "core/fetch/ResourceOwner.h" |
| 38 #include "core/loader/ThreadableLoader.h" | 38 #include "core/loader/ThreadableLoader.h" |
| 39 #include "platform/Timer.h" | 39 #include "platform/Timer.h" |
| 40 #include "platform/heap/Handle.h" | 40 #include "platform/heap/Handle.h" |
| 41 #include "platform/network/HTTPHeaderMap.h" | 41 #include "platform/network/HTTPHeaderMap.h" |
| 42 #include "platform/network/ResourceError.h" | 42 #include "platform/network/ResourceError.h" |
| 43 #include "wtf/Forward.h" | 43 #include "wtf/Forward.h" |
| 44 #include "wtf/OwnPtr.h" | |
| 45 #include "wtf/PassOwnPtr.h" | |
| 46 #include "wtf/WeakPtr.h" | 44 #include "wtf/WeakPtr.h" |
| 47 #include "wtf/text/WTFString.h" | 45 #include "wtf/text/WTFString.h" |
| 46 #include <memory> |
| 48 | 47 |
| 49 namespace blink { | 48 namespace blink { |
| 50 | 49 |
| 51 class Document; | 50 class Document; |
| 52 class KURL; | 51 class KURL; |
| 53 class ResourceRequest; | 52 class ResourceRequest; |
| 54 class SecurityOrigin; | 53 class SecurityOrigin; |
| 55 class ThreadableLoaderClient; | 54 class ThreadableLoaderClient; |
| 56 | 55 |
| 57 class CORE_EXPORT DocumentThreadableLoader final : public ThreadableLoader, priv
ate RawResourceClient { | 56 class CORE_EXPORT DocumentThreadableLoader final : public ThreadableLoader, priv
ate RawResourceClient { |
| 58 USING_FAST_MALLOC(DocumentThreadableLoader); | 57 USING_FAST_MALLOC(DocumentThreadableLoader); |
| 59 public: | 58 public: |
| 60 static void loadResourceSynchronously(Document&, const ResourceRequest&,
ThreadableLoaderClient&, const ThreadableLoaderOptions&, const ResourceLoaderOp
tions&); | 59 static void loadResourceSynchronously(Document&, const ResourceRequest&,
ThreadableLoaderClient&, const ThreadableLoaderOptions&, const ResourceLoaderOp
tions&); |
| 61 static PassOwnPtr<DocumentThreadableLoader> create(Document&, Threadable
LoaderClient*, const ThreadableLoaderOptions&, const ResourceLoaderOptions&); | 60 static std::unique_ptr<DocumentThreadableLoader> create(Document&, Threa
dableLoaderClient*, const ThreadableLoaderOptions&, const ResourceLoaderOptions&
); |
| 62 ~DocumentThreadableLoader() override; | 61 ~DocumentThreadableLoader() override; |
| 63 | 62 |
| 64 void start(const ResourceRequest&) override; | 63 void start(const ResourceRequest&) override; |
| 65 | 64 |
| 66 void overrideTimeout(unsigned long timeout) override; | 65 void overrideTimeout(unsigned long timeout) override; |
| 67 | 66 |
| 68 // |this| may be dead after calling this method in async mode. | 67 // |this| may be dead after calling this method in async mode. |
| 69 void cancel() override; | 68 void cancel() override; |
| 70 void setDefersLoading(bool); | 69 void setDefersLoading(bool); |
| 71 | 70 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 83 // | 82 // |
| 84 // |this| may be dead after calling this method. | 83 // |this| may be dead after calling this method. |
| 85 void notifyFinished(Resource*) override; | 84 void notifyFinished(Resource*) override; |
| 86 | 85 |
| 87 String debugName() const override { return "DocumentThreadableLoader"; } | 86 String debugName() const override { return "DocumentThreadableLoader"; } |
| 88 | 87 |
| 89 // RawResourceClient | 88 // RawResourceClient |
| 90 // | 89 // |
| 91 // |this| may be dead after calling these methods. | 90 // |this| may be dead after calling these methods. |
| 92 void dataSent(Resource*, unsigned long long bytesSent, unsigned long lon
g totalBytesToBeSent) override; | 91 void dataSent(Resource*, unsigned long long bytesSent, unsigned long lon
g totalBytesToBeSent) override; |
| 93 void responseReceived(Resource*, const ResourceResponse&, PassOwnPtr<Web
DataConsumerHandle>) override; | 92 void responseReceived(Resource*, const ResourceResponse&, std::unique_pt
r<WebDataConsumerHandle>) override; |
| 94 void setSerializedCachedMetadata(Resource*, const char*, size_t) overrid
e; | 93 void setSerializedCachedMetadata(Resource*, const char*, size_t) overrid
e; |
| 95 void dataReceived(Resource*, const char* data, size_t dataLength) overri
de; | 94 void dataReceived(Resource*, const char* data, size_t dataLength) overri
de; |
| 96 void redirectReceived(Resource*, ResourceRequest&, const ResourceRespons
e&) override; | 95 void redirectReceived(Resource*, ResourceRequest&, const ResourceRespons
e&) override; |
| 97 void redirectBlocked() override; | 96 void redirectBlocked() override; |
| 98 void dataDownloaded(Resource*, int) override; | 97 void dataDownloaded(Resource*, int) override; |
| 99 void didReceiveResourceTiming(Resource*, const ResourceTimingInfo&) over
ride; | 98 void didReceiveResourceTiming(Resource*, const ResourceTimingInfo&) over
ride; |
| 100 | 99 |
| 101 // |this| may be dead after calling this method in async mode. | 100 // |this| may be dead after calling this method in async mode. |
| 102 void cancelWithError(const ResourceError&); | 101 void cancelWithError(const ResourceError&); |
| 103 | 102 |
| 104 // Notify Inspector and log to console about resource response. Use | 103 // Notify Inspector and log to console about resource response. Use |
| 105 // this method if response is not going to be finished normally. | 104 // this method if response is not going to be finished normally. |
| 106 void reportResponseReceived(unsigned long identifier, const ResourceResp
onse&); | 105 void reportResponseReceived(unsigned long identifier, const ResourceResp
onse&); |
| 107 | 106 |
| 108 // Methods containing code to handle resource fetch results which are | 107 // Methods containing code to handle resource fetch results which are |
| 109 // common to both sync and async mode. | 108 // common to both sync and async mode. |
| 110 // | 109 // |
| 111 // |this| may be dead after calling these method in async mode. | 110 // |this| may be dead after calling these method in async mode. |
| 112 void handleResponse(unsigned long identifier, const ResourceResponse&, P
assOwnPtr<WebDataConsumerHandle>); | 111 void handleResponse(unsigned long identifier, const ResourceResponse&, s
td::unique_ptr<WebDataConsumerHandle>); |
| 113 void handleReceivedData(const char* data, size_t dataLength); | 112 void handleReceivedData(const char* data, size_t dataLength); |
| 114 void handleSuccessfulFinish(unsigned long identifier, double finishTime)
; | 113 void handleSuccessfulFinish(unsigned long identifier, double finishTime)
; |
| 115 | 114 |
| 116 // |this| may be dead after calling this method. | 115 // |this| may be dead after calling this method. |
| 117 void didTimeout(Timer<DocumentThreadableLoader>*); | 116 void didTimeout(Timer<DocumentThreadableLoader>*); |
| 118 // Calls the appropriate loading method according to policy and data | 117 // Calls the appropriate loading method according to policy and data |
| 119 // about origin. Only for handling the initial load (including fallback | 118 // about origin. Only for handling the initial load (including fallback |
| 120 // after consulting ServiceWorker). | 119 // after consulting ServiceWorker). |
| 121 // | 120 // |
| 122 // |this| may be dead after calling this method in async mode. | 121 // |this| may be dead after calling this method in async mode. |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 int m_corsRedirectLimit; | 223 int m_corsRedirectLimit; |
| 225 | 224 |
| 226 WebURLRequest::FetchRedirectMode m_redirectMode; | 225 WebURLRequest::FetchRedirectMode m_redirectMode; |
| 227 | 226 |
| 228 WeakPtrFactory<DocumentThreadableLoader> m_weakFactory; | 227 WeakPtrFactory<DocumentThreadableLoader> m_weakFactory; |
| 229 }; | 228 }; |
| 230 | 229 |
| 231 } // namespace blink | 230 } // namespace blink |
| 232 | 231 |
| 233 #endif // DocumentThreadableLoader_h | 232 #endif // DocumentThreadableLoader_h |
| OLD | NEW |