license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame^] | 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 |
| 3 | // found in the LICENSE file. |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 4 | |
| 5 | // This class represents contextual information (cookies, cache, etc.) |
| 6 | // that's useful when processing resource requests. |
| 7 | // The class is reference-counted so that it can be cleaned up after any |
| 8 | // requests that are using it have been completed. |
| 9 | |
[email protected] | 43530b3 | 2008-08-04 22:21:34 | [diff] [blame] | 10 | #ifndef NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ |
| 11 | #define NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 12 | |
| 13 | #include <string> |
| 14 | |
| 15 | #include "base/basictypes.h" |
| 16 | #include "base/ref_counted.h" |
| 17 | #include "base/scoped_ptr.h" |
| 18 | #include "net/base/auth_cache.h" |
| 19 | #include "net/base/cookie_policy.h" |
| 20 | #include "net/http/http_transaction_factory.h" |
| 21 | |
[email protected] | 8ac1a75 | 2008-07-31 19:40:37 | [diff] [blame] | 22 | namespace net { |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 23 | class CookieMonster; |
[email protected] | 8ac1a75 | 2008-07-31 19:40:37 | [diff] [blame] | 24 | } |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 25 | |
| 26 | // Subclass to provide application-specific context for URLRequest instances. |
| 27 | class URLRequestContext : |
| 28 | public base::RefCountedThreadSafe<URLRequestContext> { |
| 29 | public: |
| 30 | URLRequestContext() |
| 31 | : http_transaction_factory_(NULL), |
| 32 | cookie_store_(NULL), |
| 33 | is_off_the_record_(false) { |
| 34 | } |
| 35 | |
| 36 | // Gets the http transaction factory for this context. |
| 37 | net::HttpTransactionFactory* http_transaction_factory() { |
| 38 | return http_transaction_factory_; |
| 39 | } |
| 40 | |
| 41 | // Gets the cookie store for this context. |
[email protected] | 8ac1a75 | 2008-07-31 19:40:37 | [diff] [blame] | 42 | net::CookieMonster* cookie_store() { return cookie_store_; } |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 43 | |
| 44 | // Gets the cookie policy for this context. |
[email protected] | 8ac1a75 | 2008-07-31 19:40:37 | [diff] [blame] | 45 | net::CookiePolicy* cookie_policy() { return &cookie_policy_; } |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 46 | |
| 47 | // Gets the FTP realm authentication cache for this context. |
[email protected] | a9bb6f69 | 2008-07-30 16:40:10 | [diff] [blame] | 48 | net::AuthCache* ftp_auth_cache() { return &ftp_auth_cache_; } |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 49 | |
| 50 | // Gets the UA string to use for this context. |
| 51 | const std::string& user_agent() const { return user_agent_; } |
| 52 | |
| 53 | // Gets the value of 'Accept-Charset' header field. |
| 54 | const std::string& accept_charset() const { return accept_charset_; } |
| 55 | |
| 56 | // Gets the value of 'Accept-Language' header field. |
| 57 | const std::string& accept_language() const { return accept_language_; } |
| 58 | |
| 59 | // Returns true if this context is off the record. |
| 60 | bool is_off_the_record() { return is_off_the_record_; } |
| 61 | |
| 62 | // Do not call this directly. TODO(darin): extending from RefCounted* should |
| 63 | // not require a public destructor! |
| 64 | virtual ~URLRequestContext() {} |
| 65 | |
| 66 | protected: |
| 67 | // The following members are expected to be initialized and owned by |
| 68 | // subclasses. |
| 69 | net::HttpTransactionFactory* http_transaction_factory_; |
[email protected] | 8ac1a75 | 2008-07-31 19:40:37 | [diff] [blame] | 70 | net::CookieMonster* cookie_store_; |
| 71 | net::CookiePolicy cookie_policy_; |
[email protected] | a9bb6f69 | 2008-07-30 16:40:10 | [diff] [blame] | 72 | net::AuthCache ftp_auth_cache_; |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 73 | std::string user_agent_; |
| 74 | bool is_off_the_record_; |
| 75 | std::string accept_language_; |
| 76 | std::string accept_charset_; |
| 77 | |
| 78 | private: |
| 79 | DISALLOW_EVIL_CONSTRUCTORS(URLRequestContext); |
| 80 | }; |
| 81 | |
[email protected] | 43530b3 | 2008-08-04 22:21:34 | [diff] [blame] | 82 | #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame^] | 83 | |