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

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

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
Index: third_party/WebKit/Source/core/fetch/RawResource.cpp
diff --git a/third_party/WebKit/Source/core/fetch/RawResource.cpp b/third_party/WebKit/Source/core/fetch/RawResource.cpp
index c1cb86504573f8f1351e602373960260d761919d..a822dba21254ade52f53d079cef7960736f1ba74 100644
--- a/third_party/WebKit/Source/core/fetch/RawResource.cpp
+++ b/third_party/WebKit/Source/core/fetch/RawResource.cpp
@@ -260,4 +260,73 @@ bool RawResource::canReuse(const ResourceRequest& newRequest) const
return true;
}
+RawResourceClientStateChecker::RawResourceClientStateChecker()
+ : m_state(NotAddedAsClient)
+{
+}
+
+RawResourceClientStateChecker::~RawResourceClientStateChecker()
+{
+}
+
+void RawResourceClientStateChecker::willAddClient()
+{
+ SECURITY_CHECK(m_state == NotAddedAsClient);
+ m_state = Started;
+}
+
+void RawResourceClientStateChecker::willRemoveClient()
+{
+ SECURITY_CHECK(m_state != NotAddedAsClient);
+ m_state = NotAddedAsClient;
+}
+
+void RawResourceClientStateChecker::redirectReceived()
+{
+ SECURITY_CHECK(m_state == Started);
+}
+
+void RawResourceClientStateChecker::redirectBlocked()
+{
+ SECURITY_CHECK(m_state == Started);
+ m_state = RedirectBlocked;
+}
+
+void RawResourceClientStateChecker::dataSent()
+{
+ SECURITY_CHECK(m_state == Started);
+}
+
+void RawResourceClientStateChecker::responseReceived()
+{
+ SECURITY_CHECK(m_state == Started);
+ m_state = ResponseReceived;
+}
+
+void RawResourceClientStateChecker::setSerializedCachedMetadata()
+{
+ SECURITY_CHECK(m_state == ResponseReceived);
+ m_state = SetSerializedCachedMetadata;
+}
+
+void RawResourceClientStateChecker::dataReceived()
+{
+ SECURITY_CHECK(m_state == ResponseReceived || m_state == SetSerializedCachedMetadata || m_state == DataReceived);
+ m_state = DataReceived;
+}
+
+void RawResourceClientStateChecker::dataDownloaded()
+{
+ SECURITY_CHECK(m_state == ResponseReceived || m_state == SetSerializedCachedMetadata || m_state == DataDownloaded);
+ m_state = DataDownloaded;
+}
+
+void RawResourceClientStateChecker::notifyFinished(Resource* resource)
+{
+ SECURITY_CHECK(m_state != NotAddedAsClient);
+ SECURITY_CHECK(m_state != NotifyFinished);
+ SECURITY_CHECK(resource->errorOccurred() || (m_state == ResponseReceived || m_state == SetSerializedCachedMetadata || m_state == DataReceived || m_state == DataDownloaded));
+ m_state = NotifyFinished;
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/fetch/RawResource.h ('k') | third_party/WebKit/Source/core/loader/DocumentThreadableLoader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698