Home | History | Annotate | Download | only in child
      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   /// Flag whether this request was loaded via the SPDY protocol or not.
     39   // SPDY is an experimental web protocol, see http://dev.chromium.org/spdy
     40   bool was_fetched_via_spdy() const {
     41     return was_fetched_via_spdy_;
     42   }
     43   void set_was_fetched_via_spdy(bool was_fetched_via_spdy) {
     44     was_fetched_via_spdy_ = was_fetched_via_spdy;
     45   }
     46 
     47   // Information about the type of connection used to fetch this response.
     48   net::HttpResponseInfo::ConnectionInfo connection_info() const {
     49     return connection_info_;
     50   }
     51   void set_connection_info(
     52       net::HttpResponseInfo::ConnectionInfo connection_info) {
     53     connection_info_ = connection_info;
     54   }
     55 
     56   // Flag whether this request was loaded after the
     57   // TLS/Next-Protocol-Negotiation was used.
     58   // This is related to SPDY.
     59   bool was_npn_negotiated() const {
     60     return was_npn_negotiated_;
     61   }
     62   void set_was_npn_negotiated(bool was_npn_negotiated) {
     63     was_npn_negotiated_ = was_npn_negotiated;
     64   }
     65 
     66   // Flag whether this request was made when "Alternate-Protocol: xxx"
     67   // is present in server's response.
     68   bool was_alternate_protocol_available() const {
     69     return was_alternate_protocol_available_;
     70   }
     71   void set_was_alternate_protocol_available(
     72       bool was_alternate_protocol_available) {
     73     was_alternate_protocol_available_ = was_alternate_protocol_available;
     74   }
     75 
     76   bool is_ftp_directory_listing() const { return is_ftp_directory_listing_; }
     77   void set_is_ftp_directory_listing(bool is_ftp_directory_listing) {
     78     is_ftp_directory_listing_ = is_ftp_directory_listing;
     79   }
     80 
     81  private:
     82   std::string npn_negotiated_protocol_;
     83   bool is_ftp_directory_listing_;
     84   bool was_fetched_via_proxy_;
     85   bool was_fetched_via_spdy_;
     86   bool was_npn_negotiated_;
     87   net::HttpResponseInfo::ConnectionInfo connection_info_;
     88   bool was_alternate_protocol_available_;
     89 
     90   DISALLOW_COPY_AND_ASSIGN(WebURLResponseExtraDataImpl);
     91 };
     92 
     93 }  // namespace content
     94 
     95 #endif  // CONTENT_CHILD_WEBURLRESPONSE_EXTRADATA_IMPL_H_
     96