1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
8 #include "public/platform/WebURLLoaderTestDelegate.h"
9 #include "wtf/HashMap.h"
10 #include "wtf/text/StringHash.h"
11 #include "wtf/text/WTFString.h"
17 class WebURLLoaderClient
;
20 // Simulates a network with precise flow control so you can make requests
21 // return, write data, and finish in a specific order in a unit test. One of
22 // these must be created before using the SimRequest to issue requests.
23 class SimNetwork final
: public WebURLLoaderTestDelegate
{
29 friend class SimRequest
;
31 static SimNetwork
& current();
33 void servePendingRequests();
34 void addRequest(SimRequest
&);
35 void removeRequest(SimRequest
&);
37 // WebURLLoaderTestDelegate
38 void didReceiveResponse(WebURLLoaderClient
*, WebURLLoader
*, const WebURLResponse
&) override
;
39 void didReceiveData(WebURLLoaderClient
*, WebURLLoader
*, const char* data
, int dataLength
, int encodedDataLength
) override
;
40 void didFail(WebURLLoaderClient
*, WebURLLoader
*, const WebURLError
&) override
;
41 void didFinishLoading(WebURLLoaderClient
*, WebURLLoader
*, double finishTime
, int64_t totalEncodedDataLength
) override
;
43 SimRequest
* m_currentRequest
;
44 HashMap
<String
, SimRequest
*> m_requests
;