1 // Copyright 2012 The Chromium Authors 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 <memory> 9 10 #include "base/compiler_specific.h" 11 #include "base/memory/raw_ptr.h" 12 #include "base/power_monitor/power_observer.h" 13 #include "base/threading/thread_checker.h" 14 #include "net/base/net_export.h" 15 #include "net/http/http_transaction_factory.h" 16 17 namespace net { 18 19 class HttpNetworkSession; 20 21 class NET_EXPORT HttpNetworkLayer : public HttpTransactionFactory, 22 public base::PowerSuspendObserver { 23 public: 24 // Construct a HttpNetworkLayer with an existing HttpNetworkSession which 25 // contains a valid ProxyResolutionService. The HttpNetworkLayer must be 26 // destroyed before |session|. 27 explicit HttpNetworkLayer(HttpNetworkSession* session); 28 29 HttpNetworkLayer(const HttpNetworkLayer&) = delete; 30 HttpNetworkLayer& operator=(const HttpNetworkLayer&) = delete; 31 32 ~HttpNetworkLayer() override; 33 34 // HttpTransactionFactory methods: 35 int CreateTransaction(RequestPriority priority, 36 std::unique_ptr<HttpTransaction>* trans) override; 37 HttpCache* GetCache() override; 38 HttpNetworkSession* GetSession() override; 39 40 // base::PowerSuspendObserver methods: 41 void OnSuspend() override; 42 void OnResume() override; 43 44 private: 45 const raw_ptr<HttpNetworkSession> session_; 46 bool suspended_ = false; 47 48 THREAD_CHECKER(thread_checker_); 49 }; 50 51 } // namespace net 52 53 #endif // NET_HTTP_HTTP_NETWORK_LAYER_H_ 54