| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_COMMON_NET_URL_REQUEST_CONTEXT_GETTER_H_ | 5 #ifndef CHROME_COMMON_NET_URL_REQUEST_CONTEXT_GETTER_H_ |
| 6 #define CHROME_COMMON_NET_URL_REQUEST_CONTEXT_GETTER_H_ | 6 #define CHROME_COMMON_NET_URL_REQUEST_CONTEXT_GETTER_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/sequenced_task_runner_helpers.h" | 9 #include "base/sequenced_task_runner_helpers.h" |
| 10 #include "net/base/net_export.h" | 10 #include "net/base/net_export.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 // Interface for retrieving an net::URLRequestContext. | 22 // Interface for retrieving an net::URLRequestContext. |
| 23 class NET_EXPORT URLRequestContextGetter | 23 class NET_EXPORT URLRequestContextGetter |
| 24 : public base::RefCountedThreadSafe<URLRequestContextGetter, | 24 : public base::RefCountedThreadSafe<URLRequestContextGetter, |
| 25 URLRequestContextGetterTraits> { | 25 URLRequestContextGetterTraits> { |
| 26 public: | 26 public: |
| 27 virtual URLRequestContext* GetURLRequestContext() = 0; | 27 virtual URLRequestContext* GetURLRequestContext() = 0; |
| 28 | 28 |
| 29 // Returns a SingleThreadTaskRunner corresponding to the thread on | 29 // Returns a SingleThreadTaskRunner corresponding to the thread on |
| 30 // which the network IO happens (the thread on which the returned | 30 // which the network IO happens (the thread on which the returned |
| 31 // net::URLRequestContext may be used). | 31 // net::URLRequestContext may be used). |
| 32 virtual scoped_refptr<base::SingleThreadTaskRunner> | 32 virtual scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() |
| 33 GetNetworkTaskRunner() const = 0; | 33 const = 0; |
| 34 | 34 |
| 35 protected: | 35 protected: |
| 36 friend class base::RefCountedThreadSafe<URLRequestContextGetter, | 36 friend class base::RefCountedThreadSafe<URLRequestContextGetter, |
| 37 URLRequestContextGetterTraits>; | 37 URLRequestContextGetterTraits>; |
| 38 friend class base::DeleteHelper<URLRequestContextGetter>; | 38 friend class base::DeleteHelper<URLRequestContextGetter>; |
| 39 friend struct URLRequestContextGetterTraits; | 39 friend struct URLRequestContextGetterTraits; |
| 40 | 40 |
| 41 URLRequestContextGetter(); | 41 URLRequestContextGetter(); |
| 42 virtual ~URLRequestContextGetter(); | 42 virtual ~URLRequestContextGetter(); |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 // OnDestruct is meant to ensure deletion on the thread on which the request | 45 // OnDestruct is meant to ensure deletion on the thread on which the request |
| 46 // IO happens. | 46 // IO happens. |
| 47 void OnDestruct() const; | 47 void OnDestruct() const; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 struct URLRequestContextGetterTraits { | 50 struct URLRequestContextGetterTraits { |
| 51 static void Destruct(const URLRequestContextGetter* context_getter) { | 51 static void Destruct(const URLRequestContextGetter* context_getter) { |
| 52 context_getter->OnDestruct(); | 52 context_getter->OnDestruct(); |
| 53 } | 53 } |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 } // namespace net | 56 } // namespace net |
| 57 | 57 |
| 58 #endif // CHROME_COMMON_NET_URL_REQUEST_CONTEXT_GETTER_H_ | 58 #endif // CHROME_COMMON_NET_URL_REQUEST_CONTEXT_GETTER_H_ |
| OLD | NEW |