1 // Copyright (c) 2011 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.
5 #ifndef CHROME_COMMON_NET_URL_REQUEST_CONTEXT_GETTER_H_
6 #define CHROME_COMMON_NET_URL_REQUEST_CONTEXT_GETTER_H_
9 #include "base/memory/ref_counted.h"
10 #include "base/task.h"
11 #include "net/base/net_export.h"
14 class MessageLoopProxy
;
19 class URLRequestContext
;
21 struct URLRequestContextGetterTraits
;
23 // Interface for retrieving an net::URLRequestContext.
24 class NET_EXPORT URLRequestContextGetter
25 : public base::RefCountedThreadSafe
<URLRequestContextGetter
,
26 URLRequestContextGetterTraits
> {
28 virtual URLRequestContext
* GetURLRequestContext() = 0;
30 // See http://crbug.com/77835 for why this shouldn't be used. Instead use
31 // GetURLRequestContext()->cookie_store();
32 virtual CookieStore
* DONTUSEME_GetCookieStore();
34 // Returns a MessageLoopProxy corresponding to the thread on which the
35 // request IO happens (the thread on which the returned net::URLRequestContext
37 virtual scoped_refptr
<base::MessageLoopProxy
>
38 GetIOMessageLoopProxy() const = 0;
41 friend class base::RefCountedThreadSafe
<URLRequestContextGetter
,
42 URLRequestContextGetterTraits
>;
43 friend class DeleteTask
<const URLRequestContextGetter
>;
44 friend struct URLRequestContextGetterTraits
;
46 URLRequestContextGetter();
47 virtual ~URLRequestContextGetter();
50 // OnDestruct is meant to ensure deletion on the thread on which the request
52 void OnDestruct() const;
55 struct URLRequestContextGetterTraits
{
56 static void Destruct(const URLRequestContextGetter
* context_getter
) {
57 context_getter
->OnDestruct();
63 #endif // CHROME_COMMON_NET_URL_REQUEST_CONTEXT_GETTER_H_