diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-03 19:19:15 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-03 19:19:15 +0000 |
commit | c7a90eab2f4a045fee103dbfa18710918b368476 (patch) | |
tree | e12ebddacb41a61bb804deff42a504b0361f5544 /net/base/cookie_monster.h | |
parent | 97cdd4667b961cf865047d0bc764764a7c199ce7 (diff) | |
download | chromium_src-c7a90eab2f4a045fee103dbfa18710918b368476.zip chromium_src-c7a90eab2f4a045fee103dbfa18710918b368476.tar.gz chromium_src-c7a90eab2f4a045fee103dbfa18710918b368476.tar.bz2 |
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 thread-safe 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 set-cookie 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
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37998 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/cookie_monster.h')
-rw-r--r-- | net/base/cookie_monster.h | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/net/base/cookie_monster.h b/net/base/cookie_monster.h index 6976f7f..7578c46 100644 --- a/net/base/cookie_monster.h +++ b/net/base/cookie_monster.h @@ -73,30 +73,25 @@ class CookieMonster : public CookieStore { static base::Time ParseCookieTime(const std::string& time_string); // CookieStore implementation. - virtual bool SetCookie(const GURL& url, const std::string& cookie_line); virtual bool SetCookieWithOptions(const GURL& url, const std::string& cookie_line, const CookieOptions& options); - virtual bool SetCookieWithCreationTime(const GURL& url, - const std::string& cookie_line, - const base::Time& creation_time); - virtual bool SetCookieWithCreationTimeWithOptions( - const GURL& url, - const std::string& cookie_line, - const base::Time& creation_time, - const CookieOptions& options); - virtual void SetCookies(const GURL& url, - const std::vector<std::string>& cookies); - virtual void SetCookiesWithOptions(const GURL& url, - const std::vector<std::string>& cookies, - const CookieOptions& options); - virtual std::string GetCookies(const GURL& url); virtual std::string GetCookiesWithOptions(const GURL& url, const CookieOptions& options); virtual void DeleteCookie(const GURL& url, const std::string& cookie_name); - - virtual CookieMonster* GetCookieMonster() { - return this; + virtual CookieMonster* GetCookieMonster() { return this; } + + + // Exposed for unit testing. + bool SetCookieWithCreationTimeAndOptions(const GURL& url, + const std::string& cookie_line, + const base::Time& creation_time, + const CookieOptions& options); + bool SetCookieWithCreationTime(const GURL& url, + const std::string& cookie_line, + const base::Time& creation_time) { + return SetCookieWithCreationTimeAndOptions(url, cookie_line, creation_time, + CookieOptions()); } // Returns all the cookies, for use in management UI, etc. This does not mark @@ -106,7 +101,7 @@ class CookieMonster : public CookieStore { // Returns all the cookies, for use in management UI, etc. Filters results // using given url scheme and host / domain. This does not mark the cookies // as having been accessed. - CookieList GetRawCookies(const GURL& url); + CookieList GetAllCookiesForURL(const GURL& url); // Delete all of the cookies. int DeleteAll(bool sync_to_store); |