| 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/WebURLLoaderMockFactory.h" | 10 #include "public/platform/WebURLLoaderMockFactory.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 SimNetwork::current().servePendingRequests(); | 50 SimNetwork::current().servePendingRequests(); |
| 51 DCHECK(m_isReady); | 51 DCHECK(m_isReady); |
| 52 m_client->didReceiveResponse(m_loader, m_response); | 52 m_client->didReceiveResponse(m_loader, m_response); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void SimRequest::write(const String& data) | 55 void SimRequest::write(const String& data) |
| 56 { | 56 { |
| 57 DCHECK(m_isReady); | 57 DCHECK(m_isReady); |
| 58 DCHECK(!m_error.reason); | 58 DCHECK(!m_error.reason); |
| 59 m_totalEncodedDataLength += data.length(); | 59 m_totalEncodedDataLength += data.length(); |
| 60 m_client->didReceiveData(m_loader, data.utf8().data(), data.length(), data.l
ength()); | 60 m_client->didReceiveData(m_loader, data.utf8().data(), data.length(), data.l
ength(), data.length()); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void SimRequest::finish() | 63 void SimRequest::finish() |
| 64 { | 64 { |
| 65 DCHECK(m_isReady); | 65 DCHECK(m_isReady); |
| 66 if (m_error.reason) { | 66 if (m_error.reason) { |
| 67 m_client->didFail(m_loader, m_error); | 67 m_client->didFail(m_loader, m_error); |
| 68 } else { | 68 } else { |
| 69 // TODO(esprehn): Is claiming a request time of 0 okay for tests? | 69 // TODO(esprehn): Is claiming a request time of 0 okay for tests? |
| 70 m_client->didFinishLoading(m_loader, 0, m_totalEncodedDataLength); | 70 m_client->didFinishLoading(m_loader, 0, m_totalEncodedDataLength); |
| (...skipping 11 matching lines...) Expand all 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 |