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

Side by Side Diff: third_party/WebKit/Source/web/tests/sim/SimRequest.cpp

Issue 1839643009: RELEASE_ASSERT -> CHECK and ASSERT -> DCHECK in web. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compilation. Created 4 years, 8 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 unified diff | Download patch
OLDNEW
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/WebUnitTestSupport.h"
(...skipping 11 matching lines...) Expand all
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()->unitTestSupport()->registerMockedURL(fullUrl, response, "");
27 SimNetwork::current().addRequest(*this); 27 SimNetwork::current().addRequest(*this);
28 } 28 }
29 29
30 SimRequest::~SimRequest() 30 SimRequest::~SimRequest()
31 { 31 {
32 ASSERT(!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 {
37 m_client = client; 37 m_client = client;
38 m_loader = loader; 38 m_loader = loader;
39 m_response = response; 39 m_response = response;
40 m_isReady = true; 40 m_isReady = true;
41 } 41 }
42 42
43 void SimRequest::didFail(const WebURLError& error) 43 void SimRequest::didFail(const WebURLError& error)
44 { 44 {
45 m_error = error; 45 m_error = error;
46 } 46 }
47 47
48 void SimRequest::start() 48 void SimRequest::start()
49 { 49 {
50 SimNetwork::current().servePendingRequests(); 50 SimNetwork::current().servePendingRequests();
51 ASSERT(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 ASSERT(m_isReady && !m_error.reason); 57 DCHECK(m_isReady && !m_error.reason);
tkent 2016/03/31 23:05:21 Please split this into two. DCHECK(m_isReady);
58 m_totalEncodedDataLength += data.length(); 58 m_totalEncodedDataLength += data.length();
59 m_client->didReceiveData(m_loader, data.utf8().data(), data.length(), data.l ength()); 59 m_client->didReceiveData(m_loader, data.utf8().data(), data.length(), data.l ength());
60 } 60 }
61 61
62 void SimRequest::finish() 62 void SimRequest::finish()
63 { 63 {
64 ASSERT(m_isReady); 64 DCHECK(m_isReady);
65 if (m_error.reason) { 65 if (m_error.reason) {
66 m_client->didFail(m_loader, m_error); 66 m_client->didFail(m_loader, m_error);
67 } else { 67 } else {
68 // TODO(esprehn): Is claiming a request time of 0 okay for tests? 68 // TODO(esprehn): Is claiming a request time of 0 okay for tests?
69 m_client->didFinishLoading(m_loader, 0, m_totalEncodedDataLength); 69 m_client->didFinishLoading(m_loader, 0, m_totalEncodedDataLength);
70 } 70 }
71 reset(); 71 reset();
72 } 72 }
73 73
74 void SimRequest::complete(const String& data) 74 void SimRequest::complete(const String& data)
75 { 75 {
76 start(); 76 start();
77 if (!data.isEmpty()) 77 if (!data.isEmpty())
78 write(data); 78 write(data);
79 finish(); 79 finish();
80 } 80 }
81 81
82 void SimRequest::reset() 82 void SimRequest::reset()
83 { 83 {
84 m_isReady = false; 84 m_isReady = false;
85 m_client = nullptr; 85 m_client = nullptr;
86 m_loader = nullptr; 86 m_loader = nullptr;
87 SimNetwork::current().removeRequest(*this); 87 SimNetwork::current().removeRequest(*this);
88 } 88 }
89 89
90 } // namespace blink 90 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698