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

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

Issue 2537753002: Remove WebURLLoader* argument from WebURLLoaderClient methods (Closed)
Patch Set: a 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/SimNetwork.h" 5 #include "web/tests/sim/SimNetwork.h"
6 6
7 #include "public/platform/Platform.h" 7 #include "public/platform/Platform.h"
8 #include "public/platform/WebURLError.h" 8 #include "public/platform/WebURLError.h"
9 #include "public/platform/WebURLLoader.h" 9 #include "public/platform/WebURLLoader.h"
10 #include "public/platform/WebURLLoaderClient.h" 10 #include "public/platform/WebURLLoaderClient.h"
(...skipping 20 matching lines...) Expand all
31 SimNetwork& SimNetwork::current() { 31 SimNetwork& SimNetwork::current() {
32 DCHECK(s_network); 32 DCHECK(s_network);
33 return *s_network; 33 return *s_network;
34 } 34 }
35 35
36 void SimNetwork::servePendingRequests() { 36 void SimNetwork::servePendingRequests() {
37 Platform::current()->getURLLoaderMockFactory()->serveAsynchronousRequests(); 37 Platform::current()->getURLLoaderMockFactory()->serveAsynchronousRequests();
38 } 38 }
39 39
40 void SimNetwork::didReceiveResponse(WebURLLoaderClient* client, 40 void SimNetwork::didReceiveResponse(WebURLLoaderClient* client,
41 WebURLLoader* loader,
42 const WebURLResponse& response) { 41 const WebURLResponse& response) {
43 auto it = m_requests.find(response.url().string()); 42 auto it = m_requests.find(response.url().string());
44 if (it == m_requests.end()) { 43 if (it == m_requests.end()) {
45 client->didReceiveResponse(loader, response); 44 client->didReceiveResponse(response);
46 return; 45 return;
47 } 46 }
48 DCHECK(it->value); 47 DCHECK(it->value);
49 m_currentRequest = it->value; 48 m_currentRequest = it->value;
50 m_currentRequest->didReceiveResponse(client, loader, response); 49 m_currentRequest->didReceiveResponse(client, response);
51 } 50 }
52 51
53 void SimNetwork::didReceiveData(WebURLLoaderClient* client, 52 void SimNetwork::didReceiveData(WebURLLoaderClient* client,
54 WebURLLoader* loader,
55 const char* data, 53 const char* data,
56 int dataLength, 54 int dataLength,
57 int encodedDataLength) { 55 int encodedDataLength) {
58 if (!m_currentRequest) 56 if (!m_currentRequest)
59 client->didReceiveData(loader, data, dataLength, encodedDataLength); 57 client->didReceiveData(data, dataLength, encodedDataLength);
60 } 58 }
61 59
62 void SimNetwork::didFail(WebURLLoaderClient* client, 60 void SimNetwork::didFail(WebURLLoaderClient* client,
63 WebURLLoader* loader,
64 const WebURLError& error, 61 const WebURLError& error,
65 int64_t totalEncodedDataLength, 62 int64_t totalEncodedDataLength,
66 int64_t totalEncodedBodyLength) { 63 int64_t totalEncodedBodyLength) {
67 if (!m_currentRequest) { 64 if (!m_currentRequest) {
68 client->didFail(loader, error, totalEncodedDataLength, 65 client->didFail(error, totalEncodedDataLength, totalEncodedBodyLength);
69 totalEncodedBodyLength);
70 return; 66 return;
71 } 67 }
72 m_currentRequest->didFail(error); 68 m_currentRequest->didFail(error);
73 } 69 }
74 70
75 void SimNetwork::didFinishLoading(WebURLLoaderClient* client, 71 void SimNetwork::didFinishLoading(WebURLLoaderClient* client,
76 WebURLLoader* loader,
77 double finishTime, 72 double finishTime,
78 int64_t totalEncodedDataLength, 73 int64_t totalEncodedDataLength,
79 int64_t totalEncodedBodyLength) { 74 int64_t totalEncodedBodyLength) {
80 if (!m_currentRequest) { 75 if (!m_currentRequest) {
81 client->didFinishLoading(loader, finishTime, totalEncodedDataLength, 76 client->didFinishLoading(finishTime, totalEncodedDataLength,
82 totalEncodedBodyLength); 77 totalEncodedBodyLength);
83 return; 78 return;
84 } 79 }
85 m_currentRequest = nullptr; 80 m_currentRequest = nullptr;
86 } 81 }
87 82
88 void SimNetwork::addRequest(SimRequest& request) { 83 void SimNetwork::addRequest(SimRequest& request) {
89 m_requests.add(request.url(), &request); 84 m_requests.add(request.url(), &request);
90 } 85 }
91 86
92 void SimNetwork::removeRequest(SimRequest& request) { 87 void SimNetwork::removeRequest(SimRequest& request) {
93 m_requests.remove(request.url()); 88 m_requests.remove(request.url());
94 } 89 }
95 90
96 } // namespace blink 91 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/sim/SimNetwork.h ('k') | third_party/WebKit/Source/web/tests/sim/SimRequest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698