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

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: Return DCHECK_IS_ON checks. 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
« no previous file with comments | « third_party/WebKit/Source/web/tests/sim/SimNetwork.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
58 DCHECK(!m_error.reason);
58 m_totalEncodedDataLength += data.length(); 59 m_totalEncodedDataLength += data.length();
59 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());
60 } 61 }
61 62
62 void SimRequest::finish() 63 void SimRequest::finish()
63 { 64 {
64 ASSERT(m_isReady); 65 DCHECK(m_isReady);
65 if (m_error.reason) { 66 if (m_error.reason) {
66 m_client->didFail(m_loader, m_error); 67 m_client->didFail(m_loader, m_error);
67 } else { 68 } else {
68 // 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?
69 m_client->didFinishLoading(m_loader, 0, m_totalEncodedDataLength); 70 m_client->didFinishLoading(m_loader, 0, m_totalEncodedDataLength);
70 } 71 }
71 reset(); 72 reset();
72 } 73 }
73 74
74 void SimRequest::complete(const String& data) 75 void SimRequest::complete(const String& data)
75 { 76 {
76 start(); 77 start();
77 if (!data.isEmpty()) 78 if (!data.isEmpty())
78 write(data); 79 write(data);
79 finish(); 80 finish();
80 } 81 }
81 82
82 void SimRequest::reset() 83 void SimRequest::reset()
83 { 84 {
84 m_isReady = false; 85 m_isReady = false;
85 m_client = nullptr; 86 m_client = nullptr;
86 m_loader = nullptr; 87 m_loader = nullptr;
87 SimNetwork::current().removeRequest(*this); 88 SimNetwork::current().removeRequest(*this);
88 } 89 }
89 90
90 } // namespace blink 91 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/sim/SimNetwork.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698