diff options
author | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-03 19:58:57 +0000 |
---|---|---|
committer | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-03 19:58:57 +0000 |
commit | a0b0d63b60bbc0675115317a0b08ee4183436787 (patch) | |
tree | be1e255eac2d1e176af658d492bfcf2b28d30ae3 /net/base/cookie_store.h | |
parent | b24586704bd0ab21ea365bd75eb6ab0ffc1e00ec (diff) | |
download | chromium_src-a0b0d63b60bbc0675115317a0b08ee4183436787.zip chromium_src-a0b0d63b60bbc0675115317a0b08ee4183436787.tar.gz chromium_src-a0b0d63b60bbc0675115317a0b08ee4183436787.tar.bz2 |
Back out trunk r37998.
Modify CookiePolicy to work asynchronously
This change will enable us to prompt the user before setting a cookie. While we only need to prompt before setting, we actually need to make both CanSetCookie and CanGetCookies asynchronous. This is necessary in order to preserve FIFO ordering since the value returned by GetCookies depends on the changes made to the cookie DB by SetCookie.
This change also includes some simplification of CookieStore. Instead of N virtual functions, I distilled it down to only 4. The remaining functions are instead expressed in terms of those.
While studying all the places where we currently use CookiePolicy, I found that some of them were not appropriate. After discussing with Amit, I decided to remove the policy checks in URLRequestAutomationJob. See the comments in the code regarding this.
I changed the signature of CookieMonster::GetRawCookies to GetAllCookiesForURL to better match GetAllCookies. I also filed a bug about making it even closer in functionality. Related to this change webkit/glue/webcookie.h grows a constructor that takes a CanonicalCookie to help clean up some code.
On the Chrome side, ChromeURLRequestContext now has a ChromeCookiePolicy object. That object is threadsafe ref counted because it is passed between the UI and IO threads. It is responsible for implementing the queuing logic described above. It will also in the future trigger the Chrome UI code to actually show the setcookie prompt.
Please review the state machinery changes in URLRequestHttpJob carefully.
R=eroman
BUG=34331
TEST=no tests yet for prompting.
Review URL: http://codereview.chromium.org/567015
TBR=darin@chromium.org
Review URL: http://codereview.chromium.org/562037
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38002 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/cookie_store.h')
-rw-r--r-- | net/base/cookie_store.h | 58 |
1 files changed, 26 insertions, 32 deletions
diff --git a/net/base/cookie_store.h b/net/base/cookie_store.h index 2fbe1d8..1ea3fa2 100644 --- a/net/base/cookie_store.h +++ b/net/base/cookie_store.h @@ -24,51 +24,45 @@ class CookieMonster; // be thread safe as its methods can be accessed from IO as well as UI threads. class CookieStore : public base::RefCountedThreadSafe<CookieStore> { public: - // Sets a single cookie. Expects a cookie line, like "a=1; domain=b.com". + // Set a single cookie. Expects a cookie line, like "a=1; domain=b.com". + virtual bool SetCookie(const GURL& url, const std::string& cookie_line) = 0; virtual bool SetCookieWithOptions(const GURL& url, const std::string& cookie_line, const CookieOptions& options) = 0; + // Sets a single cookie with a specific creation date. To set a cookie with + // a creation date of Now() use SetCookie() instead (it calls this function + // internally). + virtual bool SetCookieWithCreationTime(const GURL& url, + const std::string& cookie_line, + const base::Time& creation_time) = 0; + virtual bool SetCookieWithCreationTimeWithOptions( + const GURL& url, + const std::string& cookie_line, + const base::Time& creation_time, + const CookieOptions& options) = 0; + // Set a vector of response cookie values for the same URL. + virtual void SetCookies(const GURL& url, + const std::vector<std::string>& cookies) = 0; + virtual void SetCookiesWithOptions(const GURL& url, + const std::vector<std::string>& cookies, + const CookieOptions& options) = 0; // TODO what if the total size of all the cookies >4k, can we have a header // that big or do we need multiple Cookie: headers? - // Simple interface, gets a cookie string "a=b; c=d" for the given URL. - // Use options to access httponly cookies. + // Simple interface, get a cookie string "a=b; c=d" for the given URL. + // It will _not_ return httponly cookies, see CookieOptions. + virtual std::string GetCookies(const GURL& url) = 0; virtual std::string GetCookiesWithOptions(const GURL& url, const CookieOptions& options) = 0; + virtual CookieMonster* GetCookieMonster() { + return NULL; + }; + // Deletes the passed in cookie for the specified URL. virtual void DeleteCookie(const GURL& url, const std::string& cookie_name) = 0; - // Returns the underlying CookieMonster. - virtual CookieMonster* GetCookieMonster() = 0; - - - // -------------------------------------------------------------------------- - // Helpers to make the above interface simpler for some cases. - - // Sets a cookie for the given URL using default options. - bool SetCookie(const GURL& url, const std::string& cookie_line) { - return SetCookieWithOptions(url, cookie_line, CookieOptions()); - } - - // Gets cookies for the given URL using default options. - std::string GetCookies(const GURL& url) { - return GetCookiesWithOptions(url, CookieOptions()); - } - - // Sets a vector of response cookie values for the same URL. - void SetCookiesWithOptions(const GURL& url, - const std::vector<std::string>& cookie_lines, - const CookieOptions& options) { - for (size_t i = 0; i < cookie_lines.size(); ++i) - SetCookieWithOptions(url, cookie_lines[i], options); - } - void SetCookies(const GURL& url, - const std::vector<std::string>& cookie_lines) { - SetCookiesWithOptions(url, cookie_lines, CookieOptions()); - } - protected: friend class base::RefCountedThreadSafe<CookieStore>; virtual ~CookieStore() {} |