Use scoped_ptr::Pass instead of scoped_ptr::PassAs<T>.
[chromium-blink-merge.git] / mojo / services / html_viewer / weburlloader_impl.h
blob6bb30dfacfff194b2c6ae8fff4d8b6563c17e1fd
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/public/interfaces/network/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_