blob: 2cab5345d0b5ccb6f6917f0187f1387da69f1a2e [file] [log] [blame]
license.botbf09a502008-08-24 00:55:551// 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.commit586acc5fe2008-07-26 22:42:524
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]43530b32008-08-04 22:21:3410#ifndef NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_
11#define NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_
initial.commit586acc5fe2008-07-26 22:42:5212
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]8ac1a752008-07-31 19:40:3722namespace net {
initial.commit586acc5fe2008-07-26 22:42:5223class CookieMonster;
[email protected]8ac1a752008-07-31 19:40:3724}
initial.commit586acc5fe2008-07-26 22:42:5225
26// Subclass to provide application-specific context for URLRequest instances.
27class 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]8ac1a752008-07-31 19:40:3742 net::CookieMonster* cookie_store() { return cookie_store_; }
initial.commit586acc5fe2008-07-26 22:42:5243
44 // Gets the cookie policy for this context.
[email protected]8ac1a752008-07-31 19:40:3745 net::CookiePolicy* cookie_policy() { return &cookie_policy_; }
initial.commit586acc5fe2008-07-26 22:42:5246
47 // Gets the FTP realm authentication cache for this context.
[email protected]a9bb6f692008-07-30 16:40:1048 net::AuthCache* ftp_auth_cache() { return &ftp_auth_cache_; }
initial.commit586acc5fe2008-07-26 22:42:5249
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]8ac1a752008-07-31 19:40:3770 net::CookieMonster* cookie_store_;
71 net::CookiePolicy cookie_policy_;
[email protected]a9bb6f692008-07-30 16:40:1072 net::AuthCache ftp_auth_cache_;
initial.commit586acc5fe2008-07-26 22:42:5273 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]43530b32008-08-04 22:21:3482#endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_
license.botbf09a502008-08-24 00:55:5583