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

Side by Side Diff: net/base/cookie_monster.cc

Issue 8533013: SessionRestore: Store session cookies and restore them if chrome crashes or auto-restarts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup. Created 9 years, 1 month 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/base/cookie_monster.h ('k') | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Portions of this code based on Mozilla: 5 // Portions of this code based on Mozilla:
6 // (netwerk/cookie/src/nsCookieService.cpp) 6 // (netwerk/cookie/src/nsCookieService.cpp)
7 /* ***** BEGIN LICENSE BLOCK ***** 7 /* ***** BEGIN LICENSE BLOCK *****
8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
9 * 9 *
10 * The contents of this file are subject to the Mozilla Public License Version 10 * The contents of this file are subject to the Mozilla Public License Version
(...skipping 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after
1392 if (matching_cookies.find(curit->second) != matching_cookies.end()) { 1392 if (matching_cookies.find(curit->second) != matching_cookies.end()) {
1393 InternalDeleteCookie(curit, true, DELETE_COOKIE_EXPLICIT); 1393 InternalDeleteCookie(curit, true, DELETE_COOKIE_EXPLICIT);
1394 } 1394 }
1395 } 1395 }
1396 } 1396 }
1397 1397
1398 CookieMonster* CookieMonster::GetCookieMonster() { 1398 CookieMonster* CookieMonster::GetCookieMonster() {
1399 return this; 1399 return this;
1400 } 1400 }
1401 1401
1402 void CookieMonster::MergeSessionCookies(CookieMonster* session_cookie_monster) {
1403 // Queue all cookie requests until the cookies have been merged.
1404 loaded_ = false;
erikwright (departed) 2011/11/22 18:49:39 This is not designed to work this way. I suspect i
1405 session_cookie_monster->GetAllCookiesAsync(
1406 base::Bind(&CookieMonster::OnGotSessionCookies, this));
1407 }
1408
1402 CookieMonster::~CookieMonster() { 1409 CookieMonster::~CookieMonster() {
1403 DeleteAll(false); 1410 DeleteAll(false);
1404 } 1411 }
1405 1412
1406 bool CookieMonster::SetCookieWithCreationTime(const GURL& url, 1413 bool CookieMonster::SetCookieWithCreationTime(const GURL& url,
1407 const std::string& cookie_line, 1414 const std::string& cookie_line,
1408 const base::Time& creation_time) { 1415 const base::Time& creation_time) {
1409 DCHECK(!store_) << "This method is only to be used by unit-tests."; 1416 DCHECK(!store_) << "This method is only to be used by unit-tests.";
1410 base::AutoLock autolock(lock_); 1417 base::AutoLock autolock(lock_);
1411 1418
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
2239 2246
2240 2247
2241 // The system resolution is not high enough, so we can have multiple 2248 // The system resolution is not high enough, so we can have multiple
2242 // set cookies that result in the same system time. When this happens, we 2249 // set cookies that result in the same system time. When this happens, we
2243 // increment by one Time unit. Let's hope computers don't get too fast. 2250 // increment by one Time unit. Let's hope computers don't get too fast.
2244 Time CookieMonster::CurrentTime() { 2251 Time CookieMonster::CurrentTime() {
2245 return std::max(Time::Now(), 2252 return std::max(Time::Now(),
2246 Time::FromInternalValue(last_time_seen_.ToInternalValue() + 1)); 2253 Time::FromInternalValue(last_time_seen_.ToInternalValue() + 1));
2247 } 2254 }
2248 2255
2256 void CookieMonster::OnGotSessionCookies(
2257 const net::CookieList& cookie_list) {
2258 // The cookies we got are all marked as persistent; we need to make them
2259 // non-persistent before merging them.
2260 net::CookieList new_cookie_list;
2261 net::CookieList::const_iterator it;
2262 for (it = cookie_list.begin(); it != cookie_list.end(); ++it) {
2263 net::CookieMonster::CanonicalCookie new_cookie(*it);
2264 new_cookie.SetPersistent(false);
2265 new_cookie_list.push_back(new_cookie);
2266 }
2267 InitializeFrom(new_cookie_list);
2268 InvokeQueue();
erikwright (departed) 2011/11/22 18:49:39 This is not likely to work as expected.
2269 }
2270
2249 CookieMonster::ParsedCookie::ParsedCookie(const std::string& cookie_line) 2271 CookieMonster::ParsedCookie::ParsedCookie(const std::string& cookie_line)
2250 : is_valid_(false), 2272 : is_valid_(false),
2251 path_index_(0), 2273 path_index_(0),
2252 domain_index_(0), 2274 domain_index_(0),
2253 mac_key_index_(0), 2275 mac_key_index_(0),
2254 mac_algorithm_index_(0), 2276 mac_algorithm_index_(0),
2255 expires_index_(0), 2277 expires_index_(0),
2256 maxage_index_(0), 2278 maxage_index_(0),
2257 secure_index_(0), 2279 secure_index_(0),
2258 httponly_index_(0) { 2280 httponly_index_(0) {
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
2762 std::string CookieMonster::CanonicalCookie::DebugString() const { 2784 std::string CookieMonster::CanonicalCookie::DebugString() const {
2763 return base::StringPrintf( 2785 return base::StringPrintf(
2764 "name: %s value: %s domain: %s path: %s creation: %" 2786 "name: %s value: %s domain: %s path: %s creation: %"
2765 PRId64, 2787 PRId64,
2766 name_.c_str(), value_.c_str(), 2788 name_.c_str(), value_.c_str(),
2767 domain_.c_str(), path_.c_str(), 2789 domain_.c_str(), path_.c_str(),
2768 static_cast<int64>(creation_date_.ToTimeT())); 2790 static_cast<int64>(creation_date_.ToTimeT()));
2769 } 2791 }
2770 2792
2771 } // namespace 2793 } // namespace
OLDNEW
« no previous file with comments | « net/base/cookie_monster.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698