| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 MOJO_SERVICES_HTML_VIEWER_WEBURLLOADER_IMPL_H_ | 5 #ifndef MOJO_SERVICES_HTML_VIEWER_WEBURLLOADER_IMPL_H_ |
| 6 #define MOJO_SERVICES_HTML_VIEWER_WEBURLLOADER_IMPL_H_ | 6 #define MOJO_SERVICES_HTML_VIEWER_WEBURLLOADER_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "mojo/common/handle_watcher.h" | 10 #include "mojo/common/handle_watcher.h" |
| 11 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" | 11 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" |
| 12 #include "third_party/WebKit/public/platform/WebURLLoader.h" | 12 #include "third_party/WebKit/public/platform/WebURLLoader.h" |
| 13 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 13 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 14 | 14 |
| 15 namespace mojo { | 15 namespace mojo { |
| 16 class NetworkService; | 16 class NetworkService; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace html_viewer { | 19 namespace html_viewer { |
| 20 | 20 |
| 21 // The concrete type of WebURLRequest::ExtraData. | 21 // The concrete type of WebURLRequest::ExtraData. |
| 22 class WebURLRequestExtraData : public blink::WebURLRequest::ExtraData { | 22 class WebURLRequestExtraData : public blink::WebURLRequest::ExtraData { |
| 23 public: | 23 public: |
| 24 WebURLRequestExtraData(); | 24 WebURLRequestExtraData(); |
| 25 ~WebURLRequestExtraData() override; | 25 virtual ~WebURLRequestExtraData(); |
| 26 | 26 |
| 27 mojo::URLResponsePtr synthetic_response; | 27 mojo::URLResponsePtr synthetic_response; |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 class WebURLLoaderImpl : public blink::WebURLLoader { | 30 class WebURLLoaderImpl : public blink::WebURLLoader { |
| 31 public: | 31 public: |
| 32 explicit WebURLLoaderImpl(mojo::NetworkService* network_service); | 32 explicit WebURLLoaderImpl(mojo::NetworkService* network_service); |
| 33 | 33 |
| 34 private: | 34 private: |
| 35 virtual ~WebURLLoaderImpl(); | 35 virtual ~WebURLLoaderImpl(); |
| 36 | 36 |
| 37 // blink::WebURLLoader methods: | 37 // blink::WebURLLoader methods: |
| 38 void loadSynchronously(const blink::WebURLRequest& request, | 38 virtual void loadSynchronously(const blink::WebURLRequest& request, |
| 39 blink::WebURLResponse& response, | 39 blink::WebURLResponse& response, |
| 40 blink::WebURLError& error, | 40 blink::WebURLError& error, |
| 41 blink::WebData& data) override; | 41 blink::WebData& data); |
| 42 void loadAsynchronously(const blink::WebURLRequest&, | 42 virtual void loadAsynchronously(const blink::WebURLRequest&, |
| 43 blink::WebURLLoaderClient* client) override; | 43 blink::WebURLLoaderClient* client); |
| 44 void cancel() override; | 44 virtual void cancel(); |
| 45 void setDefersLoading(bool defers_loading) override; | 45 virtual void setDefersLoading(bool defers_loading); |
| 46 | 46 |
| 47 void OnReceivedResponse(const blink::WebURLRequest& request, | 47 void OnReceivedResponse(const blink::WebURLRequest& request, |
| 48 mojo::URLResponsePtr response); | 48 mojo::URLResponsePtr response); |
| 49 void OnReceivedError(mojo::URLResponsePtr response); | 49 void OnReceivedError(mojo::URLResponsePtr response); |
| 50 void OnReceivedRedirect(const blink::WebURLRequest& request, | 50 void OnReceivedRedirect(const blink::WebURLRequest& request, |
| 51 mojo::URLResponsePtr response); | 51 mojo::URLResponsePtr response); |
| 52 void ReadMore(); | 52 void ReadMore(); |
| 53 void WaitToReadMore(); | 53 void WaitToReadMore(); |
| 54 void OnResponseBodyStreamReady(MojoResult result); | 54 void OnResponseBodyStreamReady(MojoResult result); |
| 55 | 55 |
| 56 blink::WebURLLoaderClient* client_; | 56 blink::WebURLLoaderClient* client_; |
| 57 GURL url_; | 57 GURL url_; |
| 58 mojo::URLLoaderPtr url_loader_; | 58 mojo::URLLoaderPtr url_loader_; |
| 59 mojo::ScopedDataPipeConsumerHandle response_body_stream_; | 59 mojo::ScopedDataPipeConsumerHandle response_body_stream_; |
| 60 mojo::common::HandleWatcher handle_watcher_; | 60 mojo::common::HandleWatcher handle_watcher_; |
| 61 | 61 |
| 62 base::WeakPtrFactory<WebURLLoaderImpl> weak_factory_; | 62 base::WeakPtrFactory<WebURLLoaderImpl> weak_factory_; |
| 63 | 63 |
| 64 DISALLOW_COPY_AND_ASSIGN(WebURLLoaderImpl); | 64 DISALLOW_COPY_AND_ASSIGN(WebURLLoaderImpl); |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 } // namespace html_viewer | 67 } // namespace html_viewer |
| 68 | 68 |
| 69 #endif // MOJO_SERVICES_HTML_VIEWER_WEBURLLOADER_IMPL_H_ | 69 #endif // MOJO_SERVICES_HTML_VIEWER_WEBURLLOADER_IMPL_H_ |
| OLD | NEW |