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

Unified Diff: third_party/WebKit/Source/core/fetch/RawResource.h

Issue 2020313002: Verify the order of RawResourceClient callbacks in DocumentThreadableLoader (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix rebase error and update TODO comment Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/fetch/RawResource.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/fetch/RawResource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698