Home | History | Annotate | Download | only in http
      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 NET_HTTP_HTTP_NETWORK_LAYER_H_
      6 #define NET_HTTP_HTTP_NETWORK_LAYER_H_
      7 
      8 #include <string>
      9 
     10 #include "base/basictypes.h"
     11 #include "base/compiler_specific.h"
     12 #include "base/memory/ref_counted.h"
     13 #include "base/memory/scoped_ptr.h"
     14 #include "base/power_monitor/power_observer.h"
     15 #include "base/threading/non_thread_safe.h"
     16 #include "net/base/net_export.h"
     17 #include "net/http/http_transaction_factory.h"
     18 
     19 namespace net {
     20 
     21 class HttpNetworkSession;
     22 
     23 class NET_EXPORT HttpNetworkLayer
     24     : public HttpTransactionFactory,
     25       public base::PowerObserver,
     26       NON_EXPORTED_BASE(public base::NonThreadSafe) {
     27  public:
     28   // Construct a HttpNetworkLayer with an existing HttpNetworkSession which
     29   // contains a valid ProxyService.
     30   explicit HttpNetworkLayer(HttpNetworkSession* session);
     31   virtual ~HttpNetworkLayer();
     32 
     33   // Create a transaction factory that instantiate a network layer over an
     34   // existing network session. Network session contains some valuable
     35   // information (e.g. authentication data) that we want to share across
     36   // multiple network layers. This method exposes the implementation details
     37   // of a network layer, use this method with an existing network layer only
     38   // when network session is shared.
     39   static HttpTransactionFactory* CreateFactory(HttpNetworkSession* session);
     40 
     41   // Forces an alternate protocol of SPDY/3 on port 443.
     42   // TODO(rch): eliminate this method.
     43   static void ForceAlternateProtocol();
     44 
     45   // HttpTransactionFactory methods:
     46   virtual int CreateTransaction(RequestPriority priority,
     47                                 scoped_ptr<HttpTransaction>* trans,
     48                                 HttpTransactionDelegate* delegate) OVERRIDE;
     49   virtual HttpCache* GetCache() OVERRIDE;
     50   virtual HttpNetworkSession* GetSession() OVERRIDE;
     51 
     52   // base::PowerObserver methods:
     53   virtual void OnSuspend() OVERRIDE;
     54   virtual void OnResume() OVERRIDE;
     55 
     56  private:
     57   const scoped_refptr<HttpNetworkSession> session_;
     58   bool suspended_;
     59 
     60   DISALLOW_COPY_AND_ASSIGN(HttpNetworkLayer);
     61 };
     62 
     63 }  // namespace net
     64 
     65 #endif  // NET_HTTP_HTTP_NETWORK_LAYER_H_
     66