Index: Source/web/tests/sim/SimRequest.h |
diff --git a/Source/web/tests/sim/SimRequest.h b/Source/web/tests/sim/SimRequest.h |
index 42ba0fe6b398102c86bf15b4c558cf793277d30a..197f2c1bfd2c09c7a91f0b70788a4eb8cb494268 100644 |
--- a/Source/web/tests/sim/SimRequest.h |
+++ b/Source/web/tests/sim/SimRequest.h |
@@ -15,25 +15,38 @@ class SimNetwork; |
class WebURLLoader; |
class WebURLLoaderClient; |
-class SimRequest { |
+// Simulates a single request for a resource from the server. Requires a |
+// SimNetwork to have been created first. Use the start(), write() and finish() |
+// methods to simulate the response from the server. Note that all started |
+// requests must be finished. |
+class SimRequest final { |
public: |
SimRequest(String url, String mimeType); |
+ ~SimRequest(); |
- void didReceiveResponse(WebURLLoaderClient*, WebURLLoader*, const WebURLResponse&); |
- void didFail(const WebURLError&); |
- |
+ // Starts the response from the server, this is as if the headers and 200 OK |
+ // reply had been received but no response body yet. |
void start(); |
+ |
+ // Write a chunk of the response body. |
void write(const String& data); |
+ |
+ // Finish the response, this is as if the server closed the connection. |
void finish(); |
- bool isReady() const { return m_isReady; } |
const String& url() const { return m_url; } |
const WebURLError& error() const { return m_error; } |
const WebURLResponse& response() const { return m_response; } |
+private: |
+ friend class SimNetwork; |
+ |
void reset(); |
-private: |
+ // Used by SimNetwork. |
+ void didReceiveResponse(WebURLLoaderClient*, WebURLLoader*, const WebURLResponse&); |
+ void didFail(const WebURLError&); |
+ |
String m_url; |
WebURLLoader* m_loader; |
WebURLResponse m_response; |