Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(874)

Side by Side Diff: net/url_request/url_request_context.h

Issue 13701: Use automatic memory management for URLRequestContext's members.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/proxy/proxy_service_unittest.cc ('k') | net/url_request/url_request_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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> 13 #include <string>
14 14
15 #include "base/basictypes.h" 15 #include "base/basictypes.h"
16 #include "base/ref_counted.h" 16 #include "base/ref_counted.h"
17 #include "base/scoped_ptr.h" 17 #include "base/scoped_ptr.h"
18 #include "net/base/auth_cache.h" 18 #include "net/base/auth_cache.h"
19 #include "net/base/cookie_policy.h" 19 #include "net/base/cookie_policy.h"
20 #include "net/http/http_transaction_factory.h" 20 #include "net/http/http_transaction_factory.h"
21 21
22 namespace net { 22 namespace net {
23 class CookieMonster; 23 class CookieMonster;
24 class ProxyService; 24 class ProxyService;
25 } 25 }
26 26
27 // Subclass to provide application-specific context for URLRequest instances. 27 // Subclass to provide application-specific context for URLRequest instances.
28 class URLRequestContext : 28 class URLRequestContext :
29 public base::RefCountedThreadSafe<URLRequestContext> { 29 public base::RefCountedThreadSafe<URLRequestContext> {
30 public: 30 public:
31 URLRequestContext() 31 URLRequestContext();
32 : proxy_service_(NULL), 32
33 http_transaction_factory_(NULL),
34 cookie_store_(NULL),
35 is_off_the_record_(false) {
36 }
37
38 // Get the proxy service for this context. 33 // Get the proxy service for this context.
39 net::ProxyService* proxy_service() const { 34 net::ProxyService* proxy_service() const {
40 return proxy_service_; 35 return proxy_service_;
41 } 36 }
42 37
43 // Gets the http transaction factory for this context. 38 // Gets the http transaction factory for this context.
44 net::HttpTransactionFactory* http_transaction_factory() { 39 net::HttpTransactionFactory* http_transaction_factory() {
45 return http_transaction_factory_; 40 return http_transaction_factory_.get();
46 } 41 }
47 42
48 // Gets the cookie store for this context. 43 // Gets the cookie store for this context.
49 net::CookieMonster* cookie_store() { return cookie_store_; } 44 net::CookieMonster* cookie_store() { return cookie_store_.get(); }
50 45
51 // Gets the cookie policy for this context. 46 // Gets the cookie policy for this context.
52 net::CookiePolicy* cookie_policy() { return &cookie_policy_; } 47 net::CookiePolicy* cookie_policy() { return &cookie_policy_; }
53 48
54 // Gets the FTP realm authentication cache for this context. 49 // Gets the FTP realm authentication cache for this context.
55 net::AuthCache* ftp_auth_cache() { return &ftp_auth_cache_; } 50 net::AuthCache* ftp_auth_cache() { return &ftp_auth_cache_; }
56 51
57 // Gets the UA string to use for this context. 52 // Gets the UA string to use for this context.
58 const std::string& user_agent() const { return user_agent_; } 53 const std::string& user_agent() const { return user_agent_; }
59 54
60 // Gets the value of 'Accept-Charset' header field. 55 // Gets the value of 'Accept-Charset' header field.
61 const std::string& accept_charset() const { return accept_charset_; } 56 const std::string& accept_charset() const { return accept_charset_; }
62 57
63 // Gets the value of 'Accept-Language' header field. 58 // Gets the value of 'Accept-Language' header field.
64 const std::string& accept_language() const { return accept_language_; } 59 const std::string& accept_language() const { return accept_language_; }
65 60
66 // Returns true if this context is off the record. 61 // Returns true if this context is off the record.
67 bool is_off_the_record() { return is_off_the_record_; } 62 bool is_off_the_record() { return is_off_the_record_; }
68 63
69 // Do not call this directly. TODO(darin): extending from RefCounted* should 64 // Do not call this directly. TODO(darin): extending from RefCounted* should
70 // not require a public destructor! 65 // not require a public destructor!
71 virtual ~URLRequestContext() {} 66 virtual ~URLRequestContext();
72 67
73 protected: 68 protected:
74 // The following members are expected to be initialized and owned by 69 // The following members are expected to be initialized by subclasses.
75 // subclasses. 70 scoped_refptr<net::ProxyService> proxy_service_;
76 net::ProxyService* proxy_service_; 71 scoped_ptr<net::HttpTransactionFactory> http_transaction_factory_;
77 net::HttpTransactionFactory* http_transaction_factory_; 72 scoped_ptr<net::CookieMonster> cookie_store_;
78 net::CookieMonster* cookie_store_;
79 net::CookiePolicy cookie_policy_; 73 net::CookiePolicy cookie_policy_;
80 net::AuthCache ftp_auth_cache_; 74 net::AuthCache ftp_auth_cache_;
81 std::string user_agent_; 75 std::string user_agent_;
82 bool is_off_the_record_; 76 bool is_off_the_record_;
83 std::string accept_language_; 77 std::string accept_language_;
84 std::string accept_charset_; 78 std::string accept_charset_;
85 79
86 private: 80 private:
87 DISALLOW_EVIL_CONSTRUCTORS(URLRequestContext); 81 DISALLOW_EVIL_CONSTRUCTORS(URLRequestContext);
88 }; 82 };
89 83
90 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ 84 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_
91 85
OLDNEW
« no previous file with comments | « net/proxy/proxy_service_unittest.cc ('k') | net/url_request/url_request_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698