OLD | NEW |
---|---|
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // This class represents contextual information (cookies, cache, etc.) | 5 // This class represents contextual information (cookies, cache, etc.) |
6 // that's useful when processing resource requests. | 6 // that's useful when processing resource requests. |
7 // The class is reference-counted so that it can be cleaned up after any | 7 // The class is reference-counted so that it can be cleaned up after any |
8 // requests that are using it have been completed. | 8 // requests that are using it have been completed. |
9 | 9 |
10 #ifndef NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ | 10 #ifndef NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ |
11 #define NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ | 11 #define NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ |
12 | 12 |
13 #include <string> | |
14 | |
15 #include "base/basictypes.h" | |
16 #include "base/ref_counted.h" | 13 #include "base/ref_counted.h" |
17 #include "base/scoped_ptr.h" | 14 #include "base/scoped_ptr.h" |
15 #include "base/string_util.h" | |
18 #include "net/base/cookie_policy.h" | 16 #include "net/base/cookie_policy.h" |
19 #include "net/ftp/ftp_auth_cache.h" | 17 #include "net/ftp/ftp_auth_cache.h" |
20 #include "net/http/http_transaction_factory.h" | 18 #include "net/http/http_transaction_factory.h" |
21 | 19 |
22 namespace net { | 20 namespace net { |
23 class CookieMonster; | 21 class CookieMonster; |
24 class ProxyService; | 22 class ProxyService; |
25 } | 23 } |
26 | 24 |
27 // Subclass to provide application-specific context for URLRequest instances. | 25 // Subclass to provide application-specific context for URLRequest instances. |
(...skipping 18 matching lines...) Expand all Loading... | |
46 | 44 |
47 // Gets the cookie store for this context. | 45 // Gets the cookie store for this context. |
48 net::CookieMonster* cookie_store() { return cookie_store_; } | 46 net::CookieMonster* cookie_store() { return cookie_store_; } |
49 | 47 |
50 // Gets the cookie policy for this context. | 48 // Gets the cookie policy for this context. |
51 net::CookiePolicy* cookie_policy() { return &cookie_policy_; } | 49 net::CookiePolicy* cookie_policy() { return &cookie_policy_; } |
52 | 50 |
53 // Gets the FTP authentication cache for this context. | 51 // Gets the FTP authentication cache for this context. |
54 net::FtpAuthCache* ftp_auth_cache() { return &ftp_auth_cache_; } | 52 net::FtpAuthCache* ftp_auth_cache() { return &ftp_auth_cache_; } |
55 | 53 |
56 // Gets the UA string to use for this context. | |
57 const std::string& user_agent() const { return user_agent_; } | |
58 | |
59 // Gets the value of 'Accept-Charset' header field. | 54 // Gets the value of 'Accept-Charset' header field. |
60 const std::string& accept_charset() const { return accept_charset_; } | 55 const std::string& accept_charset() const { return accept_charset_; } |
61 | 56 |
62 // Gets the value of 'Accept-Language' header field. | 57 // Gets the value of 'Accept-Language' header field. |
63 const std::string& accept_language() const { return accept_language_; } | 58 const std::string& accept_language() const { return accept_language_; } |
64 | 59 |
65 // Do not call this directly. TODO(darin): extending from RefCounted* should | 60 // Gets the UA string to use for the given URL. If the given URL is not a |
66 // not require a public destructor! | 61 // valid URL, then the default UA string should be returned. Subclasses |
wtc
2009/01/27 19:19:24
It's not clear what you meant by the "default UA s
darin (slow to review)
2009/01/27 19:52:06
Nice suggestion, thanks.
| |
62 // should override this method to provide a UA string. | |
63 virtual const std::string& GetUserAgent(const GURL& url) const { | |
64 return EmptyString(); | |
65 } | |
66 | |
67 protected: | |
68 friend class base::RefCountedThreadSafe<URLRequestContext>; | |
69 | |
67 virtual ~URLRequestContext() {} | 70 virtual ~URLRequestContext() {} |
wtc
2009/01/27 19:19:24
Just curious: can we make the destructor private?
darin (slow to review)
2009/01/27 19:52:06
yes!
darin (slow to review)
2009/01/27 20:00:11
actually, nevermind. a private destructor prevent
| |
68 | 71 |
69 protected: | |
70 // The following members are expected to be initialized and owned by | 72 // The following members are expected to be initialized and owned by |
71 // subclasses. | 73 // subclasses. |
72 net::ProxyService* proxy_service_; | 74 net::ProxyService* proxy_service_; |
73 net::HttpTransactionFactory* http_transaction_factory_; | 75 net::HttpTransactionFactory* http_transaction_factory_; |
74 net::CookieMonster* cookie_store_; | 76 net::CookieMonster* cookie_store_; |
75 net::CookiePolicy cookie_policy_; | 77 net::CookiePolicy cookie_policy_; |
76 net::FtpAuthCache ftp_auth_cache_; | 78 net::FtpAuthCache ftp_auth_cache_; |
77 std::string user_agent_; | |
78 std::string accept_language_; | 79 std::string accept_language_; |
79 std::string accept_charset_; | 80 std::string accept_charset_; |
80 | 81 |
81 private: | 82 private: |
82 DISALLOW_EVIL_CONSTRUCTORS(URLRequestContext); | 83 DISALLOW_COPY_AND_ASSIGN(URLRequestContext); |
83 }; | 84 }; |
84 | 85 |
85 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ | 86 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ |
86 | |
OLD | NEW |