Update mojo sdk to rev 59145288bae55b0fce4276b017df6a1117bcf00f
[chromium-blink-merge.git] / mojo / services / html_viewer / weburlloader_impl.h
blobfd4070d47b51a6a95e78fc77157ce1f4a5ff74a2
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;
18 // The concrete type of WebURLRequest::ExtraData.
19 class WebURLRequestExtraData : public blink::WebURLRequest::ExtraData {
20 public:
21 WebURLRequestExtraData();
22 virtual ~WebURLRequestExtraData();
24 URLResponsePtr synthetic_response;
27 class WebURLLoaderImpl : public blink::WebURLLoader {
28 public:
29 explicit WebURLLoaderImpl(NetworkService* network_service);
31 private:
32 virtual ~WebURLLoaderImpl();
34 // blink::WebURLLoader methods:
35 virtual void loadSynchronously(
36 const blink::WebURLRequest& request, blink::WebURLResponse& response,
37 blink::WebURLError& error, blink::WebData& data) override;
38 virtual void loadAsynchronously(
39 const blink::WebURLRequest&, blink::WebURLLoaderClient* client) override;
40 virtual void cancel() override;
41 virtual void setDefersLoading(bool defers_loading) override;
43 void OnReceivedResponse(URLResponsePtr response);
44 void OnReceivedError(URLResponsePtr response);
45 void OnReceivedRedirect(URLResponsePtr response);
46 void ReadMore();
47 void WaitToReadMore();
48 void OnResponseBodyStreamReady(MojoResult result);
50 blink::WebURLLoaderClient* client_;
51 GURL url_;
52 URLLoaderPtr url_loader_;
53 ScopedDataPipeConsumerHandle response_body_stream_;
54 common::HandleWatcher handle_watcher_;
56 base::WeakPtrFactory<WebURLLoaderImpl> weak_factory_;
58 DISALLOW_COPY_AND_ASSIGN(WebURLLoaderImpl);
61 } // namespace mojo
63 #endif // MOJO_SERVICES_HTML_VIEWER_WEBURLLOADER_IMPL_H_