OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_BROWSER_NET_URL_REQUEST_CONTEXT_GETTER_H_ | 5 #ifndef CHROME_BROWSER_NET_URL_REQUEST_CONTEXT_GETTER_H_ |
6 #define CHROME_BROWSER_NET_URL_REQUEST_CONTEXT_GETTER_H_ | 6 #define CHROME_BROWSER_NET_URL_REQUEST_CONTEXT_GETTER_H_ |
7 | 7 |
8 #include "base/ref_counted.h" | 8 #include "base/ref_counted.h" |
9 #include "base/task.h" | 9 #include "base/task.h" |
10 | 10 |
| 11 namespace base { |
| 12 class MessageLoopProxy; |
| 13 } |
| 14 |
11 namespace net { | 15 namespace net { |
12 class CookieStore; | 16 class CookieStore; |
13 } | 17 } |
14 | 18 |
15 class MessageLoopProxy; | |
16 class URLRequestContext; | 19 class URLRequestContext; |
17 struct URLRequestContextGetterTraits; | 20 struct URLRequestContextGetterTraits; |
18 | 21 |
19 // Interface for retrieving an URLRequestContext. | 22 // Interface for retrieving an URLRequestContext. |
20 class URLRequestContextGetter | 23 class URLRequestContextGetter |
21 : public base::RefCountedThreadSafe<URLRequestContextGetter, | 24 : public base::RefCountedThreadSafe<URLRequestContextGetter, |
22 URLRequestContextGetterTraits> { | 25 URLRequestContextGetterTraits> { |
23 public: | 26 public: |
24 virtual URLRequestContext* GetURLRequestContext() = 0; | 27 virtual URLRequestContext* GetURLRequestContext() = 0; |
25 | 28 |
26 // Defaults to GetURLRequestContext()->cookie_store(), but | 29 // Defaults to GetURLRequestContext()->cookie_store(), but |
27 // implementations can override it. | 30 // implementations can override it. |
28 virtual net::CookieStore* GetCookieStore(); | 31 virtual net::CookieStore* GetCookieStore(); |
29 // Returns a MessageLoopProxy corresponding to the thread on which the | 32 // Returns a MessageLoopProxy corresponding to the thread on which the |
30 // request IO happens (the thread on which the returned URLRequestContext | 33 // request IO happens (the thread on which the returned URLRequestContext |
31 // may be used). | 34 // may be used). |
32 virtual scoped_refptr<MessageLoopProxy> GetIOMessageLoopProxy() = 0; | 35 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() = 0; |
33 | 36 |
34 protected: | 37 protected: |
35 friend class DeleteTask<URLRequestContextGetter>; | 38 friend class DeleteTask<URLRequestContextGetter>; |
36 friend struct URLRequestContextGetterTraits; | 39 friend struct URLRequestContextGetterTraits; |
37 | 40 |
38 virtual ~URLRequestContextGetter() {} | 41 virtual ~URLRequestContextGetter() {} |
39 private: | 42 private: |
40 // OnDestruct is meant to ensure deletion on the thread on which the request | 43 // OnDestruct is meant to ensure deletion on the thread on which the request |
41 // IO happens. | 44 // IO happens. |
42 void OnDestruct(); | 45 void OnDestruct(); |
43 }; | 46 }; |
44 | 47 |
45 struct URLRequestContextGetterTraits { | 48 struct URLRequestContextGetterTraits { |
46 static void Destruct(URLRequestContextGetter* context_getter) { | 49 static void Destruct(URLRequestContextGetter* context_getter) { |
47 context_getter->OnDestruct(); | 50 context_getter->OnDestruct(); |
48 } | 51 } |
49 }; | 52 }; |
50 | 53 |
51 #endif // CHROME_BROWSER_NET_URL_REQUEST_CONTEXT_GETTER_H_ | 54 #endif // CHROME_BROWSER_NET_URL_REQUEST_CONTEXT_GETTER_H_ |
52 | 55 |
OLD | NEW |