Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / content / child / web_url_loader_impl.h
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 CONTENT_CHILD_WEB_URL_LOADER_IMPL_H_
6 #define CONTENT_CHILD_WEB_URL_LOADER_IMPL_H_
7
8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
10 #include "content/common/content_export.h"
11 #include "content/public/common/resource_response.h"
12 #include "third_party/WebKit/public/platform/WebURLLoader.h"
13 #include "url/gurl.h"
14
15 namespace content {
16
17 class ResourceDispatcher;
18 struct ResourceResponseInfo;
19
20 // PlzNavigate: Used to override parameters of the navigation request.
21 struct StreamOverrideParameters {
22  public:
23   // TODO(clamy): The browser should be made aware on destruction of this struct
24   // that it can release its associated stream handle.
25   GURL stream_url;
26   ResourceResponseHead response;
27 };
28
29 class CONTENT_EXPORT WebURLLoaderImpl
30     : public NON_EXPORTED_BASE(blink::WebURLLoader) {
31  public:
32   explicit WebURLLoaderImpl(ResourceDispatcher* resource_dispatcher);
33   virtual ~WebURLLoaderImpl();
34
35   static blink::WebURLError CreateError(const blink::WebURL& unreachable_url,
36                                         bool stale_copy_in_cache,
37                                         int reason);
38   static void PopulateURLResponse(
39       const GURL& url,
40       const ResourceResponseInfo& info,
41       blink::WebURLResponse* response);
42
43   // WebURLLoader methods:
44   virtual void loadSynchronously(
45       const blink::WebURLRequest& request,
46       blink::WebURLResponse& response,
47       blink::WebURLError& error,
48       blink::WebData& data) override;
49   virtual void loadAsynchronously(
50       const blink::WebURLRequest& request,
51       blink::WebURLLoaderClient* client) override;
52   virtual void cancel() override;
53   virtual void setDefersLoading(bool value) override;
54   virtual void didChangePriority(blink::WebURLRequest::Priority new_priority,
55                                  int intra_priority_value) override;
56   virtual bool attachThreadedDataReceiver(
57       blink::WebThreadedDataReceiver* threaded_data_receiver) override;
58
59  private:
60   class Context;
61   scoped_refptr<Context> context_;
62
63   DISALLOW_COPY_AND_ASSIGN(WebURLLoaderImpl);
64 };
65
66 }  // namespace content
67
68 #endif  // CONTENT_CHILD_WEB_URL_LOADER_IMPL_H_