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