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