| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "web/tests/sim/SimRequest.h" | 5 #include "web/tests/sim/SimRequest.h" |
| 6 | 6 |
| 7 #include "platform/weborigin/KURL.h" | 7 #include "platform/weborigin/KURL.h" |
| 8 #include "public/platform/Platform.h" | 8 #include "public/platform/Platform.h" |
| 9 #include "public/platform/WebURLLoaderClient.h" | 9 #include "public/platform/WebURLLoaderClient.h" |
| 10 #include "public/platform/WebUnitTestSupport.h" | 10 #include "public/platform/WebURLLoaderMockFactory.h" |
| 11 #include "web/tests/sim/SimNetwork.h" | 11 #include "web/tests/sim/SimNetwork.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 SimRequest::SimRequest(String url, String mimeType) | 15 SimRequest::SimRequest(String url, String mimeType) |
| 16 : m_url(url) | 16 : m_url(url) |
| 17 , m_loader(nullptr) | 17 , m_loader(nullptr) |
| 18 , m_client(nullptr) | 18 , m_client(nullptr) |
| 19 , m_totalEncodedDataLength(0) | 19 , m_totalEncodedDataLength(0) |
| 20 , m_isReady(false) | 20 , m_isReady(false) |
| 21 { | 21 { |
| 22 KURL fullUrl(ParsedURLString, url); | 22 KURL fullUrl(ParsedURLString, url); |
| 23 WebURLResponse response(fullUrl); | 23 WebURLResponse response(fullUrl); |
| 24 response.setMIMEType(mimeType); | 24 response.setMIMEType(mimeType); |
| 25 response.setHTTPStatusCode(200); | 25 response.setHTTPStatusCode(200); |
| 26 Platform::current()->unitTestSupport()->registerMockedURL(fullUrl, response,
""); | 26 Platform::current()->getURLLoaderMockFactory()->registerURL(fullUrl, respons
e, ""); |
| 27 SimNetwork::current().addRequest(*this); | 27 SimNetwork::current().addRequest(*this); |
| 28 } | 28 } |
| 29 | 29 |
| 30 SimRequest::~SimRequest() | 30 SimRequest::~SimRequest() |
| 31 { | 31 { |
| 32 DCHECK(!m_isReady); | 32 DCHECK(!m_isReady); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void SimRequest::didReceiveResponse(WebURLLoaderClient* client, WebURLLoader* lo
ader, const WebURLResponse& response) | 35 void SimRequest::didReceiveResponse(WebURLLoaderClient* client, WebURLLoader* lo
ader, const WebURLResponse& response) |
| 36 { | 36 { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 | 82 |
| 83 void SimRequest::reset() | 83 void SimRequest::reset() |
| 84 { | 84 { |
| 85 m_isReady = false; | 85 m_isReady = false; |
| 86 m_client = nullptr; | 86 m_client = nullptr; |
| 87 m_loader = nullptr; | 87 m_loader = nullptr; |
| 88 SimNetwork::current().removeRequest(*this); | 88 SimNetwork::current().removeRequest(*this); |
| 89 } | 89 } |
| 90 | 90 |
| 91 } // namespace blink | 91 } // namespace blink |
| OLD | NEW |