OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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_NETWORK_NETWORK_CONTEXT_H_ |
| 6 #define CONTENT_NETWORK_NETWORK_CONTEXT_H_ |
| 7 |
| 8 #include <stdint.h> |
| 9 |
| 10 #include <memory> |
| 11 #include <set> |
| 12 |
| 13 #include "base/macros.h" |
| 14 #include "content/common/content_export.h" |
| 15 |
| 16 namespace net { |
| 17 class URLRequestContext; |
| 18 } |
| 19 |
| 20 namespace content { |
| 21 class URLLoaderImpl; |
| 22 |
| 23 class CONTENT_EXPORT NetworkContext { |
| 24 public: |
| 25 NetworkContext(); |
| 26 ~NetworkContext(); |
| 27 |
| 28 net::URLRequestContext* url_request_context() { |
| 29 return url_request_context_.get(); |
| 30 } |
| 31 |
| 32 // These are called by individual url loaders as they are being created and |
| 33 // destroyed. |
| 34 void RegisterURLLoader(URLLoaderImpl* url_loader); |
| 35 void DeregisterURLLoader(URLLoaderImpl* url_loader); |
| 36 |
| 37 private: |
| 38 class MojoNetLog; |
| 39 std::unique_ptr<MojoNetLog> net_log_; |
| 40 |
| 41 std::unique_ptr<net::URLRequestContext> url_request_context_; |
| 42 |
| 43 // URLLoaderImpls register themselves with the NetworkContext so that they can |
| 44 // be cleaned up when the NetworkContext goes away. This is needed as |
| 45 // net::URLRequests held by URLLoaderImpls have to be gone when |
| 46 // net::URLRequestContext (held by NetworkContext) is destroyed. |
| 47 std::set<URLLoaderImpl*> url_loaders_; |
| 48 |
| 49 // Set when entering the destructor, in order to avoid manipulations of the |
| 50 // |url_loaders_| (as a url_loader might delete itself in Cleanup()). |
| 51 bool in_shutdown_; |
| 52 |
| 53 DISALLOW_COPY_AND_ASSIGN(NetworkContext); |
| 54 }; |
| 55 |
| 56 } // namespace content |
| 57 |
| 58 #endif // CONTENT_NETWORK_NETWORK_CONTEXT_H_ |
OLD | NEW |