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 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 if (!callback.is_null()) { | 586 if (!callback.is_null()) { |
587 this->InvokeCallback(callback); | 587 this->InvokeCallback(callback); |
588 } | 588 } |
589 } | 589 } |
590 | 590 |
591 // Task class for DeleteAll call. | 591 // Task class for DeleteAll call. |
592 class CookieMonster::DeleteAllTask : public DeleteTask<int> { | 592 class CookieMonster::DeleteAllTask : public DeleteTask<int> { |
593 public: | 593 public: |
594 DeleteAllTask(CookieMonster* cookie_monster, | 594 DeleteAllTask(CookieMonster* cookie_monster, |
595 const DeleteCallback& callback) | 595 const DeleteCallback& callback) |
596 : DeleteTask(cookie_monster, callback) { | 596 : DeleteTask<int>(cookie_monster, callback) { |
597 } | 597 } |
598 | 598 |
599 // DeleteTask: | 599 // DeleteTask: |
600 virtual int RunDeleteTask() OVERRIDE; | 600 virtual int RunDeleteTask() OVERRIDE; |
601 | 601 |
602 protected: | 602 protected: |
603 virtual ~DeleteAllTask() {} | 603 virtual ~DeleteAllTask() {} |
604 | 604 |
605 private: | 605 private: |
606 DISALLOW_COPY_AND_ASSIGN(DeleteAllTask); | 606 DISALLOW_COPY_AND_ASSIGN(DeleteAllTask); |
607 }; | 607 }; |
608 | 608 |
609 int CookieMonster::DeleteAllTask::RunDeleteTask() { | 609 int CookieMonster::DeleteAllTask::RunDeleteTask() { |
610 return this->cookie_monster()->DeleteAll(true); | 610 return this->cookie_monster()->DeleteAll(true); |
611 } | 611 } |
612 | 612 |
613 // Task class for DeleteAllCreatedBetween call. | 613 // Task class for DeleteAllCreatedBetween call. |
614 class CookieMonster::DeleteAllCreatedBetweenTask : public DeleteTask<int> { | 614 class CookieMonster::DeleteAllCreatedBetweenTask : public DeleteTask<int> { |
615 public: | 615 public: |
616 DeleteAllCreatedBetweenTask(CookieMonster* cookie_monster, | 616 DeleteAllCreatedBetweenTask(CookieMonster* cookie_monster, |
617 const Time& delete_begin, | 617 const Time& delete_begin, |
618 const Time& delete_end, | 618 const Time& delete_end, |
619 const DeleteCallback& callback) | 619 const DeleteCallback& callback) |
620 : DeleteTask(cookie_monster, callback), | 620 : DeleteTask<int>(cookie_monster, callback), |
621 delete_begin_(delete_begin), | 621 delete_begin_(delete_begin), |
622 delete_end_(delete_end) { | 622 delete_end_(delete_end) { |
623 } | 623 } |
624 | 624 |
625 // DeleteTask: | 625 // DeleteTask: |
626 virtual int RunDeleteTask() OVERRIDE; | 626 virtual int RunDeleteTask() OVERRIDE; |
627 | 627 |
628 protected: | 628 protected: |
629 virtual ~DeleteAllCreatedBetweenTask() {} | 629 virtual ~DeleteAllCreatedBetweenTask() {} |
630 | 630 |
631 private: | 631 private: |
632 Time delete_begin_; | 632 Time delete_begin_; |
633 Time delete_end_; | 633 Time delete_end_; |
634 | 634 |
635 DISALLOW_COPY_AND_ASSIGN(DeleteAllCreatedBetweenTask); | 635 DISALLOW_COPY_AND_ASSIGN(DeleteAllCreatedBetweenTask); |
636 }; | 636 }; |
637 | 637 |
638 int CookieMonster::DeleteAllCreatedBetweenTask::RunDeleteTask() { | 638 int CookieMonster::DeleteAllCreatedBetweenTask::RunDeleteTask() { |
639 return this->cookie_monster()-> | 639 return this->cookie_monster()-> |
640 DeleteAllCreatedBetween(delete_begin_, delete_end_); | 640 DeleteAllCreatedBetween(delete_begin_, delete_end_); |
641 } | 641 } |
642 | 642 |
643 // Task class for DeleteAllForHost call. | 643 // Task class for DeleteAllForHost call. |
644 class CookieMonster::DeleteAllForHostTask : public DeleteTask<int> { | 644 class CookieMonster::DeleteAllForHostTask : public DeleteTask<int> { |
645 public: | 645 public: |
646 DeleteAllForHostTask(CookieMonster* cookie_monster, | 646 DeleteAllForHostTask(CookieMonster* cookie_monster, |
647 const GURL& url, | 647 const GURL& url, |
648 const DeleteCallback& callback) | 648 const DeleteCallback& callback) |
649 : DeleteTask(cookie_monster, callback), | 649 : DeleteTask<int>(cookie_monster, callback), |
650 url_(url) { | 650 url_(url) { |
651 } | 651 } |
652 | 652 |
653 // DeleteTask: | 653 // DeleteTask: |
654 virtual int RunDeleteTask() OVERRIDE; | 654 virtual int RunDeleteTask() OVERRIDE; |
655 | 655 |
656 protected: | 656 protected: |
657 virtual ~DeleteAllForHostTask() {} | 657 virtual ~DeleteAllForHostTask() {} |
658 | 658 |
659 private: | 659 private: |
660 GURL url_; | 660 GURL url_; |
661 | 661 |
662 DISALLOW_COPY_AND_ASSIGN(DeleteAllForHostTask); | 662 DISALLOW_COPY_AND_ASSIGN(DeleteAllForHostTask); |
663 }; | 663 }; |
664 | 664 |
665 int CookieMonster::DeleteAllForHostTask::RunDeleteTask() { | 665 int CookieMonster::DeleteAllForHostTask::RunDeleteTask() { |
666 return this->cookie_monster()->DeleteAllForHost(url_); | 666 return this->cookie_monster()->DeleteAllForHost(url_); |
667 } | 667 } |
668 | 668 |
669 // Task class for DeleteAllCreatedBetweenForHost call. | 669 // Task class for DeleteAllCreatedBetweenForHost call. |
670 class CookieMonster::DeleteAllCreatedBetweenForHostTask | 670 class CookieMonster::DeleteAllCreatedBetweenForHostTask |
671 : public DeleteTask<int> { | 671 : public DeleteTask<int> { |
672 public: | 672 public: |
673 DeleteAllCreatedBetweenForHostTask( | 673 DeleteAllCreatedBetweenForHostTask( |
674 CookieMonster* cookie_monster, | 674 CookieMonster* cookie_monster, |
675 Time delete_begin, | 675 Time delete_begin, |
676 Time delete_end, | 676 Time delete_end, |
677 const GURL& url, | 677 const GURL& url, |
678 const DeleteCallback& callback) | 678 const DeleteCallback& callback) |
679 : DeleteTask(cookie_monster, callback), | 679 : DeleteTask<int>(cookie_monster, callback), |
680 delete_begin_(delete_begin), | 680 delete_begin_(delete_begin), |
681 delete_end_(delete_end), | 681 delete_end_(delete_end), |
682 url_(url) { | 682 url_(url) { |
683 } | 683 } |
684 | 684 |
685 // DeleteTask: | 685 // DeleteTask: |
686 virtual int RunDeleteTask() OVERRIDE; | 686 virtual int RunDeleteTask() OVERRIDE; |
687 | 687 |
688 protected: | 688 protected: |
689 virtual ~DeleteAllCreatedBetweenForHostTask() {} | 689 virtual ~DeleteAllCreatedBetweenForHostTask() {} |
(...skipping 10 matching lines...) Expand all Loading... |
700 return this->cookie_monster()->DeleteAllCreatedBetweenForHost( | 700 return this->cookie_monster()->DeleteAllCreatedBetweenForHost( |
701 delete_begin_, delete_end_, url_); | 701 delete_begin_, delete_end_, url_); |
702 } | 702 } |
703 | 703 |
704 // Task class for DeleteCanonicalCookie call. | 704 // Task class for DeleteCanonicalCookie call. |
705 class CookieMonster::DeleteCanonicalCookieTask : public DeleteTask<bool> { | 705 class CookieMonster::DeleteCanonicalCookieTask : public DeleteTask<bool> { |
706 public: | 706 public: |
707 DeleteCanonicalCookieTask(CookieMonster* cookie_monster, | 707 DeleteCanonicalCookieTask(CookieMonster* cookie_monster, |
708 const CanonicalCookie& cookie, | 708 const CanonicalCookie& cookie, |
709 const DeleteCookieCallback& callback) | 709 const DeleteCookieCallback& callback) |
710 : DeleteTask(cookie_monster, callback), | 710 : DeleteTask<bool>(cookie_monster, callback), |
711 cookie_(cookie) { | 711 cookie_(cookie) { |
712 } | 712 } |
713 | 713 |
714 // DeleteTask: | 714 // DeleteTask: |
715 virtual bool RunDeleteTask() OVERRIDE; | 715 virtual bool RunDeleteTask() OVERRIDE; |
716 | 716 |
717 protected: | 717 protected: |
718 virtual ~DeleteCanonicalCookieTask() {} | 718 virtual ~DeleteCanonicalCookieTask() {} |
719 | 719 |
720 private: | 720 private: |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 } | 802 } |
803 } | 803 } |
804 | 804 |
805 // Task class for DeleteCookie call. | 805 // Task class for DeleteCookie call. |
806 class CookieMonster::DeleteCookieTask : public DeleteTask<void> { | 806 class CookieMonster::DeleteCookieTask : public DeleteTask<void> { |
807 public: | 807 public: |
808 DeleteCookieTask(CookieMonster* cookie_monster, | 808 DeleteCookieTask(CookieMonster* cookie_monster, |
809 const GURL& url, | 809 const GURL& url, |
810 const std::string& cookie_name, | 810 const std::string& cookie_name, |
811 const base::Closure& callback) | 811 const base::Closure& callback) |
812 : DeleteTask(cookie_monster, callback), | 812 : DeleteTask<void>(cookie_monster, callback), |
813 url_(url), | 813 url_(url), |
814 cookie_name_(cookie_name) { | 814 cookie_name_(cookie_name) { |
815 } | 815 } |
816 | 816 |
817 // DeleteTask: | 817 // DeleteTask: |
818 virtual void RunDeleteTask() OVERRIDE; | 818 virtual void RunDeleteTask() OVERRIDE; |
819 | 819 |
820 protected: | 820 protected: |
821 virtual ~DeleteCookieTask() {} | 821 virtual ~DeleteCookieTask() {} |
822 | 822 |
823 private: | 823 private: |
824 GURL url_; | 824 GURL url_; |
825 std::string cookie_name_; | 825 std::string cookie_name_; |
826 | 826 |
827 DISALLOW_COPY_AND_ASSIGN(DeleteCookieTask); | 827 DISALLOW_COPY_AND_ASSIGN(DeleteCookieTask); |
828 }; | 828 }; |
829 | 829 |
830 void CookieMonster::DeleteCookieTask::RunDeleteTask() { | 830 void CookieMonster::DeleteCookieTask::RunDeleteTask() { |
831 this->cookie_monster()->DeleteCookie(url_, cookie_name_); | 831 this->cookie_monster()->DeleteCookie(url_, cookie_name_); |
832 } | 832 } |
833 | 833 |
834 // Task class for DeleteSessionCookies call. | 834 // Task class for DeleteSessionCookies call. |
835 class CookieMonster::DeleteSessionCookiesTask : public DeleteTask<int> { | 835 class CookieMonster::DeleteSessionCookiesTask : public DeleteTask<int> { |
836 public: | 836 public: |
837 DeleteSessionCookiesTask(CookieMonster* cookie_monster, | 837 DeleteSessionCookiesTask(CookieMonster* cookie_monster, |
838 const DeleteCallback& callback) | 838 const DeleteCallback& callback) |
839 : DeleteTask(cookie_monster, callback) { | 839 : DeleteTask<int>(cookie_monster, callback) { |
840 } | 840 } |
841 | 841 |
842 // DeleteTask: | 842 // DeleteTask: |
843 virtual int RunDeleteTask() OVERRIDE; | 843 virtual int RunDeleteTask() OVERRIDE; |
844 | 844 |
845 protected: | 845 protected: |
846 virtual ~DeleteSessionCookiesTask() {} | 846 virtual ~DeleteSessionCookiesTask() {} |
847 | 847 |
848 private: | 848 private: |
849 | 849 |
(...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2246 | 2246 |
2247 // The system resolution is not high enough, so we can have multiple | 2247 // The system resolution is not high enough, so we can have multiple |
2248 // set cookies that result in the same system time. When this happens, we | 2248 // set cookies that result in the same system time. When this happens, we |
2249 // increment by one Time unit. Let's hope computers don't get too fast. | 2249 // increment by one Time unit. Let's hope computers don't get too fast. |
2250 Time CookieMonster::CurrentTime() { | 2250 Time CookieMonster::CurrentTime() { |
2251 return std::max(Time::Now(), | 2251 return std::max(Time::Now(), |
2252 Time::FromInternalValue(last_time_seen_.ToInternalValue() + 1)); | 2252 Time::FromInternalValue(last_time_seen_.ToInternalValue() + 1)); |
2253 } | 2253 } |
2254 | 2254 |
2255 } // namespace net | 2255 } // namespace net |
OLD | NEW |