| 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 #ifndef WebURLLoaderMockFactory_h | 5 #ifndef WebURLLoaderMockFactory_h |
| 6 #define WebURLLoaderMockFactory_h | 6 #define WebURLLoaderMockFactory_h |
| 7 | 7 |
| 8 #include "public/platform/WebCommon.h" | 8 #include "public/platform/WebCommon.h" |
| 9 #include "public/platform/WebData.h" | 9 #include "public/platform/WebData.h" |
| 10 #include "public/platform/WebString.h" | 10 #include "public/platform/WebString.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 virtual ~WebURLLoaderMockFactory() {} | 26 virtual ~WebURLLoaderMockFactory() {} |
| 27 | 27 |
| 28 // Create a WebURLLoader that takes care of mocked requests. | 28 // Create a WebURLLoader that takes care of mocked requests. |
| 29 // Non-mocked request are forwarded to given loader which should not | 29 // Non-mocked request are forwarded to given loader which should not |
| 30 // be nullptr. | 30 // be nullptr. |
| 31 virtual std::unique_ptr<WebURLLoader> CreateURLLoader( | 31 virtual std::unique_ptr<WebURLLoader> CreateURLLoader( |
| 32 std::unique_ptr<WebURLLoader>) = 0; | 32 std::unique_ptr<WebURLLoader>) = 0; |
| 33 | 33 |
| 34 // Registers a response and the file to be served when the specified URL | 34 // Registers a response and the file to be served when the specified URL |
| 35 // is loaded. If no file is specified then the response content will be empty. | 35 // is loaded. If no file is specified then the response content will be empty. |
| 36 // unregisterURL() should be called for each test entry before registering | 36 // UnregisterURL() should be called for each test entry before registering |
| 37 // another response for the same URL from another test. | 37 // another response for the same URL from another test. |
| 38 virtual void RegisterURL(const WebURL&, | 38 virtual void RegisterURL(const WebURL&, |
| 39 const WebURLResponse&, | 39 const WebURLResponse&, |
| 40 const WebString& file_path) = 0; | 40 const WebString& file_path) = 0; |
| 41 | 41 |
| 42 // Registers an error to be served when the specified URL is requested. | 42 // Registers an error to be served when the specified URL is requested. |
| 43 // unregisterURL() should be called for each test entry before registering | 43 // UnregisterURL() should be called for each test entry before registering |
| 44 // another response for the same URL from another test. | 44 // another response for the same URL from another test. |
| 45 virtual void RegisterErrorURL(const WebURL&, | 45 virtual void RegisterErrorURL(const WebURL&, |
| 46 const WebURLResponse&, | 46 const WebURLResponse&, |
| 47 const WebURLError&) = 0; | 47 const WebURLError&) = 0; |
| 48 | 48 |
| 49 // Unregisters the given URL so it is no longer mocked. | 49 // Unregisters the given URL so it is no longer mocked. |
| 50 virtual void UnregisterURL(const WebURL&) = 0; | 50 virtual void UnregisterURL(const WebURL&) = 0; |
| 51 | 51 |
| 52 // Registers a response and the file to be served when a URL with the given |
| 53 // protocol is loaded. If no file is specified then the response content will |
| 54 // be empty. UnregisterProtocol() should be called for each test entry before |
| 55 // registering another response for the same protocol from another test. |
| 56 virtual void RegisterURLProtocol(const WebString& protocol, |
| 57 const WebURLResponse&, |
| 58 const WebString& file_path) = 0; |
| 59 |
| 60 // Unregisters the given URL protocol so it is no longer mocked. |
| 61 virtual void UnregisterURLProtocol(const WebString& protocol) = 0; |
| 62 |
| 52 // Unregisters URLs so they are no longer mocked. This also clears the | 63 // Unregisters URLs so they are no longer mocked. This also clears the |
| 53 // MemoryCache. | 64 // MemoryCache. |
| 54 virtual void UnregisterAllURLsAndClearMemoryCache() = 0; | 65 virtual void UnregisterAllURLsAndClearMemoryCache() = 0; |
| 55 | 66 |
| 56 // Causes all pending asynchronous requests to be served. When this method | 67 // Causes all pending asynchronous requests to be served. When this method |
| 57 // returns all the pending requests have been processed. | 68 // returns all the pending requests have been processed. |
| 58 // Note: this may not work as expected if more requests could be made | 69 // Note: this may not work as expected if more requests could be made |
| 59 // asynchronously from different threads (e.g. when HTML parser thread | 70 // asynchronously from different threads (e.g. when HTML parser thread |
| 60 // is being involved). | 71 // is being involved). |
| 61 // DO NOT USE THIS for Frame loading; always use methods defined in | 72 // DO NOT USE THIS for Frame loading; always use methods defined in |
| 62 // FrameTestHelpers instead. | 73 // FrameTestHelpers instead. |
| 63 virtual void ServeAsynchronousRequests() = 0; | 74 virtual void ServeAsynchronousRequests() = 0; |
| 64 | 75 |
| 65 // Set a delegate that allows callbacks for all WebURLLoaderClients to be | 76 // Set a delegate that allows callbacks for all WebURLLoaderClients to be |
| 66 // intercepted. | 77 // intercepted. |
| 67 virtual void SetLoaderDelegate(WebURLLoaderTestDelegate*) = 0; | 78 virtual void SetLoaderDelegate(WebURLLoaderTestDelegate*) = 0; |
| 68 }; | 79 }; |
| 69 | 80 |
| 70 } // namespace blink | 81 } // namespace blink |
| 71 | 82 |
| 72 #endif // WebURLLoaderMockFactory_h | 83 #endif // WebURLLoaderMockFactory_h |
| OLD | NEW |