OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "platform/testing/weburl_loader_mock.h" | 5 #include "platform/testing/weburl_loader_mock.h" |
6 | 6 |
7 #include "platform/testing/weburl_loader_mock_factory_impl.h" | 7 #include "platform/testing/weburl_loader_mock_factory_impl.h" |
8 #include "public/platform/URLConversion.h" | 8 #include "public/platform/URLConversion.h" |
9 #include "public/platform/WebData.h" | 9 #include "public/platform/WebData.h" |
10 #include "public/platform/WebURLError.h" | 10 #include "public/platform/WebURLError.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 delegate->didReceiveData(client_, data.data(), data.size()); | 66 delegate->didReceiveData(client_, data.data(), data.size()); |
67 if (!self) | 67 if (!self) |
68 return; | 68 return; |
69 | 69 |
70 delegate->didFinishLoading(client_, 0, data.size(), data.size()); | 70 delegate->didFinishLoading(client_, 0, data.size(), data.size()); |
71 } | 71 } |
72 | 72 |
73 WebURLRequest WebURLLoaderMock::ServeRedirect( | 73 WebURLRequest WebURLLoaderMock::ServeRedirect( |
74 const WebURLRequest& request, | 74 const WebURLRequest& request, |
75 const WebURLResponse& redirectResponse) { | 75 const WebURLResponse& redirectResponse) { |
76 KURL redirectURL( | 76 KURL redirectURL(ParsedURLString, |
77 ParsedURLString, redirectResponse.httpHeaderField("Location")); | 77 redirectResponse.httpHeaderField("Location")); |
78 | 78 |
79 WebURLRequest newRequest(redirectURL); | 79 WebURLRequest newRequest(redirectURL); |
80 newRequest.setFirstPartyForCookies(redirectURL); | 80 newRequest.setFirstPartyForCookies(redirectURL); |
81 newRequest.setDownloadToFile(request.downloadToFile()); | 81 newRequest.setDownloadToFile(request.downloadToFile()); |
82 newRequest.setUseStreamOnResponse(request.useStreamOnResponse()); | 82 newRequest.setUseStreamOnResponse(request.useStreamOnResponse()); |
83 newRequest.setRequestContext(request.getRequestContext()); | 83 newRequest.setRequestContext(request.getRequestContext()); |
84 newRequest.setFrameType(request.getFrameType()); | 84 newRequest.setFrameType(request.getFrameType()); |
85 newRequest.setSkipServiceWorker(request.skipServiceWorker()); | 85 newRequest.setSkipServiceWorker(request.skipServiceWorker()); |
86 newRequest.setShouldResetAppCache(request.shouldResetAppCache()); | 86 newRequest.setShouldResetAppCache(request.shouldResetAppCache()); |
87 newRequest.setFetchRequestMode(request.getFetchRequestMode()); | 87 newRequest.setFetchRequestMode(request.getFetchRequestMode()); |
(...skipping 17 matching lines...) Expand all Loading... |
105 return newRequest; | 105 return newRequest; |
106 } | 106 } |
107 | 107 |
108 void WebURLLoaderMock::loadSynchronously(const WebURLRequest& request, | 108 void WebURLLoaderMock::loadSynchronously(const WebURLRequest& request, |
109 WebURLResponse& response, | 109 WebURLResponse& response, |
110 WebURLError& error, | 110 WebURLError& error, |
111 WebData& data, | 111 WebData& data, |
112 int64_t& encoded_data_length, | 112 int64_t& encoded_data_length, |
113 int64_t& encoded_body_length) { | 113 int64_t& encoded_body_length) { |
114 if (factory_->IsMockedURL(request.url())) { | 114 if (factory_->IsMockedURL(request.url())) { |
115 factory_->LoadSynchronously(request, &response, &error, &data, | 115 factory_->LoadSynchronously(request, &response, &error, &data, |
116 &encoded_data_length); | 116 &encoded_data_length); |
117 return; | 117 return; |
118 } | 118 } |
119 assertFallbackLoaderAvailability(request.url(), default_loader_.get()); | 119 assertFallbackLoaderAvailability(request.url(), default_loader_.get()); |
120 using_default_loader_ = true; | 120 using_default_loader_ = true; |
121 default_loader_->loadSynchronously(request, response, error, data, | 121 default_loader_->loadSynchronously(request, response, error, data, |
122 encoded_data_length, encoded_body_length); | 122 encoded_data_length, encoded_body_length); |
123 } | 123 } |
124 | 124 |
125 void WebURLLoaderMock::loadAsynchronously(const WebURLRequest& request, | 125 void WebURLLoaderMock::loadAsynchronously(const WebURLRequest& request, |
126 WebURLLoaderClient* client) { | 126 WebURLLoaderClient* client) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 base::SingleThreadTaskRunner* runner) { | 163 base::SingleThreadTaskRunner* runner) { |
164 // In principle this is NOTIMPLEMENTED(), but if we put that here it floods | 164 // In principle this is NOTIMPLEMENTED(), but if we put that here it floods |
165 // the console during webkit unit tests, so we leave the function empty. | 165 // the console during webkit unit tests, so we leave the function empty. |
166 DCHECK(runner); | 166 DCHECK(runner); |
167 } | 167 } |
168 | 168 |
169 WeakPtr<WebURLLoaderMock> WebURLLoaderMock::GetWeakPtr() { | 169 WeakPtr<WebURLLoaderMock> WebURLLoaderMock::GetWeakPtr() { |
170 return weak_factory_.createWeakPtr(); | 170 return weak_factory_.createWeakPtr(); |
171 } | 171 } |
172 | 172 |
173 } // namespace blink | 173 } // namespace blink |
OLD | NEW |