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