| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_HTML_VIEWER_WEB_URL_LOADER_IMPL_H_ | |
| 6 #define COMPONENTS_HTML_VIEWER_WEB_URL_LOADER_IMPL_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/memory/weak_ptr.h" | |
| 10 #include "components/html_viewer/mock_web_blob_registry_impl.h" | |
| 11 #include "mojo/message_pump/handle_watcher.h" | |
| 12 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" | |
| 13 #include "third_party/WebKit/public/platform/WebBlobData.h" | |
| 14 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" | |
| 15 #include "third_party/WebKit/public/platform/WebURLLoader.h" | |
| 16 #include "third_party/WebKit/public/platform/WebURLRequest.h" | |
| 17 | |
| 18 namespace mojo { | |
| 19 class URLLoaderFactory; | |
| 20 } | |
| 21 | |
| 22 namespace html_viewer { | |
| 23 | |
| 24 // The concrete type of WebURLRequest::ExtraData. | |
| 25 class WebURLRequestExtraData : public blink::WebURLRequest::ExtraData { | |
| 26 public: | |
| 27 WebURLRequestExtraData(); | |
| 28 ~WebURLRequestExtraData() override; | |
| 29 | |
| 30 mojo::URLResponsePtr synthetic_response; | |
| 31 }; | |
| 32 | |
| 33 class WebURLLoaderImpl : public blink::WebURLLoader { | |
| 34 public: | |
| 35 explicit WebURLLoaderImpl(mojo::URLLoaderFactory* url_loader_factory, | |
| 36 MockWebBlobRegistryImpl* web_blob_registry); | |
| 37 | |
| 38 private: | |
| 39 ~WebURLLoaderImpl() override; | |
| 40 | |
| 41 // blink::WebURLLoader methods: | |
| 42 void loadSynchronously(const blink::WebURLRequest& request, | |
| 43 blink::WebURLResponse& response, | |
| 44 blink::WebURLError& error, | |
| 45 blink::WebData& data) override; | |
| 46 void loadAsynchronously(const blink::WebURLRequest&, | |
| 47 blink::WebURLLoaderClient* client) override; | |
| 48 void cancel() override; | |
| 49 void setDefersLoading(bool defers_loading) override; | |
| 50 void setLoadingTaskRunner(blink::WebTaskRunner* web_task_runner) override; | |
| 51 | |
| 52 void OnReceivedResponse(const blink::WebURLRequest& request, | |
| 53 mojo::URLResponsePtr response); | |
| 54 void OnReceivedError(mojo::URLResponsePtr response); | |
| 55 void OnReceivedRedirect(const blink::WebURLRequest& request, | |
| 56 mojo::URLResponsePtr response); | |
| 57 void OnReceiveWebBlobData( | |
| 58 const blink::WebURLRequest& request, | |
| 59 const blink::WebVector<blink::WebBlobData::Item*>& items); | |
| 60 void ReadMore(); | |
| 61 void WaitToReadMore(); | |
| 62 void OnResponseBodyStreamReady(MojoResult result); | |
| 63 | |
| 64 blink::WebURLLoaderClient* client_; | |
| 65 MockWebBlobRegistryImpl* web_blob_registry_; | |
| 66 GURL url_; | |
| 67 blink::WebReferrerPolicy referrer_policy_; | |
| 68 mojo::URLLoaderPtr url_loader_; | |
| 69 mojo::ScopedDataPipeConsumerHandle response_body_stream_; | |
| 70 mojo::common::HandleWatcher handle_watcher_; | |
| 71 | |
| 72 base::WeakPtrFactory<WebURLLoaderImpl> weak_factory_; | |
| 73 | |
| 74 DISALLOW_COPY_AND_ASSIGN(WebURLLoaderImpl); | |
| 75 }; | |
| 76 | |
| 77 } // namespace html_viewer | |
| 78 | |
| 79 #endif // COMPONENTS_HTML_VIEWER_WEB_URL_LOADER_IMPL_H_ | |
| OLD | NEW |