| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 DCHECK(!newRequest.url().isValid()); | 96 DCHECK(!newRequest.url().isValid()); |
| 97 cancel(); | 97 cancel(); |
| 98 } | 98 } |
| 99 | 99 |
| 100 return newRequest; | 100 return newRequest; |
| 101 } | 101 } |
| 102 | 102 |
| 103 void WebURLLoaderMock::loadSynchronously(const WebURLRequest& request, | 103 void WebURLLoaderMock::loadSynchronously(const WebURLRequest& request, |
| 104 WebURLResponse& response, | 104 WebURLResponse& response, |
| 105 WebURLError& error, | 105 WebURLError& error, |
| 106 WebData& data) { | 106 WebData& data, |
| 107 int64_t& encoded_data_length) { |
| 107 if (factory_->IsMockedURL(request.url())) { | 108 if (factory_->IsMockedURL(request.url())) { |
| 108 factory_->LoadSynchronously(request, &response, &error, &data); | 109 factory_->LoadSynchronously(request, &response, &error, &data, |
| 110 &encoded_data_length); |
| 109 return; | 111 return; |
| 110 } | 112 } |
| 111 DCHECK(KURL(request.url()).protocolIsData()) | 113 DCHECK(KURL(request.url()).protocolIsData()) |
| 112 << "loadSynchronously shouldn't be falling back: " | 114 << "loadSynchronously shouldn't be falling back: " |
| 113 << request.url().string().utf8(); | 115 << request.url().string().utf8(); |
| 114 using_default_loader_ = true; | 116 using_default_loader_ = true; |
| 115 default_loader_->loadSynchronously(request, response, error, data); | 117 default_loader_->loadSynchronously(request, response, error, data, |
| 118 encoded_data_length); |
| 116 } | 119 } |
| 117 | 120 |
| 118 void WebURLLoaderMock::loadAsynchronously(const WebURLRequest& request, | 121 void WebURLLoaderMock::loadAsynchronously(const WebURLRequest& request, |
| 119 WebURLLoaderClient* client) { | 122 WebURLLoaderClient* client) { |
| 120 DCHECK(client); | 123 DCHECK(client); |
| 121 if (factory_->IsMockedURL(request.url())) { | 124 if (factory_->IsMockedURL(request.url())) { |
| 122 client_ = client; | 125 client_ = client; |
| 123 factory_->LoadAsynchronouly(request, this); | 126 factory_->LoadAsynchronouly(request, this); |
| 124 return; | 127 return; |
| 125 } | 128 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 // In principle this is NOTIMPLEMENTED(), but if we put that here it floods | 161 // In principle this is NOTIMPLEMENTED(), but if we put that here it floods |
| 159 // the console during webkit unit tests, so we leave the function empty. | 162 // the console during webkit unit tests, so we leave the function empty. |
| 160 DCHECK(runner); | 163 DCHECK(runner); |
| 161 } | 164 } |
| 162 | 165 |
| 163 WeakPtr<WebURLLoaderMock> WebURLLoaderMock::GetWeakPtr() { | 166 WeakPtr<WebURLLoaderMock> WebURLLoaderMock::GetWeakPtr() { |
| 164 return weak_factory_.createWeakPtr(); | 167 return weak_factory_.createWeakPtr(); |
| 165 } | 168 } |
| 166 | 169 |
| 167 } // namespace blink | 170 } // namespace blink |
| OLD | NEW |