Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 // 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 // See comments at declaration of these variables in cookie_monster.h | 97 // See comments at declaration of these variables in cookie_monster.h |
| 98 // for details. | 98 // for details. |
| 99 const size_t CookieMonster::kDomainMaxCookies = 180; | 99 const size_t CookieMonster::kDomainMaxCookies = 180; |
| 100 const size_t CookieMonster::kDomainPurgeCookies = 30; | 100 const size_t CookieMonster::kDomainPurgeCookies = 30; |
| 101 const size_t CookieMonster::kMaxCookies = 3300; | 101 const size_t CookieMonster::kMaxCookies = 3300; |
| 102 const size_t CookieMonster::kPurgeCookies = 300; | 102 const size_t CookieMonster::kPurgeCookies = 300; |
| 103 | 103 |
| 104 const size_t CookieMonster::kDomainCookiesQuotaLow = 30; | 104 const size_t CookieMonster::kDomainCookiesQuotaLow = 30; |
| 105 const size_t CookieMonster::kDomainCookiesQuotaMedium = 50; | 105 const size_t CookieMonster::kDomainCookiesQuotaMedium = 50; |
| 106 const size_t CookieMonster::kDomainCookiesQuotaHigh = | 106 const size_t CookieMonster::kDomainCookiesQuotaHigh = |
| 107 CookieMonster::kDomainMaxCookies - CookieMonster::kDomainPurgeCookies | 107 kDomainMaxCookies - kDomainPurgeCookies |
| 108 - CookieMonster::kDomainCookiesQuotaLow | 108 - kDomainCookiesQuotaLow - kDomainCookiesQuotaMedium; |
| 109 - CookieMonster::kDomainCookiesQuotaMedium; | |
| 110 | 109 |
| 111 const int CookieMonster::kSafeFromGlobalPurgeDays = 30; | 110 const int CookieMonster::kSafeFromGlobalPurgeDays = 30; |
| 112 | 111 |
| 113 namespace { | 112 namespace { |
| 114 | 113 |
| 115 typedef std::vector<CanonicalCookie*> CanonicalCookieVector; | 114 typedef std::vector<CanonicalCookie*> CanonicalCookieVector; |
| 116 | 115 |
| 117 // Default minimum delay after updating a cookie's LastAccessDate before we | 116 // Default minimum delay after updating a cookie's LastAccessDate before we |
| 118 // will update it again. | 117 // will update it again. |
| 119 const int kDefaultAccessUpdateThresholdSeconds = 60; | 118 const int kDefaultAccessUpdateThresholdSeconds = 60; |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 392 // message loop because the underlying instance may be destroyed (along with the | 391 // message loop because the underlying instance may be destroyed (along with the |
| 393 // CookieMonsterTask instance) in the interim. Therefore, we post a callback | 392 // CookieMonsterTask instance) in the interim. Therefore, we post a callback |
| 394 // bound to the CookieMonsterTask, which *is* reference counted (thus preventing | 393 // bound to the CookieMonsterTask, which *is* reference counted (thus preventing |
| 395 // destruction of the original callback), and which invokes the closure (which | 394 // destruction of the original callback), and which invokes the closure (which |
| 396 // invokes the original callback with the returned data). | 395 // invokes the original callback with the returned data). |
| 397 void CookieMonster::CookieMonsterTask::InvokeCallback(base::Closure callback) { | 396 void CookieMonster::CookieMonsterTask::InvokeCallback(base::Closure callback) { |
| 398 if (thread_->BelongsToCurrentThread()) { | 397 if (thread_->BelongsToCurrentThread()) { |
| 399 callback.Run(); | 398 callback.Run(); |
| 400 } else { | 399 } else { |
| 401 thread_->PostTask(FROM_HERE, base::Bind( | 400 thread_->PostTask(FROM_HERE, base::Bind( |
| 402 &CookieMonster::CookieMonsterTask::InvokeCallback, this, callback)); | 401 &CookieMonsterTask::InvokeCallback, this, callback)); |
| 403 } | 402 } |
| 404 } | 403 } |
| 405 | 404 |
| 406 // Task class for SetCookieWithDetails call. | 405 // Task class for SetCookieWithDetails call. |
| 407 class CookieMonster::SetCookieWithDetailsTask | 406 class CookieMonster::SetCookieWithDetailsTask : public CookieMonsterTask { |
| 408 : public CookieMonster::CookieMonsterTask { | |
| 409 public: | 407 public: |
| 410 SetCookieWithDetailsTask(CookieMonster* cookie_monster, | 408 SetCookieWithDetailsTask(CookieMonster* cookie_monster, |
| 411 const GURL& url, | 409 const GURL& url, |
| 412 const std::string& name, | 410 const std::string& name, |
| 413 const std::string& value, | 411 const std::string& value, |
| 414 const std::string& domain, | 412 const std::string& domain, |
| 415 const std::string& path, | 413 const std::string& path, |
| 416 const base::Time& expiration_time, | 414 const base::Time& expiration_time, |
| 417 bool secure, | 415 bool secure, |
| 418 bool http_only, | 416 bool http_only, |
| 419 CookiePriority priority, | 417 CookiePriority priority, |
| 420 const CookieMonster::SetCookiesCallback& callback) | 418 const SetCookiesCallback& callback) |
| 421 : CookieMonsterTask(cookie_monster), | 419 : CookieMonsterTask(cookie_monster), |
| 422 url_(url), | 420 url_(url), |
| 423 name_(name), | 421 name_(name), |
| 424 value_(value), | 422 value_(value), |
| 425 domain_(domain), | 423 domain_(domain), |
| 426 path_(path), | 424 path_(path), |
| 427 expiration_time_(expiration_time), | 425 expiration_time_(expiration_time), |
| 428 secure_(secure), | 426 secure_(secure), |
| 429 http_only_(http_only), | 427 http_only_(http_only), |
| 430 priority_(priority), | 428 priority_(priority), |
| 431 callback_(callback) { | 429 callback_(callback) { |
| 432 } | 430 } |
| 433 | 431 |
| 434 // CookieMonster::CookieMonsterTask: | 432 // CookieMonsterTask: |
| 435 virtual void Run() OVERRIDE; | 433 virtual void Run() OVERRIDE; |
| 436 | 434 |
| 437 protected: | 435 protected: |
| 438 virtual ~SetCookieWithDetailsTask() {} | 436 virtual ~SetCookieWithDetailsTask() {} |
| 439 | 437 |
| 440 private: | 438 private: |
| 441 GURL url_; | 439 GURL url_; |
| 442 std::string name_; | 440 std::string name_; |
| 443 std::string value_; | 441 std::string value_; |
| 444 std::string domain_; | 442 std::string domain_; |
| 445 std::string path_; | 443 std::string path_; |
| 446 base::Time expiration_time_; | 444 base::Time expiration_time_; |
| 447 bool secure_; | 445 bool secure_; |
| 448 bool http_only_; | 446 bool http_only_; |
| 449 CookiePriority priority_; | 447 CookiePriority priority_; |
| 450 CookieMonster::SetCookiesCallback callback_; | 448 SetCookiesCallback callback_; |
| 451 | 449 |
| 452 DISALLOW_COPY_AND_ASSIGN(SetCookieWithDetailsTask); | 450 DISALLOW_COPY_AND_ASSIGN(SetCookieWithDetailsTask); |
| 453 }; | 451 }; |
| 454 | 452 |
| 455 void CookieMonster::SetCookieWithDetailsTask::Run() { | 453 void CookieMonster::SetCookieWithDetailsTask::Run() { |
| 456 bool success = this->cookie_monster()-> | 454 bool success = this->cookie_monster()-> |
| 457 SetCookieWithDetails(url_, name_, value_, domain_, path_, | 455 SetCookieWithDetails(url_, name_, value_, domain_, path_, |
| 458 expiration_time_, secure_, http_only_, priority_); | 456 expiration_time_, secure_, http_only_, priority_); |
| 459 if (!callback_.is_null()) { | 457 if (!callback_.is_null()) { |
| 460 this->InvokeCallback(base::Bind(&CookieMonster::SetCookiesCallback::Run, | 458 this->InvokeCallback(base::Bind(&SetCookiesCallback::Run, |
| 461 base::Unretained(&callback_), success)); | 459 base::Unretained(&callback_), success)); |
| 462 } | 460 } |
| 463 } | 461 } |
| 464 | 462 |
| 465 // Task class for GetAllCookies call. | 463 // Task class for GetAllCookies call. |
| 466 class CookieMonster::GetAllCookiesTask | 464 class CookieMonster::GetAllCookiesTask : public CookieMonsterTask { |
| 467 : public CookieMonster::CookieMonsterTask { | |
| 468 public: | 465 public: |
| 469 GetAllCookiesTask(CookieMonster* cookie_monster, | 466 GetAllCookiesTask(CookieMonster* cookie_monster, |
| 470 const CookieMonster::GetCookieListCallback& callback) | 467 const GetCookieListCallback& callback) |
| 471 : CookieMonsterTask(cookie_monster), | 468 : CookieMonsterTask(cookie_monster), |
| 472 callback_(callback) { | 469 callback_(callback) { |
| 473 } | 470 } |
| 474 | 471 |
| 475 // CookieMonster::CookieMonsterTask | 472 // CookieMonsterTask |
| 476 virtual void Run() OVERRIDE; | 473 virtual void Run() OVERRIDE; |
| 477 | 474 |
| 478 protected: | 475 protected: |
| 479 virtual ~GetAllCookiesTask() {} | 476 virtual ~GetAllCookiesTask() {} |
| 480 | 477 |
| 481 private: | 478 private: |
| 482 CookieMonster::GetCookieListCallback callback_; | 479 GetCookieListCallback callback_; |
| 483 | 480 |
| 484 DISALLOW_COPY_AND_ASSIGN(GetAllCookiesTask); | 481 DISALLOW_COPY_AND_ASSIGN(GetAllCookiesTask); |
| 485 }; | 482 }; |
| 486 | 483 |
| 487 void CookieMonster::GetAllCookiesTask::Run() { | 484 void CookieMonster::GetAllCookiesTask::Run() { |
| 488 if (!callback_.is_null()) { | 485 if (!callback_.is_null()) { |
| 489 CookieList cookies = this->cookie_monster()->GetAllCookies(); | 486 CookieList cookies = this->cookie_monster()->GetAllCookies(); |
| 490 this->InvokeCallback(base::Bind(&CookieMonster::GetCookieListCallback::Run, | 487 this->InvokeCallback(base::Bind(&GetCookieListCallback::Run, |
| 491 base::Unretained(&callback_), cookies)); | 488 base::Unretained(&callback_), cookies)); |
| 492 } | 489 } |
| 493 } | 490 } |
| 494 | 491 |
| 495 // Task class for GetAllCookiesForURLWithOptions call. | 492 // Task class for GetAllCookiesForURLWithOptions call. |
| 496 class CookieMonster::GetAllCookiesForURLWithOptionsTask | 493 class CookieMonster::GetAllCookiesForURLWithOptionsTask |
| 497 : public CookieMonster::CookieMonsterTask { | 494 : public CookieMonsterTask { |
| 498 public: | 495 public: |
| 499 GetAllCookiesForURLWithOptionsTask( | 496 GetAllCookiesForURLWithOptionsTask( |
| 500 CookieMonster* cookie_monster, | 497 CookieMonster* cookie_monster, |
| 501 const GURL& url, | 498 const GURL& url, |
| 502 const CookieOptions& options, | 499 const CookieOptions& options, |
| 503 const CookieMonster::GetCookieListCallback& callback) | 500 const GetCookieListCallback& callback) |
| 504 : CookieMonsterTask(cookie_monster), | 501 : CookieMonsterTask(cookie_monster), |
| 505 url_(url), | 502 url_(url), |
| 506 options_(options), | 503 options_(options), |
| 507 callback_(callback) { | 504 callback_(callback) { |
| 508 } | 505 } |
| 509 | 506 |
| 510 // CookieMonster::CookieMonsterTask: | 507 // CookieMonsterTask: |
| 511 virtual void Run() OVERRIDE; | 508 virtual void Run() OVERRIDE; |
| 512 | 509 |
| 513 protected: | 510 protected: |
| 514 virtual ~GetAllCookiesForURLWithOptionsTask() {} | 511 virtual ~GetAllCookiesForURLWithOptionsTask() {} |
| 515 | 512 |
| 516 private: | 513 private: |
| 517 GURL url_; | 514 GURL url_; |
| 518 CookieOptions options_; | 515 CookieOptions options_; |
| 519 CookieMonster::GetCookieListCallback callback_; | 516 GetCookieListCallback callback_; |
| 520 | 517 |
| 521 DISALLOW_COPY_AND_ASSIGN(GetAllCookiesForURLWithOptionsTask); | 518 DISALLOW_COPY_AND_ASSIGN(GetAllCookiesForURLWithOptionsTask); |
| 522 }; | 519 }; |
| 523 | 520 |
| 524 void CookieMonster::GetAllCookiesForURLWithOptionsTask::Run() { | 521 void CookieMonster::GetAllCookiesForURLWithOptionsTask::Run() { |
| 525 if (!callback_.is_null()) { | 522 if (!callback_.is_null()) { |
| 526 CookieList cookies = this->cookie_monster()-> | 523 CookieList cookies = this->cookie_monster()-> |
| 527 GetAllCookiesForURLWithOptions(url_, options_); | 524 GetAllCookiesForURLWithOptions(url_, options_); |
| 528 this->InvokeCallback(base::Bind(&CookieMonster::GetCookieListCallback::Run, | 525 this->InvokeCallback(base::Bind(&GetCookieListCallback::Run, |
| 529 base::Unretained(&callback_), cookies)); | 526 base::Unretained(&callback_), cookies)); |
| 530 } | 527 } |
| 531 } | 528 } |
| 532 | 529 |
| 533 // Task class for DeleteAll call. | 530 template <typename Result> struct CallbackType { |
| 534 class CookieMonster::DeleteAllTask : public CookieMonster::CookieMonsterTask { | 531 typedef base::Callback<void(Result)> Type; |
| 532 }; | |
| 533 | |
| 534 template <> struct CallbackType<void> { | |
| 535 typedef base::Closure Type; | |
| 536 }; | |
| 537 | |
| 538 // Base task class for Delete*Task. | |
| 539 template <typename Result> | |
| 540 class CookieMonster::DeleteTask : public CookieMonsterTask { | |
| 535 public: | 541 public: |
| 536 DeleteAllTask(CookieMonster* cookie_monster, | 542 DeleteTask(CookieMonster* cookie_monster, |
| 537 const CookieMonster::DeleteCallback& callback) | 543 const typename CallbackType<Result>::Type& callback) |
| 538 : CookieMonsterTask(cookie_monster), | 544 : CookieMonsterTask(cookie_monster), |
| 539 callback_(callback) { | 545 callback_(callback) { |
| 540 } | 546 } |
| 541 | 547 |
| 542 // CookieMonster::CookieMonsterTask: | 548 // Runs the delete task and returns a result. |
| 549 virtual Result RunDeleteTask() = 0; | |
|
erikwright (departed)
2013/09/12 17:25:44
can be private.
| |
| 550 | |
| 551 // CookieMonsterTask: | |
| 543 virtual void Run() OVERRIDE; | 552 virtual void Run() OVERRIDE; |
| 544 | 553 |
| 554 void FlushDone(const base::Closure& callback); | |
|
erikwright (departed)
2013/09/12 17:25:44
can be private
| |
| 555 | |
| 556 private: | |
| 557 base::Closure RunDeleteTaskAndBindCallback(); | |
| 558 | |
| 559 typename CallbackType<Result>::Type callback_; | |
| 560 | |
| 561 DISALLOW_COPY_AND_ASSIGN(DeleteTask); | |
| 562 }; | |
| 563 | |
| 564 template <typename Result> | |
| 565 base::Closure CookieMonster::DeleteTask<Result>:: | |
| 566 RunDeleteTaskAndBindCallback() { | |
| 567 return base::Bind(callback_, RunDeleteTask()); | |
|
erikwright (departed)
2013/09/12 17:25:44
if callback_.is_null() you will need to just do Ru
| |
| 568 } | |
| 569 | |
| 570 template <> | |
| 571 base::Closure CookieMonster::DeleteTask<void>::RunDeleteTaskAndBindCallback() { | |
| 572 RunDeleteTask(); | |
| 573 return callback_; | |
| 574 } | |
| 575 | |
| 576 template <typename Result> | |
| 577 void CookieMonster::DeleteTask<Result>::Run() { | |
| 578 this->cookie_monster()->FlushStore( | |
| 579 base::Bind(&DeleteTask<Result>::FlushDone, this, | |
| 580 RunDeleteTaskAndBindCallback())); | |
| 581 } | |
| 582 | |
| 583 template <typename Result> | |
| 584 void CookieMonster::DeleteTask<Result>::FlushDone( | |
| 585 const base::Closure& callback) { | |
| 586 if (!callback.is_null()) { | |
| 587 this->InvokeCallback(callback); | |
| 588 } | |
| 589 } | |
| 590 | |
| 591 // Task class for DeleteAll call. | |
| 592 class CookieMonster::DeleteAllTask : public DeleteTask<int> { | |
| 593 public: | |
| 594 DeleteAllTask(CookieMonster* cookie_monster, | |
| 595 const DeleteCallback& callback) | |
| 596 : DeleteTask(cookie_monster, callback) { | |
| 597 } | |
| 598 | |
| 599 // DeleteTask: | |
| 600 virtual int RunDeleteTask() OVERRIDE; | |
| 601 | |
| 545 protected: | 602 protected: |
| 546 virtual ~DeleteAllTask() {} | 603 virtual ~DeleteAllTask() {} |
| 547 | 604 |
| 548 private: | 605 private: |
| 549 CookieMonster::DeleteCallback callback_; | |
| 550 | |
| 551 DISALLOW_COPY_AND_ASSIGN(DeleteAllTask); | 606 DISALLOW_COPY_AND_ASSIGN(DeleteAllTask); |
| 552 }; | 607 }; |
| 553 | 608 |
| 554 void CookieMonster::DeleteAllTask::Run() { | 609 int CookieMonster::DeleteAllTask::RunDeleteTask() { |
| 555 int num_deleted = this->cookie_monster()->DeleteAll(true); | 610 return this->cookie_monster()->DeleteAll(true); |
| 556 if (!callback_.is_null()) { | |
| 557 this->InvokeCallback(base::Bind(&CookieMonster::DeleteCallback::Run, | |
| 558 base::Unretained(&callback_), num_deleted)); | |
| 559 } | |
| 560 } | 611 } |
| 561 | 612 |
| 562 // Task class for DeleteAllCreatedBetween call. | 613 // Task class for DeleteAllCreatedBetween call. |
| 563 class CookieMonster::DeleteAllCreatedBetweenTask | 614 class CookieMonster::DeleteAllCreatedBetweenTask : public DeleteTask<int> { |
| 564 : public CookieMonster::CookieMonsterTask { | |
| 565 public: | 615 public: |
| 566 DeleteAllCreatedBetweenTask(CookieMonster* cookie_monster, | 616 DeleteAllCreatedBetweenTask(CookieMonster* cookie_monster, |
| 567 const Time& delete_begin, | 617 const Time& delete_begin, |
| 568 const Time& delete_end, | 618 const Time& delete_end, |
| 569 const CookieMonster::DeleteCallback& callback) | 619 const DeleteCallback& callback) |
| 570 : CookieMonsterTask(cookie_monster), | 620 : DeleteTask(cookie_monster, callback), |
| 571 delete_begin_(delete_begin), | 621 delete_begin_(delete_begin), |
| 572 delete_end_(delete_end), | 622 delete_end_(delete_end) { |
| 573 callback_(callback) { | |
| 574 } | 623 } |
| 575 | 624 |
| 576 // CookieMonster::CookieMonsterTask: | 625 // DeleteTask: |
| 577 virtual void Run() OVERRIDE; | 626 virtual int RunDeleteTask() OVERRIDE; |
| 578 | 627 |
| 579 protected: | 628 protected: |
| 580 virtual ~DeleteAllCreatedBetweenTask() {} | 629 virtual ~DeleteAllCreatedBetweenTask() {} |
| 581 | 630 |
| 582 private: | 631 private: |
| 583 Time delete_begin_; | 632 Time delete_begin_; |
| 584 Time delete_end_; | 633 Time delete_end_; |
| 585 CookieMonster::DeleteCallback callback_; | |
| 586 | 634 |
| 587 DISALLOW_COPY_AND_ASSIGN(DeleteAllCreatedBetweenTask); | 635 DISALLOW_COPY_AND_ASSIGN(DeleteAllCreatedBetweenTask); |
| 588 }; | 636 }; |
| 589 | 637 |
| 590 void CookieMonster::DeleteAllCreatedBetweenTask::Run() { | 638 int CookieMonster::DeleteAllCreatedBetweenTask::RunDeleteTask() { |
| 591 int num_deleted = this->cookie_monster()-> | 639 return this->cookie_monster()-> |
| 592 DeleteAllCreatedBetween(delete_begin_, delete_end_); | 640 DeleteAllCreatedBetween(delete_begin_, delete_end_); |
| 593 if (!callback_.is_null()) { | |
| 594 this->InvokeCallback(base::Bind(&CookieMonster::DeleteCallback::Run, | |
| 595 base::Unretained(&callback_), num_deleted)); | |
| 596 } | |
| 597 } | 641 } |
| 598 | 642 |
| 599 // Task class for DeleteAllForHost call. | 643 // Task class for DeleteAllForHost call. |
| 600 class CookieMonster::DeleteAllForHostTask | 644 class CookieMonster::DeleteAllForHostTask : public DeleteTask<int> { |
| 601 : public CookieMonster::CookieMonsterTask { | |
| 602 public: | 645 public: |
| 603 DeleteAllForHostTask(CookieMonster* cookie_monster, | 646 DeleteAllForHostTask(CookieMonster* cookie_monster, |
| 604 const GURL& url, | 647 const GURL& url, |
| 605 const CookieMonster::DeleteCallback& callback) | 648 const DeleteCallback& callback) |
| 606 : CookieMonsterTask(cookie_monster), | 649 : DeleteTask(cookie_monster, callback), |
| 607 url_(url), | 650 url_(url) { |
| 608 callback_(callback) { | |
| 609 } | 651 } |
| 610 | 652 |
| 611 // CookieMonster::CookieMonsterTask: | 653 // DeleteTask: |
| 612 virtual void Run() OVERRIDE; | 654 virtual int RunDeleteTask() OVERRIDE; |
| 613 | 655 |
| 614 protected: | 656 protected: |
| 615 virtual ~DeleteAllForHostTask() {} | 657 virtual ~DeleteAllForHostTask() {} |
| 616 | 658 |
| 617 private: | 659 private: |
| 618 GURL url_; | 660 GURL url_; |
| 619 CookieMonster::DeleteCallback callback_; | |
| 620 | 661 |
| 621 DISALLOW_COPY_AND_ASSIGN(DeleteAllForHostTask); | 662 DISALLOW_COPY_AND_ASSIGN(DeleteAllForHostTask); |
| 622 }; | 663 }; |
| 623 | 664 |
| 624 void CookieMonster::DeleteAllForHostTask::Run() { | 665 int CookieMonster::DeleteAllForHostTask::RunDeleteTask() { |
| 625 int num_deleted = this->cookie_monster()->DeleteAllForHost(url_); | 666 return this->cookie_monster()->DeleteAllForHost(url_); |
| 626 if (!callback_.is_null()) { | |
| 627 this->InvokeCallback(base::Bind(&CookieMonster::DeleteCallback::Run, | |
| 628 base::Unretained(&callback_), num_deleted)); | |
| 629 } | |
| 630 } | 667 } |
| 631 | 668 |
| 632 // Task class for DeleteAllCreatedBetweenForHost call. | 669 // Task class for DeleteAllCreatedBetweenForHost call. |
| 633 class CookieMonster::DeleteAllCreatedBetweenForHostTask | 670 class CookieMonster::DeleteAllCreatedBetweenForHostTask |
| 634 : public CookieMonster::CookieMonsterTask { | 671 : public DeleteTask<int> { |
| 635 public: | 672 public: |
| 636 DeleteAllCreatedBetweenForHostTask( | 673 DeleteAllCreatedBetweenForHostTask( |
| 637 CookieMonster* cookie_monster, | 674 CookieMonster* cookie_monster, |
| 638 Time delete_begin, | 675 Time delete_begin, |
| 639 Time delete_end, | 676 Time delete_end, |
| 640 const GURL& url, | 677 const GURL& url, |
| 641 const CookieMonster::DeleteCallback& callback) | 678 const DeleteCallback& callback) |
| 642 : CookieMonsterTask(cookie_monster), | 679 : DeleteTask(cookie_monster, callback), |
| 643 delete_begin_(delete_begin), | 680 delete_begin_(delete_begin), |
| 644 delete_end_(delete_end), | 681 delete_end_(delete_end), |
| 645 url_(url), | 682 url_(url) { |
| 646 callback_(callback) { | |
| 647 } | 683 } |
| 648 | 684 |
| 649 // CookieMonster::CookieMonsterTask: | 685 // DeleteTask: |
| 650 virtual void Run() OVERRIDE; | 686 virtual int RunDeleteTask() OVERRIDE; |
| 651 | 687 |
| 652 protected: | 688 protected: |
| 653 virtual ~DeleteAllCreatedBetweenForHostTask() {} | 689 virtual ~DeleteAllCreatedBetweenForHostTask() {} |
| 654 | 690 |
| 655 private: | 691 private: |
| 656 Time delete_begin_; | 692 Time delete_begin_; |
| 657 Time delete_end_; | 693 Time delete_end_; |
| 658 GURL url_; | 694 GURL url_; |
| 659 CookieMonster::DeleteCallback callback_; | |
| 660 | 695 |
| 661 DISALLOW_COPY_AND_ASSIGN(DeleteAllCreatedBetweenForHostTask); | 696 DISALLOW_COPY_AND_ASSIGN(DeleteAllCreatedBetweenForHostTask); |
| 662 }; | 697 }; |
| 663 | 698 |
| 664 void CookieMonster::DeleteAllCreatedBetweenForHostTask::Run() { | 699 int CookieMonster::DeleteAllCreatedBetweenForHostTask::RunDeleteTask() { |
| 665 int num_deleted = this->cookie_monster()->DeleteAllCreatedBetweenForHost( | 700 return this->cookie_monster()->DeleteAllCreatedBetweenForHost( |
| 666 delete_begin_, delete_end_, url_); | 701 delete_begin_, delete_end_, url_); |
| 667 if (!callback_.is_null()) { | |
| 668 this->InvokeCallback(base::Bind(&CookieMonster::DeleteCallback::Run, | |
| 669 base::Unretained(&callback_), num_deleted)); | |
| 670 } | |
| 671 } | 702 } |
| 672 | 703 |
| 673 // Task class for DeleteCanonicalCookie call. | 704 // Task class for DeleteCanonicalCookie call. |
| 674 class CookieMonster::DeleteCanonicalCookieTask | 705 class CookieMonster::DeleteCanonicalCookieTask : public DeleteTask<bool> { |
| 675 : public CookieMonster::CookieMonsterTask { | |
| 676 public: | 706 public: |
| 677 DeleteCanonicalCookieTask(CookieMonster* cookie_monster, | 707 DeleteCanonicalCookieTask(CookieMonster* cookie_monster, |
| 678 const CanonicalCookie& cookie, | 708 const CanonicalCookie& cookie, |
| 679 const CookieMonster::DeleteCookieCallback& callback) | 709 const DeleteCookieCallback& callback) |
| 680 : CookieMonsterTask(cookie_monster), | 710 : DeleteTask(cookie_monster, callback), |
| 681 cookie_(cookie), | 711 cookie_(cookie) { |
| 682 callback_(callback) { | |
| 683 } | 712 } |
| 684 | 713 |
| 685 // CookieMonster::CookieMonsterTask: | 714 // DeleteTask: |
| 686 virtual void Run() OVERRIDE; | 715 virtual bool RunDeleteTask() OVERRIDE; |
| 687 | 716 |
| 688 protected: | 717 protected: |
| 689 virtual ~DeleteCanonicalCookieTask() {} | 718 virtual ~DeleteCanonicalCookieTask() {} |
| 690 | 719 |
| 691 private: | 720 private: |
| 692 CanonicalCookie cookie_; | 721 CanonicalCookie cookie_; |
| 693 CookieMonster::DeleteCookieCallback callback_; | |
| 694 | 722 |
| 695 DISALLOW_COPY_AND_ASSIGN(DeleteCanonicalCookieTask); | 723 DISALLOW_COPY_AND_ASSIGN(DeleteCanonicalCookieTask); |
| 696 }; | 724 }; |
| 697 | 725 |
| 698 void CookieMonster::DeleteCanonicalCookieTask::Run() { | 726 bool CookieMonster::DeleteCanonicalCookieTask::RunDeleteTask() { |
| 699 bool result = this->cookie_monster()->DeleteCanonicalCookie(cookie_); | 727 return this->cookie_monster()->DeleteCanonicalCookie(cookie_); |
| 700 if (!callback_.is_null()) { | |
| 701 this->InvokeCallback(base::Bind(&CookieMonster::DeleteCookieCallback::Run, | |
| 702 base::Unretained(&callback_), result)); | |
| 703 } | |
| 704 } | 728 } |
| 705 | 729 |
| 706 // Task class for SetCookieWithOptions call. | 730 // Task class for SetCookieWithOptions call. |
| 707 class CookieMonster::SetCookieWithOptionsTask | 731 class CookieMonster::SetCookieWithOptionsTask : public CookieMonsterTask { |
| 708 : public CookieMonster::CookieMonsterTask { | |
| 709 public: | 732 public: |
| 710 SetCookieWithOptionsTask(CookieMonster* cookie_monster, | 733 SetCookieWithOptionsTask(CookieMonster* cookie_monster, |
| 711 const GURL& url, | 734 const GURL& url, |
| 712 const std::string& cookie_line, | 735 const std::string& cookie_line, |
| 713 const CookieOptions& options, | 736 const CookieOptions& options, |
| 714 const CookieMonster::SetCookiesCallback& callback) | 737 const SetCookiesCallback& callback) |
| 715 : CookieMonsterTask(cookie_monster), | 738 : CookieMonsterTask(cookie_monster), |
| 716 url_(url), | 739 url_(url), |
| 717 cookie_line_(cookie_line), | 740 cookie_line_(cookie_line), |
| 718 options_(options), | 741 options_(options), |
| 719 callback_(callback) { | 742 callback_(callback) { |
| 720 } | 743 } |
| 721 | 744 |
| 722 // CookieMonster::CookieMonsterTask: | 745 // CookieMonsterTask: |
| 723 virtual void Run() OVERRIDE; | 746 virtual void Run() OVERRIDE; |
| 724 | 747 |
| 725 protected: | 748 protected: |
| 726 virtual ~SetCookieWithOptionsTask() {} | 749 virtual ~SetCookieWithOptionsTask() {} |
| 727 | 750 |
| 728 private: | 751 private: |
| 729 GURL url_; | 752 GURL url_; |
| 730 std::string cookie_line_; | 753 std::string cookie_line_; |
| 731 CookieOptions options_; | 754 CookieOptions options_; |
| 732 CookieMonster::SetCookiesCallback callback_; | 755 SetCookiesCallback callback_; |
| 733 | 756 |
| 734 DISALLOW_COPY_AND_ASSIGN(SetCookieWithOptionsTask); | 757 DISALLOW_COPY_AND_ASSIGN(SetCookieWithOptionsTask); |
| 735 }; | 758 }; |
| 736 | 759 |
| 737 void CookieMonster::SetCookieWithOptionsTask::Run() { | 760 void CookieMonster::SetCookieWithOptionsTask::Run() { |
| 738 bool result = this->cookie_monster()-> | 761 bool result = this->cookie_monster()-> |
| 739 SetCookieWithOptions(url_, cookie_line_, options_); | 762 SetCookieWithOptions(url_, cookie_line_, options_); |
| 740 if (!callback_.is_null()) { | 763 if (!callback_.is_null()) { |
| 741 this->InvokeCallback(base::Bind(&CookieMonster::SetCookiesCallback::Run, | 764 this->InvokeCallback(base::Bind(&SetCookiesCallback::Run, |
| 742 base::Unretained(&callback_), result)); | 765 base::Unretained(&callback_), result)); |
| 743 } | 766 } |
| 744 } | 767 } |
| 745 | 768 |
| 746 // Task class for GetCookiesWithOptions call. | 769 // Task class for GetCookiesWithOptions call. |
| 747 class CookieMonster::GetCookiesWithOptionsTask | 770 class CookieMonster::GetCookiesWithOptionsTask : public CookieMonsterTask { |
| 748 : public CookieMonster::CookieMonsterTask { | |
| 749 public: | 771 public: |
| 750 GetCookiesWithOptionsTask(CookieMonster* cookie_monster, | 772 GetCookiesWithOptionsTask(CookieMonster* cookie_monster, |
| 751 const GURL& url, | 773 const GURL& url, |
| 752 const CookieOptions& options, | 774 const CookieOptions& options, |
| 753 const CookieMonster::GetCookiesCallback& callback) | 775 const GetCookiesCallback& callback) |
| 754 : CookieMonsterTask(cookie_monster), | 776 : CookieMonsterTask(cookie_monster), |
| 755 url_(url), | 777 url_(url), |
| 756 options_(options), | 778 options_(options), |
| 757 callback_(callback) { | 779 callback_(callback) { |
| 758 } | 780 } |
| 759 | 781 |
| 760 // CookieMonster::CookieMonsterTask: | 782 // CookieMonsterTask: |
| 761 virtual void Run() OVERRIDE; | 783 virtual void Run() OVERRIDE; |
| 762 | 784 |
| 763 protected: | 785 protected: |
| 764 virtual ~GetCookiesWithOptionsTask() {} | 786 virtual ~GetCookiesWithOptionsTask() {} |
| 765 | 787 |
| 766 private: | 788 private: |
| 767 GURL url_; | 789 GURL url_; |
| 768 CookieOptions options_; | 790 CookieOptions options_; |
| 769 CookieMonster::GetCookiesCallback callback_; | 791 GetCookiesCallback callback_; |
| 770 | 792 |
| 771 DISALLOW_COPY_AND_ASSIGN(GetCookiesWithOptionsTask); | 793 DISALLOW_COPY_AND_ASSIGN(GetCookiesWithOptionsTask); |
| 772 }; | 794 }; |
| 773 | 795 |
| 774 void CookieMonster::GetCookiesWithOptionsTask::Run() { | 796 void CookieMonster::GetCookiesWithOptionsTask::Run() { |
| 775 std::string cookie = this->cookie_monster()-> | 797 std::string cookie = this->cookie_monster()-> |
| 776 GetCookiesWithOptions(url_, options_); | 798 GetCookiesWithOptions(url_, options_); |
| 777 if (!callback_.is_null()) { | 799 if (!callback_.is_null()) { |
| 778 this->InvokeCallback(base::Bind(&CookieMonster::GetCookiesCallback::Run, | 800 this->InvokeCallback(base::Bind(&GetCookiesCallback::Run, |
| 779 base::Unretained(&callback_), cookie)); | 801 base::Unretained(&callback_), cookie)); |
| 780 } | 802 } |
| 781 } | 803 } |
| 782 | 804 |
| 783 // Task class for DeleteCookie call. | 805 // Task class for DeleteCookie call. |
| 784 class CookieMonster::DeleteCookieTask | 806 class CookieMonster::DeleteCookieTask : public DeleteTask<void> { |
| 785 : public CookieMonster::CookieMonsterTask { | |
| 786 public: | 807 public: |
| 787 DeleteCookieTask(CookieMonster* cookie_monster, | 808 DeleteCookieTask(CookieMonster* cookie_monster, |
| 788 const GURL& url, | 809 const GURL& url, |
| 789 const std::string& cookie_name, | 810 const std::string& cookie_name, |
| 790 const base::Closure& callback) | 811 const base::Closure& callback) |
| 791 : CookieMonsterTask(cookie_monster), | 812 : DeleteTask(cookie_monster, callback), |
| 792 url_(url), | 813 url_(url), |
| 793 cookie_name_(cookie_name), | 814 cookie_name_(cookie_name) { |
| 794 callback_(callback) { } | 815 } |
| 795 | 816 |
| 796 // CookieMonster::CookieMonsterTask: | 817 // DeleteTask: |
| 797 virtual void Run() OVERRIDE; | 818 virtual void RunDeleteTask() OVERRIDE; |
| 798 | 819 |
| 799 protected: | 820 protected: |
| 800 virtual ~DeleteCookieTask() {} | 821 virtual ~DeleteCookieTask() {} |
| 801 | 822 |
| 802 private: | 823 private: |
| 803 GURL url_; | 824 GURL url_; |
| 804 std::string cookie_name_; | 825 std::string cookie_name_; |
| 805 base::Closure callback_; | |
| 806 | 826 |
| 807 DISALLOW_COPY_AND_ASSIGN(DeleteCookieTask); | 827 DISALLOW_COPY_AND_ASSIGN(DeleteCookieTask); |
| 808 }; | 828 }; |
| 809 | 829 |
| 810 void CookieMonster::DeleteCookieTask::Run() { | 830 void CookieMonster::DeleteCookieTask::RunDeleteTask() { |
| 811 this->cookie_monster()->DeleteCookie(url_, cookie_name_); | 831 this->cookie_monster()->DeleteCookie(url_, cookie_name_); |
| 812 if (!callback_.is_null()) { | |
| 813 this->InvokeCallback(callback_); | |
| 814 } | |
| 815 } | 832 } |
| 816 | 833 |
| 817 // Task class for DeleteSessionCookies call. | 834 // Task class for DeleteSessionCookies call. |
| 818 class CookieMonster::DeleteSessionCookiesTask | 835 class CookieMonster::DeleteSessionCookiesTask : public DeleteTask<int> { |
| 819 : public CookieMonster::CookieMonsterTask { | |
| 820 public: | 836 public: |
| 821 DeleteSessionCookiesTask(CookieMonster* cookie_monster, | 837 DeleteSessionCookiesTask(CookieMonster* cookie_monster, |
| 822 const CookieMonster::DeleteCallback& callback) | 838 const DeleteCallback& callback) |
| 823 : CookieMonsterTask(cookie_monster), callback_(callback) { | 839 : DeleteTask(cookie_monster, callback) { |
| 824 } | 840 } |
| 825 | 841 |
| 826 // CookieMonster::CookieMonsterTask: | 842 // DeleteTask: |
| 827 virtual void Run() OVERRIDE; | 843 virtual int RunDeleteTask() OVERRIDE; |
| 828 | 844 |
| 829 protected: | 845 protected: |
| 830 virtual ~DeleteSessionCookiesTask() {} | 846 virtual ~DeleteSessionCookiesTask() {} |
| 831 | 847 |
| 832 private: | 848 private: |
| 833 CookieMonster::DeleteCallback callback_; | |
| 834 | 849 |
| 835 DISALLOW_COPY_AND_ASSIGN(DeleteSessionCookiesTask); | 850 DISALLOW_COPY_AND_ASSIGN(DeleteSessionCookiesTask); |
| 836 }; | 851 }; |
| 837 | 852 |
| 838 void CookieMonster::DeleteSessionCookiesTask::Run() { | 853 int CookieMonster::DeleteSessionCookiesTask::RunDeleteTask() { |
| 839 int num_deleted = this->cookie_monster()->DeleteSessionCookies(); | 854 return this->cookie_monster()->DeleteSessionCookies(); |
| 840 if (!callback_.is_null()) { | |
| 841 this->InvokeCallback(base::Bind(&CookieMonster::DeleteCallback::Run, | |
| 842 base::Unretained(&callback_), num_deleted)); | |
| 843 } | |
| 844 } | 855 } |
| 845 | 856 |
| 846 // Task class for HasCookiesForETLDP1Task call. | 857 // Task class for HasCookiesForETLDP1Task call. |
| 847 class CookieMonster::HasCookiesForETLDP1Task | 858 class CookieMonster::HasCookiesForETLDP1Task : public CookieMonsterTask { |
| 848 : public CookieMonster::CookieMonsterTask { | |
| 849 public: | 859 public: |
| 850 HasCookiesForETLDP1Task( | 860 HasCookiesForETLDP1Task( |
| 851 CookieMonster* cookie_monster, | 861 CookieMonster* cookie_monster, |
| 852 const std::string& etldp1, | 862 const std::string& etldp1, |
| 853 const CookieMonster::HasCookiesForETLDP1Callback& callback) | 863 const HasCookiesForETLDP1Callback& callback) |
| 854 : CookieMonsterTask(cookie_monster), | 864 : CookieMonsterTask(cookie_monster), |
| 855 etldp1_(etldp1), | 865 etldp1_(etldp1), |
| 856 callback_(callback) { | 866 callback_(callback) { |
| 857 } | 867 } |
| 858 | 868 |
| 859 // CookieMonster::CookieMonsterTask: | 869 // CookieMonsterTask: |
| 860 virtual void Run() OVERRIDE; | 870 virtual void Run() OVERRIDE; |
| 861 | 871 |
| 862 protected: | 872 protected: |
| 863 virtual ~HasCookiesForETLDP1Task() {} | 873 virtual ~HasCookiesForETLDP1Task() {} |
| 864 | 874 |
| 865 private: | 875 private: |
| 866 std::string etldp1_; | 876 std::string etldp1_; |
| 867 CookieMonster::HasCookiesForETLDP1Callback callback_; | 877 HasCookiesForETLDP1Callback callback_; |
| 868 | 878 |
| 869 DISALLOW_COPY_AND_ASSIGN(HasCookiesForETLDP1Task); | 879 DISALLOW_COPY_AND_ASSIGN(HasCookiesForETLDP1Task); |
| 870 }; | 880 }; |
| 871 | 881 |
| 872 void CookieMonster::HasCookiesForETLDP1Task::Run() { | 882 void CookieMonster::HasCookiesForETLDP1Task::Run() { |
| 873 bool result = this->cookie_monster()->HasCookiesForETLDP1(etldp1_); | 883 bool result = this->cookie_monster()->HasCookiesForETLDP1(etldp1_); |
| 874 if (!callback_.is_null()) { | 884 if (!callback_.is_null()) { |
| 875 this->InvokeCallback( | 885 this->InvokeCallback( |
| 876 base::Bind(&CookieMonster::HasCookiesForETLDP1Callback::Run, | 886 base::Bind(&HasCookiesForETLDP1Callback::Run, |
| 877 base::Unretained(&callback_), result)); | 887 base::Unretained(&callback_), result)); |
| 878 } | 888 } |
| 879 } | 889 } |
| 880 | 890 |
| 881 // Asynchronous CookieMonster API | 891 // Asynchronous CookieMonster API |
| 882 | 892 |
| 883 void CookieMonster::SetCookieWithDetailsAsync( | 893 void CookieMonster::SetCookieWithDetailsAsync( |
| 884 const GURL& url, | 894 const GURL& url, |
| 885 const std::string& name, | 895 const std::string& name, |
| 886 const std::string& value, | 896 const std::string& value, |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1632 } | 1642 } |
| 1633 DCHECK_EQ(num_duplicates, num_duplicates_found); | 1643 DCHECK_EQ(num_duplicates, num_duplicates_found); |
| 1634 | 1644 |
| 1635 return num_duplicates; | 1645 return num_duplicates; |
| 1636 } | 1646 } |
| 1637 | 1647 |
| 1638 // Note: file must be the last scheme. | 1648 // Note: file must be the last scheme. |
| 1639 const char* CookieMonster::kDefaultCookieableSchemes[] = | 1649 const char* CookieMonster::kDefaultCookieableSchemes[] = |
| 1640 { "http", "https", "file" }; | 1650 { "http", "https", "file" }; |
| 1641 const int CookieMonster::kDefaultCookieableSchemesCount = | 1651 const int CookieMonster::kDefaultCookieableSchemesCount = |
| 1642 arraysize(CookieMonster::kDefaultCookieableSchemes); | 1652 arraysize(kDefaultCookieableSchemes); |
| 1643 | 1653 |
| 1644 void CookieMonster::SetDefaultCookieableSchemes() { | 1654 void CookieMonster::SetDefaultCookieableSchemes() { |
| 1645 int num_schemes = default_enable_file_scheme_ ? | 1655 int num_schemes = default_enable_file_scheme_ ? |
| 1646 kDefaultCookieableSchemesCount : kDefaultCookieableSchemesCount - 1; | 1656 kDefaultCookieableSchemesCount : kDefaultCookieableSchemesCount - 1; |
| 1647 SetCookieableSchemes(kDefaultCookieableSchemes, num_schemes); | 1657 SetCookieableSchemes(kDefaultCookieableSchemes, num_schemes); |
| 1648 } | 1658 } |
| 1649 | 1659 |
| 1650 void CookieMonster::FindCookiesForHostAndDomain( | 1660 void CookieMonster::FindCookiesForHostAndDomain( |
| 1651 const GURL& url, | 1661 const GURL& url, |
| 1652 const CookieOptions& options, | 1662 const CookieOptions& options, |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1737 CanonicalCookie* cc, | 1747 CanonicalCookie* cc, |
| 1738 bool sync_to_store) { | 1748 bool sync_to_store) { |
| 1739 lock_.AssertAcquired(); | 1749 lock_.AssertAcquired(); |
| 1740 | 1750 |
| 1741 if ((cc->IsPersistent() || persist_session_cookies_) && store_.get() && | 1751 if ((cc->IsPersistent() || persist_session_cookies_) && store_.get() && |
| 1742 sync_to_store) | 1752 sync_to_store) |
| 1743 store_->AddCookie(*cc); | 1753 store_->AddCookie(*cc); |
| 1744 cookies_.insert(CookieMap::value_type(key, cc)); | 1754 cookies_.insert(CookieMap::value_type(key, cc)); |
| 1745 if (delegate_.get()) { | 1755 if (delegate_.get()) { |
| 1746 delegate_->OnCookieChanged( | 1756 delegate_->OnCookieChanged( |
| 1747 *cc, false, CookieMonster::Delegate::CHANGE_COOKIE_EXPLICIT); | 1757 *cc, false, Delegate::CHANGE_COOKIE_EXPLICIT); |
| 1748 } | 1758 } |
| 1749 } | 1759 } |
| 1750 | 1760 |
| 1751 bool CookieMonster::SetCookieWithCreationTimeAndOptions( | 1761 bool CookieMonster::SetCookieWithCreationTimeAndOptions( |
| 1752 const GURL& url, | 1762 const GURL& url, |
| 1753 const std::string& cookie_line, | 1763 const std::string& cookie_line, |
| 1754 const Time& creation_time_or_null, | 1764 const Time& creation_time_or_null, |
| 1755 const CookieOptions& options) { | 1765 const CookieOptions& options) { |
| 1756 lock_.AssertAcquired(); | 1766 lock_.AssertAcquired(); |
| 1757 | 1767 |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2008 cookie_its->push_back(curit); | 2018 cookie_its->push_back(curit); |
| 2009 } | 2019 } |
| 2010 } | 2020 } |
| 2011 | 2021 |
| 2012 return num_deleted; | 2022 return num_deleted; |
| 2013 } | 2023 } |
| 2014 | 2024 |
| 2015 int CookieMonster::GarbageCollectDeleteRange( | 2025 int CookieMonster::GarbageCollectDeleteRange( |
| 2016 const Time& current, | 2026 const Time& current, |
| 2017 DeletionCause cause, | 2027 DeletionCause cause, |
| 2018 CookieMonster::CookieItVector::iterator it_begin, | 2028 CookieItVector::iterator it_begin, |
| 2019 CookieMonster::CookieItVector::iterator it_end) { | 2029 CookieItVector::iterator it_end) { |
| 2020 for (CookieItVector::iterator it = it_begin; it != it_end; it++) { | 2030 for (CookieItVector::iterator it = it_begin; it != it_end; it++) { |
| 2021 histogram_evicted_last_access_minutes_->Add( | 2031 histogram_evicted_last_access_minutes_->Add( |
| 2022 (current - (*it)->second->LastAccessDate()).InMinutes()); | 2032 (current - (*it)->second->LastAccessDate()).InMinutes()); |
| 2023 InternalDeleteCookie((*it), true, cause); | 2033 InternalDeleteCookie((*it), true, cause); |
| 2024 } | 2034 } |
| 2025 return it_end - it_begin; | 2035 return it_end - it_begin; |
| 2026 } | 2036 } |
| 2027 | 2037 |
| 2028 // A wrapper around registry_controlled_domains::GetDomainAndRegistry | 2038 // A wrapper around registry_controlled_domains::GetDomainAndRegistry |
| 2029 // to make clear we're creating a key for our local map. Here and | 2039 // to make clear we're creating a key for our local map. Here and |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2214 | 2224 |
| 2215 // The system resolution is not high enough, so we can have multiple | 2225 // The system resolution is not high enough, so we can have multiple |
| 2216 // set cookies that result in the same system time. When this happens, we | 2226 // set cookies that result in the same system time. When this happens, we |
| 2217 // increment by one Time unit. Let's hope computers don't get too fast. | 2227 // increment by one Time unit. Let's hope computers don't get too fast. |
| 2218 Time CookieMonster::CurrentTime() { | 2228 Time CookieMonster::CurrentTime() { |
| 2219 return std::max(Time::Now(), | 2229 return std::max(Time::Now(), |
| 2220 Time::FromInternalValue(last_time_seen_.ToInternalValue() + 1)); | 2230 Time::FromInternalValue(last_time_seen_.ToInternalValue() + 1)); |
| 2221 } | 2231 } |
| 2222 | 2232 |
| 2223 } // namespace net | 2233 } // namespace net |
| OLD | NEW |