OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 // Brought to you by number 42. | 5 // Brought to you by number 42. |
6 | 6 |
7 #ifndef NET_BASE_COOKIE_STORE_H_ | 7 #ifndef NET_BASE_COOKIE_STORE_H_ |
8 #define NET_BASE_COOKIE_STORE_H_ | 8 #define NET_BASE_COOKIE_STORE_H_ |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/ref_counted.h" | 13 #include "base/ref_counted.h" |
14 #include "base/time.h" | 14 #include "base/time.h" |
15 #include "net/base/cookie_options.h" | 15 #include "net/base/cookie_options.h" |
16 | 16 |
17 class GURL; | 17 class GURL; |
18 | 18 |
19 namespace net { | 19 namespace net { |
20 | 20 |
21 class CookieMonster; | 21 class CookieMonster; |
22 | 22 |
23 // An interface for storing and retrieving cookies. Implementations need to | 23 // An interface for storing and retrieving cookies. Implementations need to |
24 // be thread safe as its methods can be accessed from IO as well as UI threads. | 24 // be thread safe as its methods can be accessed from IO as well as UI threads. |
25 class CookieStore : public base::RefCountedThreadSafe<CookieStore> { | 25 class CookieStore : public base::RefCountedThreadSafe<CookieStore> { |
26 public: | 26 public: |
27 virtual ~CookieStore() {} | |
28 | |
29 // Set a single cookie. Expects a cookie line, like "a=1; domain=b.com". | 27 // Set a single cookie. Expects a cookie line, like "a=1; domain=b.com". |
30 virtual bool SetCookie(const GURL& url, const std::string& cookie_line) = 0; | 28 virtual bool SetCookie(const GURL& url, const std::string& cookie_line) = 0; |
31 virtual bool SetCookieWithOptions(const GURL& url, | 29 virtual bool SetCookieWithOptions(const GURL& url, |
32 const std::string& cookie_line, | 30 const std::string& cookie_line, |
33 const CookieOptions& options) = 0; | 31 const CookieOptions& options) = 0; |
34 // Sets a single cookie with a specific creation date. To set a cookie with | 32 // Sets a single cookie with a specific creation date. To set a cookie with |
35 // a creation date of Now() use SetCookie() instead (it calls this function | 33 // a creation date of Now() use SetCookie() instead (it calls this function |
36 // internally). | 34 // internally). |
37 virtual bool SetCookieWithCreationTime(const GURL& url, | 35 virtual bool SetCookieWithCreationTime(const GURL& url, |
38 const std::string& cookie_line, | 36 const std::string& cookie_line, |
(...skipping 14 matching lines...) Expand all Loading... |
53 // that big or do we need multiple Cookie: headers? | 51 // that big or do we need multiple Cookie: headers? |
54 // Simple interface, get a cookie string "a=b; c=d" for the given URL. | 52 // Simple interface, get a cookie string "a=b; c=d" for the given URL. |
55 // It will _not_ return httponly cookies, see CookieOptions. | 53 // It will _not_ return httponly cookies, see CookieOptions. |
56 virtual std::string GetCookies(const GURL& url) = 0; | 54 virtual std::string GetCookies(const GURL& url) = 0; |
57 virtual std::string GetCookiesWithOptions(const GURL& url, | 55 virtual std::string GetCookiesWithOptions(const GURL& url, |
58 const CookieOptions& options) = 0; | 56 const CookieOptions& options) = 0; |
59 | 57 |
60 virtual CookieMonster* GetCookieMonster() { | 58 virtual CookieMonster* GetCookieMonster() { |
61 return NULL; | 59 return NULL; |
62 }; | 60 }; |
| 61 |
| 62 protected: |
| 63 friend class base::RefCountedThreadSafe<CookieStore>; |
| 64 virtual ~CookieStore() {} |
63 }; | 65 }; |
64 | 66 |
65 } // namespace net | 67 } // namespace net |
66 | 68 |
67 #endif // NET_BASE_COOKIE_STORE_H_ | 69 #endif // NET_BASE_COOKIE_STORE_H_ |
OLD | NEW |