Port Android relocation packer to chromium build
[chromium-blink-merge.git] / mojo / services / html_viewer / weburlloader_impl.h
blobecfe6c08b35f33fc946506caa20a96a237ac7a6c
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.
5 #ifndef MOJO_SERVICES_HTML_VIEWER_WEBURLLOADER_IMPL_H_
6 #define MOJO_SERVICES_HTML_VIEWER_WEBURLLOADER_IMPL_H_
8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h"
10 #include "mojo/common/handle_watcher.h"
11 #include "mojo/services/network/public/interfaces/url_loader.mojom.h"
12 #include "third_party/WebKit/public/platform/WebURLLoader.h"
13 #include "third_party/WebKit/public/platform/WebURLRequest.h"
15 namespace mojo {
16 class NetworkService;
19 namespace html_viewer {
21 // The concrete type of WebURLRequest::ExtraData.
22 class WebURLRequestExtraData : public blink::WebURLRequest::ExtraData {
23 public:
24 WebURLRequestExtraData();
25 virtual ~WebURLRequestExtraData();
27 mojo::URLResponsePtr synthetic_response;
30 class WebURLLoaderImpl : public blink::WebURLLoader {
31 public:
32 explicit WebURLLoaderImpl(mojo::NetworkService* network_service);
34 private:
35 virtual ~WebURLLoaderImpl();
37 // blink::WebURLLoader methods:
38 virtual void loadSynchronously(
39 const blink::WebURLRequest& request, blink::WebURLResponse& response,
40 blink::WebURLError& error, blink::WebData& data) override;
41 virtual void loadAsynchronously(
42 const blink::WebURLRequest&, blink::WebURLLoaderClient* client) override;
43 virtual void cancel() override;
44 virtual void setDefersLoading(bool defers_loading) override;
46 void OnReceivedResponse(mojo::URLResponsePtr response);
47 void OnReceivedError(mojo::URLResponsePtr response);
48 void OnReceivedRedirect(mojo::URLResponsePtr response);
49 void ReadMore();
50 void WaitToReadMore();
51 void OnResponseBodyStreamReady(MojoResult result);
53 blink::WebURLLoaderClient* client_;
54 GURL url_;
55 mojo::URLLoaderPtr url_loader_;
56 mojo::ScopedDataPipeConsumerHandle response_body_stream_;
57 mojo::common::HandleWatcher handle_watcher_;
59 base::WeakPtrFactory<WebURLLoaderImpl> weak_factory_;
61 DISALLOW_COPY_AND_ASSIGN(WebURLLoaderImpl);
64 } // namespace html_viewer
66 #endif // MOJO_SERVICES_HTML_VIEWER_WEBURLLOADER_IMPL_H_