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