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

Side by Side Diff: net/url_request/url_request_http_job.cc

Issue 11339032: Account for server vs host clock skew in cookie expiration times. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disable test on Android as there's no test server Created 8 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/url_request/url_request_http_job.h ('k') | net/url_request/url_request_unittest.cc » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "net/url_request/url_request_http_job.h" 5 #include "net/url_request/url_request_http_job.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 DCHECK(transaction_.get()); 559 DCHECK(transaction_.get());
560 560
561 const HttpResponseInfo* response_info = transaction_->GetResponseInfo(); 561 const HttpResponseInfo* response_info = transaction_->GetResponseInfo();
562 DCHECK(response_info); 562 DCHECK(response_info);
563 563
564 response_cookies_.clear(); 564 response_cookies_.clear();
565 response_cookies_save_index_ = 0; 565 response_cookies_save_index_ = 0;
566 566
567 FetchResponseCookies(&response_cookies_); 567 FetchResponseCookies(&response_cookies_);
568 568
569 if (!GetResponseHeaders()->GetDateValue(&response_date_))
570 response_date_ = base::Time();
571
569 // Now, loop over the response cookies, and attempt to persist each. 572 // Now, loop over the response cookies, and attempt to persist each.
570 SaveNextCookie(); 573 SaveNextCookie();
571 } 574 }
572 575
573 // If the save occurs synchronously, SaveNextCookie will loop and save the next 576 // If the save occurs synchronously, SaveNextCookie will loop and save the next
574 // cookie. If the save is deferred, the callback is responsible for continuing 577 // cookie. If the save is deferred, the callback is responsible for continuing
575 // to iterate through the cookies. 578 // to iterate through the cookies.
576 // TODO(erikwright): Modify the CookieStore API to indicate via return value 579 // TODO(erikwright): Modify the CookieStore API to indicate via return value
577 // whether it completed synchronously or asynchronously. 580 // whether it completed synchronously or asynchronously.
578 // See http://crbug.com/131066. 581 // See http://crbug.com/131066.
579 void URLRequestHttpJob::SaveNextCookie() { 582 void URLRequestHttpJob::SaveNextCookie() {
580 // No matter what, we want to report our status as IO pending since we will 583 // No matter what, we want to report our status as IO pending since we will
581 // be notifying our consumer asynchronously via OnStartCompleted. 584 // be notifying our consumer asynchronously via OnStartCompleted.
582 SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); 585 SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0));
583 586
584 // Used to communicate with the callback. See the implementation of 587 // Used to communicate with the callback. See the implementation of
585 // OnCookieSaved. 588 // OnCookieSaved.
586 scoped_refptr<SharedBoolean> callback_pending = new SharedBoolean(false); 589 scoped_refptr<SharedBoolean> callback_pending = new SharedBoolean(false);
587 scoped_refptr<SharedBoolean> save_next_cookie_running = 590 scoped_refptr<SharedBoolean> save_next_cookie_running =
588 new SharedBoolean(true); 591 new SharedBoolean(true);
589 592
590 if (!(request_info_.load_flags & LOAD_DO_NOT_SAVE_COOKIES) && 593 if (!(request_info_.load_flags & LOAD_DO_NOT_SAVE_COOKIES) &&
591 request_->context()->cookie_store() && 594 request_->context()->cookie_store() &&
592 response_cookies_.size() > 0) { 595 response_cookies_.size() > 0) {
593 CookieOptions options; 596 CookieOptions options;
594 options.set_include_httponly(); 597 options.set_include_httponly();
598 options.set_server_time(response_date_);
595 599
596 net::CookieStore::SetCookiesCallback callback( 600 net::CookieStore::SetCookiesCallback callback(
597 base::Bind(&URLRequestHttpJob::OnCookieSaved, 601 base::Bind(&URLRequestHttpJob::OnCookieSaved,
598 weak_factory_.GetWeakPtr(), 602 weak_factory_.GetWeakPtr(),
599 save_next_cookie_running, 603 save_next_cookie_running,
600 callback_pending)); 604 callback_pending));
601 605
602 // Loop through the cookies as long as SetCookieWithOptionsAsync completes 606 // Loop through the cookies as long as SetCookieWithOptionsAsync completes
603 // synchronously. 607 // synchronously.
604 while (!callback_pending->data && 608 while (!callback_pending->data &&
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
1515 1519
1516 void URLRequestHttpJob::NotifyURLRequestDestroyed() { 1520 void URLRequestHttpJob::NotifyURLRequestDestroyed() {
1517 awaiting_callback_ = false; 1521 awaiting_callback_ = false;
1518 } 1522 }
1519 1523
1520 void URLRequestHttpJob::OnDetachRequest() { 1524 void URLRequestHttpJob::OnDetachRequest() {
1521 http_transaction_delegate_->OnDetachRequest(); 1525 http_transaction_delegate_->OnDetachRequest();
1522 } 1526 }
1523 1527
1524 } // namespace net 1528 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_http_job.h ('k') | net/url_request/url_request_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698