| Index: third_party/WebKit/Source/core/fetch/RawResource.h
|
| diff --git a/third_party/WebKit/Source/core/fetch/RawResource.h b/third_party/WebKit/Source/core/fetch/RawResource.h
|
| index d8a0d5233db79b09cba048beb57cd9195a552438..9dfa986d62a49b88ce052d8b4cac01af75c665a3 100644
|
| --- a/third_party/WebKit/Source/core/fetch/RawResource.h
|
| +++ b/third_party/WebKit/Source/core/fetch/RawResource.h
|
| @@ -107,6 +107,23 @@ public:
|
| static bool isExpectedType(ResourceClient* client) { return client->getResourceClientType() == RawResourceType; }
|
| ResourceClientType getResourceClientType() const final { return RawResourceType; }
|
|
|
| + // The order of the callbacks is as follows:
|
| + // [Case 1] A successful load:
|
| + // 0+ redirectReceived() and/or dataSent()
|
| + // 1 responseReceived()
|
| + // 0-1 setSerializedCachedMetadata()
|
| + // 0+ dataReceived() or dataDownloaded(), but never both
|
| + // 1 notifyFinished() with errorOccurred() = false
|
| + // [Case 2] When redirect is blocked:
|
| + // 0+ redirectReceived() and/or dataSent()
|
| + // 1 redirectBlocked()
|
| + // 1 notifyFinished() with errorOccurred() = true
|
| + // [Case 3] Other failures:
|
| + // notifyFinished() with errorOccurred() = true is called at any time
|
| + // (unless notifyFinished() is already called).
|
| + // In all cases:
|
| + // No callbacks are made after notifyFinished() or
|
| + // removeClient() is called.
|
| virtual void dataSent(Resource*, unsigned long long /* bytesSent */, unsigned long long /* totalBytesToBeSent */) { }
|
| virtual void responseReceived(Resource*, const ResourceResponse&, std::unique_ptr<WebDataConsumerHandle>) { }
|
| virtual void setSerializedCachedMetadata(Resource*, const char*, size_t) { }
|
| @@ -119,6 +136,43 @@ public:
|
| DEFINE_INLINE_VIRTUAL_TRACE() {}
|
| };
|
|
|
| +// Checks the sequence of callbacks of RawResourceClient.
|
| +// This can be used only when a RawResourceClient is added as a client to
|
| +// at most one RawResource.
|
| +class CORE_EXPORT RawResourceClientStateChecker final {
|
| +public:
|
| + RawResourceClientStateChecker();
|
| + ~RawResourceClientStateChecker();
|
| +
|
| + // Call before addClient()/removeClient() is called.
|
| + void willAddClient();
|
| + void willRemoveClient();
|
| +
|
| + // Call RawResourceClientStateChecker::f() at the beginning of
|
| + // RawResourceClient::f().
|
| + void redirectReceived();
|
| + void redirectBlocked();
|
| + void dataSent();
|
| + void responseReceived();
|
| + void setSerializedCachedMetadata();
|
| + void dataReceived();
|
| + void dataDownloaded();
|
| + void notifyFinished(Resource*);
|
| +
|
| +private:
|
| + enum State {
|
| + NotAddedAsClient,
|
| + Started,
|
| + RedirectBlocked,
|
| + ResponseReceived,
|
| + SetSerializedCachedMetadata,
|
| + DataReceived,
|
| + DataDownloaded,
|
| + NotifyFinished
|
| + };
|
| + State m_state;
|
| +};
|
| +
|
| } // namespace blink
|
|
|
| #endif // RawResource_h
|
|
|