summaryrefslogtreecommitdiffstats
path: root/ios/net
diff options
context:
space:
mode:
authormmenke <mmenke@chromium.org>2016-02-05 12:53:24 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-05 20:59:24 +0000
commitfdd4fc741f5797719784f46799051c31e50ce09f (patch)
treee6386161a31b09d0d39c2778b9b648aebe12b19a /ios/net
parent7492a5fcb13ad3236e5251eb2ea0776c730e50b0 (diff)
downloadchromium_src-fdd4fc741f5797719784f46799051c31e50ce09f.zip
chromium_src-fdd4fc741f5797719784f46799051c31e50ce09f.tar.gz
chromium_src-fdd4fc741f5797719784f46799051c31e50ce09f.tar.bz2
Remove ImportCookies from CookieMonster interface.
Consumers now use CookieStore::SetCookieWithDetailsAsync. The old method grabbed a mutex and synchronously set all cookies. It's the only cookie method that did that, and it's unclear why. With the new code, the cookies won't be set until any old matching cookie has already been loaded from the store, which will then be overwritten. With the old code, that didn't happen, and it's unclear if the code was actually correct. This also adds an argument to SetCookieWithDetailsAsync: last_access_time, to better match old behavior. TBR=bauerb@chromium.org BUG=579653 Review URL: https://codereview.chromium.org/1663473002 Cr-Commit-Position: refs/heads/master@{#373902}
Diffstat (limited to 'ios/net')
-rw-r--r--ios/net/cookies/cookie_store_ios.h5
-rw-r--r--ios/net/cookies/cookie_store_ios.mm28
-rw-r--r--ios/net/cookies/cookie_store_ios_unittest.mm10
3 files changed, 23 insertions, 20 deletions
diff --git a/ios/net/cookies/cookie_store_ios.h b/ios/net/cookies/cookie_store_ios.h
index 6d34c67..36f92e3 100644
--- a/ios/net/cookies/cookie_store_ios.h
+++ b/ios/net/cookies/cookie_store_ios.h
@@ -124,8 +124,9 @@ class CookieStoreIOS : public net::CookieStore,
const std::string& value,
const std::string& domain,
const std::string& path,
- const base::Time creation_time,
- const base::Time expiration_time,
+ base::Time creation_time,
+ base::Time expiration_time,
+ base::Time last_access_time,
bool secure,
bool http_only,
bool same_site,
diff --git a/ios/net/cookies/cookie_store_ios.mm b/ios/net/cookies/cookie_store_ios.mm
index 0162799..519c129 100644
--- a/ios/net/cookies/cookie_store_ios.mm
+++ b/ios/net/cookies/cookie_store_ios.mm
@@ -435,8 +435,9 @@ void CookieStoreIOS::SetCookieWithDetailsAsync(
const std::string& value,
const std::string& domain,
const std::string& path,
- const base::Time creation_time,
- const base::Time expiration_time,
+ base::Time creation_time,
+ base::Time expiration_time,
+ base::Time last_access_time,
bool secure,
bool http_only,
bool same_site,
@@ -449,15 +450,15 @@ void CookieStoreIOS::SetCookieWithDetailsAsync(
case NOT_SYNCHRONIZED:
cookie_monster_->SetCookieWithDetailsAsync(
url, name, value, domain, path, creation_time, expiration_time,
- secure, http_only, same_site, enforce_strict_secure, priority,
- WrapSetCallback(callback));
+ last_access_time, secure, http_only, same_site, enforce_strict_secure,
+ priority, WrapSetCallback(callback));
break;
case SYNCHRONIZING:
- tasks_pending_synchronization_.push_back(
- base::Bind(&CookieStoreIOS::SetCookieWithDetailsAsync, this, url,
- name, value, domain, path, creation_time, expiration_time,
- secure, http_only, same_site, enforce_strict_secure,
- priority, WrapSetCallback(callback)));
+ tasks_pending_synchronization_.push_back(base::Bind(
+ &CookieStoreIOS::SetCookieWithDetailsAsync, this, url, name, value,
+ domain, path, creation_time, expiration_time, last_access_time,
+ secure, http_only, same_site, enforce_strict_secure, priority,
+ WrapSetCallback(callback)));
break;
case SYNCHRONIZED:
// If cookies are not allowed, they are stashed in the CookieMonster, and
@@ -466,6 +467,9 @@ void CookieStoreIOS::SetCookieWithDetailsAsync(
bool success = false;
+ if (creation_time.is_null())
+ creation_time = base::Time::Now();
+
// First create a CanonicalCookie, to normalize the arguments,
// particularly domain and path, and perform validation.
scoped_ptr<net::CanonicalCookie> canonical_cookie =
@@ -480,13 +484,9 @@ void CookieStoreIOS::SetCookieWithDetailsAsync(
if (cookie != nil) {
[system_store_ setCookie:cookie];
- base::Time base_creation_time = creation_time;
- if (base_creation_time.is_null()) {
- base_creation_time = base::Time::Now();
- }
creation_time_manager_->SetCreationTime(
cookie, creation_time_manager_->MakeUniqueCreationTime(
- base_creation_time));
+ canonical_cookie->CreationDate()));
success = true;
}
}
diff --git a/ios/net/cookies/cookie_store_ios_unittest.mm b/ios/net/cookies/cookie_store_ios_unittest.mm
index 5518c60..41319a8 100644
--- a/ios/net/cookies/cookie_store_ios_unittest.mm
+++ b/ios/net/cookies/cookie_store_ios_unittest.mm
@@ -92,8 +92,9 @@ class RoundTripTestCookieStore : public net::CookieStore {
const std::string& value,
const std::string& domain,
const std::string& path,
- const base::Time creation_time,
- const base::Time expiration_time,
+ base::Time creation_time,
+ base::Time expiration_time,
+ base::Time last_access_time,
bool secure,
bool http_only,
bool same_site,
@@ -102,8 +103,9 @@ class RoundTripTestCookieStore : public net::CookieStore {
const SetCookiesCallback& callback) override {
RoundTrip();
store_->SetCookieWithDetailsAsync(
- url, name, value, domain, path, creation_time, expiration_time, secure,
- http_only, same_site, enforce_strict_secure, priority, callback);
+ url, name, value, domain, path, creation_time, expiration_time,
+ last_access_time, secure, http_only, same_site, enforce_strict_secure,
+ priority, callback);
}
void GetCookiesWithOptionsAsync(const GURL& url,