| OLD | NEW |
| (Empty) |
| 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 MOJO_SERVICES_NETWORK_NETWORK_CONTEXT_H_ | |
| 6 #define MOJO_SERVICES_NETWORK_NETWORK_CONTEXT_H_ | |
| 7 | |
| 8 #include <stddef.h> | |
| 9 | |
| 10 #include <set> | |
| 11 | |
| 12 #include "base/macros.h" | |
| 13 #include "base/memory/ref_counted.h" | |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 #include "base/sequenced_task_runner.h" | |
| 16 | |
| 17 namespace base { | |
| 18 class FilePath; | |
| 19 } | |
| 20 | |
| 21 namespace net { | |
| 22 class URLRequestContext; | |
| 23 } | |
| 24 | |
| 25 namespace mojo { | |
| 26 class URLLoader; | |
| 27 class URLLoaderImpl; | |
| 28 class NetworkServiceDelegate; | |
| 29 | |
| 30 class NetworkContext { | |
| 31 public: | |
| 32 explicit NetworkContext( | |
| 33 scoped_ptr<net::URLRequestContext> url_request_context); | |
| 34 NetworkContext( | |
| 35 const base::FilePath& base_path, | |
| 36 NetworkServiceDelegate* delegate); | |
| 37 ~NetworkContext(); | |
| 38 | |
| 39 net::URLRequestContext* url_request_context() { | |
| 40 return url_request_context_.get(); | |
| 41 } | |
| 42 | |
| 43 // These are called by individual url loaders as they are being created and | |
| 44 // destroyed. | |
| 45 void RegisterURLLoader(URLLoaderImpl* url_loader); | |
| 46 void DeregisterURLLoader(URLLoaderImpl* url_loader); | |
| 47 | |
| 48 private: | |
| 49 friend class UrlLoaderImplTest; | |
| 50 size_t GetURLLoaderCountForTesting(); | |
| 51 | |
| 52 static scoped_ptr<net::URLRequestContext> MakeURLRequestContext( | |
| 53 const base::FilePath& base_path, | |
| 54 NetworkServiceDelegate* delegate); | |
| 55 | |
| 56 class MojoNetLog; | |
| 57 scoped_ptr<class MojoNetLog> net_log_; | |
| 58 | |
| 59 scoped_ptr<net::URLRequestContext> url_request_context_; | |
| 60 // URLLoaderImpls register themselves with the NetworkContext so that they can | |
| 61 // be cleaned up when the NetworkContext goes away. This is needed as | |
| 62 // net::URLRequests held by URLLoaderImpls have to be gone when | |
| 63 // net::URLRequestContext (held by NetworkContext) is destroyed. | |
| 64 std::set<URLLoaderImpl*> url_loaders_; | |
| 65 | |
| 66 // Set when entering the destructor, in order to avoid manipulations of the | |
| 67 // |url_loaders_| (as a url_loader might delete itself in Cleanup()). | |
| 68 bool in_shutdown_; | |
| 69 | |
| 70 DISALLOW_COPY_AND_ASSIGN(NetworkContext); | |
| 71 }; | |
| 72 | |
| 73 } // namespace mojo | |
| 74 | |
| 75 #endif // MOJO_SERVICES_NETWORK_NETWORK_CONTEXT_H_ | |
| OLD | NEW |