Upstream version 11.40.277.0
[platform/framework/web/crosswalk.git] / src / content / child / weburlresponse_extradata_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_WEBURLRESPONSE_EXTRADATA_IMPL_H_
6 #define CONTENT_CHILD_WEBURLRESPONSE_EXTRADATA_IMPL_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "content/common/content_export.h"
13 #include "net/http/http_response_info.h"
14 #include "third_party/WebKit/public/platform/WebURLResponse.h"
15
16 namespace content {
17
18 class CONTENT_EXPORT WebURLResponseExtraDataImpl :
19     public NON_EXPORTED_BASE(blink::WebURLResponse::ExtraData) {
20  public:
21   explicit WebURLResponseExtraDataImpl(
22       const std::string& npn_negotiated_protocol);
23   virtual ~WebURLResponseExtraDataImpl();
24
25   const std::string& npn_negotiated_protocol() const {
26     return npn_negotiated_protocol_;
27   }
28
29   // Flag whether this request was loaded via an explicit proxy
30   // (HTTP, SOCKS, etc).
31   bool was_fetched_via_proxy() const {
32     return was_fetched_via_proxy_;
33   }
34   void set_was_fetched_via_proxy(bool was_fetched_via_proxy) {
35     was_fetched_via_proxy_ = was_fetched_via_proxy;
36   }
37
38   // The proxy server used if this request was loaded via an explicit proxy
39   // (HTTP, SOCKS, etc).
40   net::HostPortPair proxy_server() const {
41     return proxy_server_;
42   }
43   void set_proxy_server(net::HostPortPair proxy_server) {
44     proxy_server_ = proxy_server;
45   }
46
47   /// Flag whether this request was loaded via the SPDY protocol or not.
48   // SPDY is an experimental web protocol, see http://dev.chromium.org/spdy
49   bool was_fetched_via_spdy() const {
50     return was_fetched_via_spdy_;
51   }
52   void set_was_fetched_via_spdy(bool was_fetched_via_spdy) {
53     was_fetched_via_spdy_ = was_fetched_via_spdy;
54   }
55
56   // Information about the type of connection used to fetch this response.
57   net::HttpResponseInfo::ConnectionInfo connection_info() const {
58     return connection_info_;
59   }
60   void set_connection_info(
61       net::HttpResponseInfo::ConnectionInfo connection_info) {
62     connection_info_ = connection_info;
63   }
64
65   // Flag whether this request was loaded after the
66   // TLS/Next-Protocol-Negotiation was used.
67   // This is related to SPDY.
68   bool was_npn_negotiated() const {
69     return was_npn_negotiated_;
70   }
71   void set_was_npn_negotiated(bool was_npn_negotiated) {
72     was_npn_negotiated_ = was_npn_negotiated;
73   }
74
75   // Flag whether this request was made when "Alternate-Protocol: xxx"
76   // is present in server's response.
77   bool was_alternate_protocol_available() const {
78     return was_alternate_protocol_available_;
79   }
80   void set_was_alternate_protocol_available(
81       bool was_alternate_protocol_available) {
82     was_alternate_protocol_available_ = was_alternate_protocol_available;
83   }
84
85   bool is_ftp_directory_listing() const { return is_ftp_directory_listing_; }
86   void set_is_ftp_directory_listing(bool is_ftp_directory_listing) {
87     is_ftp_directory_listing_ = is_ftp_directory_listing;
88   }
89
90  private:
91   std::string npn_negotiated_protocol_;
92   bool is_ftp_directory_listing_;
93   bool was_fetched_via_proxy_;
94   net::HostPortPair proxy_server_;
95   bool was_fetched_via_spdy_;
96   bool was_npn_negotiated_;
97   net::HttpResponseInfo::ConnectionInfo connection_info_;
98   bool was_alternate_protocol_available_;
99
100   DISALLOW_COPY_AND_ASSIGN(WebURLResponseExtraDataImpl);
101 };
102
103 }  // namespace content
104
105 #endif  // CONTENT_CHILD_WEBURLRESPONSE_EXTRADATA_IMPL_H_