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

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

Issue 2540023003: Dispatch encoded_data_length separately in content/child (Closed)
Patch Set: rebase Created 4 years 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/WebURLLoaderMockFactory.h" 10 #include "public/platform/WebURLLoaderMockFactory.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 void SimRequest::start() { 44 void SimRequest::start() {
45 SimNetwork::current().servePendingRequests(); 45 SimNetwork::current().servePendingRequests();
46 DCHECK(m_isReady); 46 DCHECK(m_isReady);
47 m_client->didReceiveResponse(m_response); 47 m_client->didReceiveResponse(m_response);
48 } 48 }
49 49
50 void SimRequest::write(const String& data) { 50 void SimRequest::write(const String& data) {
51 DCHECK(m_isReady); 51 DCHECK(m_isReady);
52 DCHECK(!m_error.reason); 52 DCHECK(!m_error.reason);
53 m_totalEncodedDataLength += data.length(); 53 m_totalEncodedDataLength += data.length();
54 m_client->didReceiveData(data.utf8().data(), data.length(), data.length()); 54 m_client->didReceiveData(data.utf8().data(), data.length());
55 } 55 }
56 56
57 void SimRequest::finish() { 57 void SimRequest::finish() {
58 DCHECK(m_isReady); 58 DCHECK(m_isReady);
59 if (m_error.reason) { 59 if (m_error.reason) {
60 m_client->didFail(m_error, m_totalEncodedDataLength, 60 m_client->didFail(m_error, m_totalEncodedDataLength,
61 m_totalEncodedDataLength); 61 m_totalEncodedDataLength);
62 } else { 62 } else {
63 // TODO(esprehn): Is claiming a request time of 0 okay for tests? 63 // TODO(esprehn): Is claiming a request time of 0 okay for tests?
64 m_client->didFinishLoading(0, m_totalEncodedDataLength, 64 m_client->didFinishLoading(0, m_totalEncodedDataLength,
65 m_totalEncodedDataLength); 65 m_totalEncodedDataLength);
66 } 66 }
67 reset(); 67 reset();
68 } 68 }
69 69
70 void SimRequest::complete(const String& data) { 70 void SimRequest::complete(const String& data) {
71 start(); 71 start();
72 if (!data.isEmpty()) 72 if (!data.isEmpty())
73 write(data); 73 write(data);
74 finish(); 74 finish();
75 } 75 }
76 76
77 void SimRequest::reset() { 77 void SimRequest::reset() {
78 m_isReady = false; 78 m_isReady = false;
79 m_client = nullptr; 79 m_client = nullptr;
80 SimNetwork::current().removeRequest(*this); 80 SimNetwork::current().removeRequest(*this);
81 } 81 }
82 82
83 } // namespace blink 83 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698