WebKit roll 90808:90810
[chromium-blink-merge.git] / net / url_request / url_request_context_getter.h
blob57406d4425f799dcd27f64cc7f6b939088f9fbae
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_
7 #pragma once
9 #include "base/memory/ref_counted.h"
10 #include "base/task.h"
11 #include "net/base/net_api.h"
13 namespace base {
14 class MessageLoopProxy;
17 namespace net {
18 class CookieStore;
19 class URLRequestContext;
21 struct URLRequestContextGetterTraits;
23 // Interface for retrieving an net::URLRequestContext.
24 class NET_API URLRequestContextGetter
25 : public base::RefCountedThreadSafe<URLRequestContextGetter,
26 URLRequestContextGetterTraits> {
27 public:
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
36 // may be used).
37 virtual scoped_refptr<base::MessageLoopProxy>
38 GetIOMessageLoopProxy() const = 0;
40 protected:
41 friend class base::RefCountedThreadSafe<URLRequestContextGetter,
42 URLRequestContextGetterTraits>;
43 friend class DeleteTask<const URLRequestContextGetter>;
44 friend struct URLRequestContextGetterTraits;
46 URLRequestContextGetter();
47 virtual ~URLRequestContextGetter();
49 private:
50 // OnDestruct is meant to ensure deletion on the thread on which the request
51 // IO happens.
52 void OnDestruct() const;
55 struct URLRequestContextGetterTraits {
56 static void Destruct(const URLRequestContextGetter* context_getter) {
57 context_getter->OnDestruct();
61 } // namespace net
63 #endif // CHROME_COMMON_NET_URL_REQUEST_CONTEXT_GETTER_H_