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 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 // Invokes the callback immediately, if the current thread is the one | 525 // Invokes the callback immediately, if the current thread is the one |
526 // that originated the task, or queues the callback for execution on the | 526 // that originated the task, or queues the callback for execution on the |
527 // appropriate thread. Maintains a reference to this CookieMonsterTask | 527 // appropriate thread. Maintains a reference to this CookieMonsterTask |
528 // instance until the callback completes. | 528 // instance until the callback completes. |
529 void InvokeCallback(base::Closure callback); | 529 void InvokeCallback(base::Closure callback); |
530 | 530 |
531 CookieMonster* cookie_monster() { | 531 CookieMonster* cookie_monster() { |
532 return cookie_monster_; | 532 return cookie_monster_; |
533 } | 533 } |
534 | 534 |
| 535 private: |
535 friend class base::RefCountedThreadSafe<CookieMonsterTask>; | 536 friend class base::RefCountedThreadSafe<CookieMonsterTask>; |
536 | 537 |
537 private: | |
538 CookieMonster* cookie_monster_; | 538 CookieMonster* cookie_monster_; |
539 scoped_refptr<base::MessageLoopProxy> thread_; | 539 scoped_refptr<base::MessageLoopProxy> thread_; |
540 | 540 |
541 DISALLOW_COPY_AND_ASSIGN(CookieMonsterTask); | 541 DISALLOW_COPY_AND_ASSIGN(CookieMonsterTask); |
542 }; | 542 }; |
543 | 543 |
544 CookieMonster::CookieMonsterTask::CookieMonsterTask( | 544 CookieMonster::CookieMonsterTask::CookieMonsterTask( |
545 CookieMonster* cookie_monster) | 545 CookieMonster* cookie_monster) |
546 : cookie_monster_(cookie_monster), | 546 : cookie_monster_(cookie_monster), |
547 thread_(base::MessageLoopProxy::current()) { } | 547 thread_(base::MessageLoopProxy::current()) { |
| 548 } |
548 | 549 |
549 CookieMonster::CookieMonsterTask::~CookieMonsterTask() { } | 550 CookieMonster::CookieMonsterTask::~CookieMonsterTask() {} |
550 | 551 |
551 // Unfortunately, one cannot re-bind a Callback with parameters into a closure. | 552 // Unfortunately, one cannot re-bind a Callback with parameters into a closure. |
552 // Therefore, the closure passed to InvokeCallback is a clumsy binding of | 553 // Therefore, the closure passed to InvokeCallback is a clumsy binding of |
553 // Callback::Run on a wrapped Callback instance. Since Callback is not | 554 // Callback::Run on a wrapped Callback instance. Since Callback is not |
554 // reference counted, we bind to an instance that is a member of the | 555 // reference counted, we bind to an instance that is a member of the |
555 // CookieMonsterTask subclass. Then, we cannot simply post the callback to a | 556 // CookieMonsterTask subclass. Then, we cannot simply post the callback to a |
556 // message loop because the underlying instance may be destroyed (along with the | 557 // message loop because the underlying instance may be destroyed (along with the |
557 // CookieMonsterTask instance) in the interim. Therefore, we post a callback | 558 // CookieMonsterTask instance) in the interim. Therefore, we post a callback |
558 // bound to the CookieMonsterTask, which *is* reference counted (thus preventing | 559 // bound to the CookieMonsterTask, which *is* reference counted (thus preventing |
559 // destruction of the original callback), and which invokes the closure (which | 560 // destruction of the original callback), and which invokes the closure (which |
(...skipping 19 matching lines...) Expand all Loading... |
579 const CookieMonster::SetCookiesCallback& callback) | 580 const CookieMonster::SetCookiesCallback& callback) |
580 : CookieMonsterTask(cookie_monster), | 581 : CookieMonsterTask(cookie_monster), |
581 url_(url), | 582 url_(url), |
582 name_(name), | 583 name_(name), |
583 value_(value), | 584 value_(value), |
584 domain_(domain), | 585 domain_(domain), |
585 path_(path), | 586 path_(path), |
586 expiration_time_(expiration_time), | 587 expiration_time_(expiration_time), |
587 secure_(secure), | 588 secure_(secure), |
588 http_only_(http_only), | 589 http_only_(http_only), |
589 callback_(callback) { } | 590 callback_(callback) { |
| 591 } |
590 | 592 |
| 593 // CookieMonster::CookieMonsterTask: |
591 virtual void Run() OVERRIDE; | 594 virtual void Run() OVERRIDE; |
592 | 595 |
| 596 protected: |
| 597 virtual ~SetCookieWithDetailsTask() {} |
| 598 |
593 private: | 599 private: |
594 GURL url_; | 600 GURL url_; |
595 std::string name_; | 601 std::string name_; |
596 std::string value_; | 602 std::string value_; |
597 std::string domain_; | 603 std::string domain_; |
598 std::string path_; | 604 std::string path_; |
599 base::Time expiration_time_; | 605 base::Time expiration_time_; |
600 bool secure_; | 606 bool secure_; |
601 bool http_only_; | 607 bool http_only_; |
602 CookieMonster::SetCookiesCallback callback_; | 608 CookieMonster::SetCookiesCallback callback_; |
(...skipping 11 matching lines...) Expand all Loading... |
614 } | 620 } |
615 } | 621 } |
616 | 622 |
617 // Task class for GetAllCookies call. | 623 // Task class for GetAllCookies call. |
618 class CookieMonster::GetAllCookiesTask | 624 class CookieMonster::GetAllCookiesTask |
619 : public CookieMonster::CookieMonsterTask { | 625 : public CookieMonster::CookieMonsterTask { |
620 public: | 626 public: |
621 GetAllCookiesTask(CookieMonster* cookie_monster, | 627 GetAllCookiesTask(CookieMonster* cookie_monster, |
622 const CookieMonster::GetCookieListCallback& callback) | 628 const CookieMonster::GetCookieListCallback& callback) |
623 : CookieMonsterTask(cookie_monster), | 629 : CookieMonsterTask(cookie_monster), |
624 callback_(callback) { } | 630 callback_(callback) { |
| 631 } |
625 | 632 |
| 633 // CookieMonster::CookieMonsterTask |
626 virtual void Run() OVERRIDE; | 634 virtual void Run() OVERRIDE; |
627 | 635 |
| 636 protected: |
| 637 virtual ~GetAllCookiesTask() {} |
| 638 |
628 private: | 639 private: |
629 CookieMonster::GetCookieListCallback callback_; | 640 CookieMonster::GetCookieListCallback callback_; |
630 | 641 |
631 DISALLOW_COPY_AND_ASSIGN(GetAllCookiesTask); | 642 DISALLOW_COPY_AND_ASSIGN(GetAllCookiesTask); |
632 }; | 643 }; |
633 | 644 |
634 void CookieMonster::GetAllCookiesTask::Run() { | 645 void CookieMonster::GetAllCookiesTask::Run() { |
635 if (!callback_.is_null()) { | 646 if (!callback_.is_null()) { |
636 CookieList cookies = this->cookie_monster()->GetAllCookies(); | 647 CookieList cookies = this->cookie_monster()->GetAllCookies(); |
637 this->InvokeCallback(base::Bind(&CookieMonster::GetCookieListCallback::Run, | 648 this->InvokeCallback(base::Bind(&CookieMonster::GetCookieListCallback::Run, |
638 base::Unretained(&callback_), cookies)); | 649 base::Unretained(&callback_), cookies)); |
639 } | 650 } |
640 } | 651 } |
641 | 652 |
642 // Task class for GetAllCookiesForURLWithOptions call. | 653 // Task class for GetAllCookiesForURLWithOptions call. |
643 class CookieMonster::GetAllCookiesForURLWithOptionsTask | 654 class CookieMonster::GetAllCookiesForURLWithOptionsTask |
644 : public CookieMonster::CookieMonsterTask { | 655 : public CookieMonster::CookieMonsterTask { |
645 public: | 656 public: |
646 GetAllCookiesForURLWithOptionsTask( | 657 GetAllCookiesForURLWithOptionsTask( |
647 CookieMonster* cookie_monster, | 658 CookieMonster* cookie_monster, |
648 const GURL& url, | 659 const GURL& url, |
649 const CookieOptions& options, | 660 const CookieOptions& options, |
650 const CookieMonster::GetCookieListCallback& callback) | 661 const CookieMonster::GetCookieListCallback& callback) |
651 : CookieMonsterTask(cookie_monster), | 662 : CookieMonsterTask(cookie_monster), |
652 url_(url), | 663 url_(url), |
653 options_(options), | 664 options_(options), |
654 callback_(callback) { } | 665 callback_(callback) { |
| 666 } |
655 | 667 |
| 668 // CookieMonster::CookieMonsterTask: |
656 virtual void Run() OVERRIDE; | 669 virtual void Run() OVERRIDE; |
657 | 670 |
| 671 protected: |
| 672 virtual ~GetAllCookiesForURLWithOptionsTask() {} |
| 673 |
658 private: | 674 private: |
659 GURL url_; | 675 GURL url_; |
660 CookieOptions options_; | 676 CookieOptions options_; |
661 CookieMonster::GetCookieListCallback callback_; | 677 CookieMonster::GetCookieListCallback callback_; |
662 | 678 |
663 DISALLOW_COPY_AND_ASSIGN(GetAllCookiesForURLWithOptionsTask); | 679 DISALLOW_COPY_AND_ASSIGN(GetAllCookiesForURLWithOptionsTask); |
664 }; | 680 }; |
665 | 681 |
666 void CookieMonster::GetAllCookiesForURLWithOptionsTask::Run() { | 682 void CookieMonster::GetAllCookiesForURLWithOptionsTask::Run() { |
667 if (!callback_.is_null()) { | 683 if (!callback_.is_null()) { |
668 CookieList cookies = this->cookie_monster()-> | 684 CookieList cookies = this->cookie_monster()-> |
669 GetAllCookiesForURLWithOptions(url_, options_); | 685 GetAllCookiesForURLWithOptions(url_, options_); |
670 this->InvokeCallback(base::Bind(&CookieMonster::GetCookieListCallback::Run, | 686 this->InvokeCallback(base::Bind(&CookieMonster::GetCookieListCallback::Run, |
671 base::Unretained(&callback_), cookies)); | 687 base::Unretained(&callback_), cookies)); |
672 } | 688 } |
673 } | 689 } |
674 | 690 |
675 // Task class for DeleteAll call. | 691 // Task class for DeleteAll call. |
676 class CookieMonster::DeleteAllTask : public CookieMonster::CookieMonsterTask { | 692 class CookieMonster::DeleteAllTask : public CookieMonster::CookieMonsterTask { |
677 public: | 693 public: |
678 DeleteAllTask(CookieMonster* cookie_monster, | 694 DeleteAllTask(CookieMonster* cookie_monster, |
679 const CookieMonster::DeleteCallback& callback) | 695 const CookieMonster::DeleteCallback& callback) |
680 : CookieMonsterTask(cookie_monster), | 696 : CookieMonsterTask(cookie_monster), |
681 callback_(callback) { } | 697 callback_(callback) { |
| 698 } |
682 | 699 |
| 700 // CookieMonster::CookieMonsterTask: |
683 virtual void Run() OVERRIDE; | 701 virtual void Run() OVERRIDE; |
684 | 702 |
| 703 protected: |
| 704 virtual ~DeleteAllTask() {} |
| 705 |
685 private: | 706 private: |
686 CookieMonster::DeleteCallback callback_; | 707 CookieMonster::DeleteCallback callback_; |
687 | 708 |
688 DISALLOW_COPY_AND_ASSIGN(DeleteAllTask); | 709 DISALLOW_COPY_AND_ASSIGN(DeleteAllTask); |
689 }; | 710 }; |
690 | 711 |
691 void CookieMonster::DeleteAllTask::Run() { | 712 void CookieMonster::DeleteAllTask::Run() { |
692 int num_deleted = this->cookie_monster()->DeleteAll(true); | 713 int num_deleted = this->cookie_monster()->DeleteAll(true); |
693 if (!callback_.is_null()) { | 714 if (!callback_.is_null()) { |
694 this->InvokeCallback(base::Bind(&CookieMonster::DeleteCallback::Run, | 715 this->InvokeCallback(base::Bind(&CookieMonster::DeleteCallback::Run, |
695 base::Unretained(&callback_), num_deleted)); | 716 base::Unretained(&callback_), num_deleted)); |
696 } | 717 } |
697 } | 718 } |
698 | 719 |
699 // Task class for DeleteAllCreatedBetween call. | 720 // Task class for DeleteAllCreatedBetween call. |
700 class CookieMonster::DeleteAllCreatedBetweenTask | 721 class CookieMonster::DeleteAllCreatedBetweenTask |
701 : public CookieMonster::CookieMonsterTask { | 722 : public CookieMonster::CookieMonsterTask { |
702 public: | 723 public: |
703 DeleteAllCreatedBetweenTask( | 724 DeleteAllCreatedBetweenTask( |
704 CookieMonster* cookie_monster, | 725 CookieMonster* cookie_monster, |
705 const Time& delete_begin, | 726 const Time& delete_begin, |
706 const Time& delete_end, | 727 const Time& delete_end, |
707 const CookieMonster::DeleteCallback& callback) | 728 const CookieMonster::DeleteCallback& callback) |
708 : CookieMonsterTask(cookie_monster), | 729 : CookieMonsterTask(cookie_monster), |
709 delete_begin_(delete_begin), | 730 delete_begin_(delete_begin), |
710 delete_end_(delete_end), | 731 delete_end_(delete_end), |
711 callback_(callback) { } | 732 callback_(callback) { |
| 733 } |
712 | 734 |
| 735 // CookieMonster::CookieMonsterTask: |
713 virtual void Run() OVERRIDE; | 736 virtual void Run() OVERRIDE; |
714 | 737 |
| 738 protected: |
| 739 virtual ~DeleteAllCreatedBetweenTask() {} |
| 740 |
715 private: | 741 private: |
716 Time delete_begin_; | 742 Time delete_begin_; |
717 Time delete_end_; | 743 Time delete_end_; |
718 CookieMonster::DeleteCallback callback_; | 744 CookieMonster::DeleteCallback callback_; |
719 | 745 |
720 DISALLOW_COPY_AND_ASSIGN(DeleteAllCreatedBetweenTask); | 746 DISALLOW_COPY_AND_ASSIGN(DeleteAllCreatedBetweenTask); |
721 }; | 747 }; |
722 | 748 |
723 void CookieMonster::DeleteAllCreatedBetweenTask::Run() { | 749 void CookieMonster::DeleteAllCreatedBetweenTask::Run() { |
724 int num_deleted = this->cookie_monster()-> | 750 int num_deleted = this->cookie_monster()-> |
725 DeleteAllCreatedBetween(delete_begin_, delete_end_); | 751 DeleteAllCreatedBetween(delete_begin_, delete_end_); |
726 if (!callback_.is_null()) { | 752 if (!callback_.is_null()) { |
727 this->InvokeCallback(base::Bind(&CookieMonster::DeleteCallback::Run, | 753 this->InvokeCallback(base::Bind(&CookieMonster::DeleteCallback::Run, |
728 base::Unretained(&callback_), num_deleted)); | 754 base::Unretained(&callback_), num_deleted)); |
729 } | 755 } |
730 } | 756 } |
731 | 757 |
732 // Task class for DeleteAllForHost call. | 758 // Task class for DeleteAllForHost call. |
733 class CookieMonster::DeleteAllForHostTask | 759 class CookieMonster::DeleteAllForHostTask |
734 : public CookieMonster::CookieMonsterTask { | 760 : public CookieMonster::CookieMonsterTask { |
735 public: | 761 public: |
736 DeleteAllForHostTask(CookieMonster* cookie_monster, | 762 DeleteAllForHostTask(CookieMonster* cookie_monster, |
737 const GURL& url, | 763 const GURL& url, |
738 const CookieMonster::DeleteCallback& callback) | 764 const CookieMonster::DeleteCallback& callback) |
739 : CookieMonsterTask(cookie_monster), | 765 : CookieMonsterTask(cookie_monster), |
740 url_(url), | 766 url_(url), |
741 callback_(callback) { } | 767 callback_(callback) { |
| 768 } |
742 | 769 |
| 770 // CookieMonster::CookieMonsterTask: |
743 virtual void Run() OVERRIDE; | 771 virtual void Run() OVERRIDE; |
744 | 772 |
| 773 protected: |
| 774 virtual ~DeleteAllForHostTask() {} |
| 775 |
745 private: | 776 private: |
746 GURL url_; | 777 GURL url_; |
747 CookieMonster::DeleteCallback callback_; | 778 CookieMonster::DeleteCallback callback_; |
748 | 779 |
749 DISALLOW_COPY_AND_ASSIGN(DeleteAllForHostTask); | 780 DISALLOW_COPY_AND_ASSIGN(DeleteAllForHostTask); |
750 }; | 781 }; |
751 | 782 |
752 void CookieMonster::DeleteAllForHostTask::Run() { | 783 void CookieMonster::DeleteAllForHostTask::Run() { |
753 int num_deleted = this->cookie_monster()->DeleteAllForHost(url_); | 784 int num_deleted = this->cookie_monster()->DeleteAllForHost(url_); |
754 if (!callback_.is_null()) { | 785 if (!callback_.is_null()) { |
755 this->InvokeCallback(base::Bind(&CookieMonster::DeleteCallback::Run, | 786 this->InvokeCallback(base::Bind(&CookieMonster::DeleteCallback::Run, |
756 base::Unretained(&callback_), num_deleted)); | 787 base::Unretained(&callback_), num_deleted)); |
757 } | 788 } |
758 } | 789 } |
759 | 790 |
760 // Task class for DeleteCanonicalCookie call. | 791 // Task class for DeleteCanonicalCookie call. |
761 class CookieMonster::DeleteCanonicalCookieTask | 792 class CookieMonster::DeleteCanonicalCookieTask |
762 : public CookieMonster::CookieMonsterTask { | 793 : public CookieMonster::CookieMonsterTask { |
763 public: | 794 public: |
764 DeleteCanonicalCookieTask( | 795 DeleteCanonicalCookieTask( |
765 CookieMonster* cookie_monster, | 796 CookieMonster* cookie_monster, |
766 const CookieMonster::CanonicalCookie& cookie, | 797 const CookieMonster::CanonicalCookie& cookie, |
767 const CookieMonster::DeleteCookieCallback& callback) | 798 const CookieMonster::DeleteCookieCallback& callback) |
768 : CookieMonsterTask(cookie_monster), | 799 : CookieMonsterTask(cookie_monster), |
769 cookie_(cookie), | 800 cookie_(cookie), |
770 callback_(callback) { } | 801 callback_(callback) { |
| 802 } |
771 | 803 |
| 804 // CookieMonster::CookieMonsterTask: |
772 virtual void Run() OVERRIDE; | 805 virtual void Run() OVERRIDE; |
773 | 806 |
| 807 protected: |
| 808 virtual ~DeleteCanonicalCookieTask() {} |
| 809 |
774 private: | 810 private: |
775 CookieMonster::CanonicalCookie cookie_; | 811 CookieMonster::CanonicalCookie cookie_; |
776 CookieMonster::DeleteCookieCallback callback_; | 812 CookieMonster::DeleteCookieCallback callback_; |
777 | 813 |
778 DISALLOW_COPY_AND_ASSIGN(DeleteCanonicalCookieTask); | 814 DISALLOW_COPY_AND_ASSIGN(DeleteCanonicalCookieTask); |
779 }; | 815 }; |
780 | 816 |
781 void CookieMonster::DeleteCanonicalCookieTask::Run() { | 817 void CookieMonster::DeleteCanonicalCookieTask::Run() { |
782 bool result = this->cookie_monster()->DeleteCanonicalCookie(cookie_); | 818 bool result = this->cookie_monster()->DeleteCanonicalCookie(cookie_); |
783 if (!callback_.is_null()) { | 819 if (!callback_.is_null()) { |
784 this->InvokeCallback(base::Bind(&CookieMonster::DeleteCookieCallback::Run, | 820 this->InvokeCallback(base::Bind(&CookieMonster::DeleteCookieCallback::Run, |
785 base::Unretained(&callback_), result)); | 821 base::Unretained(&callback_), result)); |
786 } | 822 } |
787 } | 823 } |
788 | 824 |
789 // Task class for SetCookieWithOptions call. | 825 // Task class for SetCookieWithOptions call. |
790 class CookieMonster::SetCookieWithOptionsTask | 826 class CookieMonster::SetCookieWithOptionsTask |
791 : public CookieMonster::CookieMonsterTask { | 827 : public CookieMonster::CookieMonsterTask { |
792 public: | 828 public: |
793 SetCookieWithOptionsTask(CookieMonster* cookie_monster, | 829 SetCookieWithOptionsTask(CookieMonster* cookie_monster, |
794 const GURL& url, | 830 const GURL& url, |
795 const std::string& cookie_line, | 831 const std::string& cookie_line, |
796 const CookieOptions& options, | 832 const CookieOptions& options, |
797 const CookieMonster::SetCookiesCallback& callback) | 833 const CookieMonster::SetCookiesCallback& callback) |
798 : CookieMonsterTask(cookie_monster), | 834 : CookieMonsterTask(cookie_monster), |
799 url_(url), | 835 url_(url), |
800 cookie_line_(cookie_line), | 836 cookie_line_(cookie_line), |
801 options_(options), | 837 options_(options), |
802 callback_(callback) { } | 838 callback_(callback) { |
| 839 } |
803 | 840 |
| 841 // CookieMonster::CookieMonsterTask: |
804 virtual void Run() OVERRIDE; | 842 virtual void Run() OVERRIDE; |
805 | 843 |
| 844 protected: |
| 845 virtual ~SetCookieWithOptionsTask() {} |
| 846 |
806 private: | 847 private: |
807 GURL url_; | 848 GURL url_; |
808 std::string cookie_line_; | 849 std::string cookie_line_; |
809 CookieOptions options_; | 850 CookieOptions options_; |
810 CookieMonster::SetCookiesCallback callback_; | 851 CookieMonster::SetCookiesCallback callback_; |
811 | 852 |
812 DISALLOW_COPY_AND_ASSIGN(SetCookieWithOptionsTask); | 853 DISALLOW_COPY_AND_ASSIGN(SetCookieWithOptionsTask); |
813 }; | 854 }; |
814 | 855 |
815 void CookieMonster::SetCookieWithOptionsTask::Run() { | 856 void CookieMonster::SetCookieWithOptionsTask::Run() { |
816 bool result = this->cookie_monster()-> | 857 bool result = this->cookie_monster()-> |
817 SetCookieWithOptions(url_, cookie_line_, options_); | 858 SetCookieWithOptions(url_, cookie_line_, options_); |
818 if (!callback_.is_null()) { | 859 if (!callback_.is_null()) { |
819 this->InvokeCallback(base::Bind(&CookieMonster::SetCookiesCallback::Run, | 860 this->InvokeCallback(base::Bind(&CookieMonster::SetCookiesCallback::Run, |
820 base::Unretained(&callback_), result)); | 861 base::Unretained(&callback_), result)); |
821 } | 862 } |
822 } | 863 } |
823 | 864 |
824 // Task class for GetCookiesWithOptions call. | 865 // Task class for GetCookiesWithOptions call. |
825 class CookieMonster::GetCookiesWithOptionsTask | 866 class CookieMonster::GetCookiesWithOptionsTask |
826 : public CookieMonster::CookieMonsterTask { | 867 : public CookieMonster::CookieMonsterTask { |
827 public: | 868 public: |
828 GetCookiesWithOptionsTask(CookieMonster* cookie_monster, | 869 GetCookiesWithOptionsTask(CookieMonster* cookie_monster, |
829 const GURL& url, | 870 const GURL& url, |
830 const CookieOptions& options, | 871 const CookieOptions& options, |
831 const CookieMonster::GetCookiesCallback& callback) | 872 const CookieMonster::GetCookiesCallback& callback) |
832 : CookieMonsterTask(cookie_monster), | 873 : CookieMonsterTask(cookie_monster), |
833 url_(url), | 874 url_(url), |
834 options_(options), | 875 options_(options), |
835 callback_(callback) { } | 876 callback_(callback) { |
| 877 } |
836 | 878 |
| 879 // CookieMonster::CookieMonsterTask: |
837 virtual void Run() OVERRIDE; | 880 virtual void Run() OVERRIDE; |
838 | 881 |
| 882 protected: |
| 883 virtual ~GetCookiesWithOptionsTask() {} |
| 884 |
839 private: | 885 private: |
840 GURL url_; | 886 GURL url_; |
841 CookieOptions options_; | 887 CookieOptions options_; |
842 CookieMonster::GetCookiesCallback callback_; | 888 CookieMonster::GetCookiesCallback callback_; |
843 | 889 |
844 DISALLOW_COPY_AND_ASSIGN(GetCookiesWithOptionsTask); | 890 DISALLOW_COPY_AND_ASSIGN(GetCookiesWithOptionsTask); |
845 }; | 891 }; |
846 | 892 |
847 void CookieMonster::GetCookiesWithOptionsTask::Run() { | 893 void CookieMonster::GetCookiesWithOptionsTask::Run() { |
848 std::string cookie = this->cookie_monster()-> | 894 std::string cookie = this->cookie_monster()-> |
(...skipping 10 matching lines...) Expand all Loading... |
859 public: | 905 public: |
860 GetCookiesWithInfoTask(CookieMonster* cookie_monster, | 906 GetCookiesWithInfoTask(CookieMonster* cookie_monster, |
861 const GURL& url, | 907 const GURL& url, |
862 const CookieOptions& options, | 908 const CookieOptions& options, |
863 const CookieMonster::GetCookieInfoCallback& callback) | 909 const CookieMonster::GetCookieInfoCallback& callback) |
864 : CookieMonsterTask(cookie_monster), | 910 : CookieMonsterTask(cookie_monster), |
865 url_(url), | 911 url_(url), |
866 options_(options), | 912 options_(options), |
867 callback_(callback) { } | 913 callback_(callback) { } |
868 | 914 |
| 915 // CookieMonster::CookieMonsterTask: |
869 virtual void Run() OVERRIDE; | 916 virtual void Run() OVERRIDE; |
870 | 917 |
| 918 protected: |
| 919 virtual ~GetCookiesWithInfoTask() {} |
| 920 |
871 private: | 921 private: |
872 GURL url_; | 922 GURL url_; |
873 CookieOptions options_; | 923 CookieOptions options_; |
874 CookieMonster::GetCookieInfoCallback callback_; | 924 CookieMonster::GetCookieInfoCallback callback_; |
875 | 925 |
876 DISALLOW_COPY_AND_ASSIGN(GetCookiesWithInfoTask); | 926 DISALLOW_COPY_AND_ASSIGN(GetCookiesWithInfoTask); |
877 }; | 927 }; |
878 | 928 |
879 void CookieMonster::GetCookiesWithInfoTask::Run() { | 929 void CookieMonster::GetCookiesWithInfoTask::Run() { |
880 if (!callback_.is_null()) { | 930 if (!callback_.is_null()) { |
(...skipping 13 matching lines...) Expand all Loading... |
894 public: | 944 public: |
895 DeleteCookieTask(CookieMonster* cookie_monster, | 945 DeleteCookieTask(CookieMonster* cookie_monster, |
896 const GURL& url, | 946 const GURL& url, |
897 const std::string& cookie_name, | 947 const std::string& cookie_name, |
898 const base::Closure& callback) | 948 const base::Closure& callback) |
899 : CookieMonsterTask(cookie_monster), | 949 : CookieMonsterTask(cookie_monster), |
900 url_(url), | 950 url_(url), |
901 cookie_name_(cookie_name), | 951 cookie_name_(cookie_name), |
902 callback_(callback) { } | 952 callback_(callback) { } |
903 | 953 |
| 954 // CookieMonster::CookieMonsterTask: |
904 virtual void Run() OVERRIDE; | 955 virtual void Run() OVERRIDE; |
905 | 956 |
| 957 protected: |
| 958 virtual ~DeleteCookieTask() {} |
| 959 |
906 private: | 960 private: |
907 GURL url_; | 961 GURL url_; |
908 std::string cookie_name_; | 962 std::string cookie_name_; |
909 base::Closure callback_; | 963 base::Closure callback_; |
910 | 964 |
911 DISALLOW_COPY_AND_ASSIGN(DeleteCookieTask); | 965 DISALLOW_COPY_AND_ASSIGN(DeleteCookieTask); |
912 }; | 966 }; |
913 | 967 |
914 void CookieMonster::DeleteCookieTask::Run() { | 968 void CookieMonster::DeleteCookieTask::Run() { |
915 this->cookie_monster()->DeleteCookie(url_, cookie_name_); | 969 this->cookie_monster()->DeleteCookie(url_, cookie_name_); |
916 if (!callback_.is_null()) { | 970 if (!callback_.is_null()) { |
917 this->InvokeCallback(callback_); | 971 this->InvokeCallback(callback_); |
918 } | 972 } |
919 } | 973 } |
920 | 974 |
921 // Task class for DeleteSessionCookies call. | 975 // Task class for DeleteSessionCookies call. |
922 class CookieMonster::DeleteSessionCookiesTask | 976 class CookieMonster::DeleteSessionCookiesTask |
923 : public CookieMonster::CookieMonsterTask { | 977 : public CookieMonster::CookieMonsterTask { |
924 public: | 978 public: |
925 DeleteSessionCookiesTask( | 979 DeleteSessionCookiesTask( |
926 CookieMonster* cookie_monster, | 980 CookieMonster* cookie_monster, |
927 const CookieMonster::DeleteCallback& callback) | 981 const CookieMonster::DeleteCallback& callback) |
928 : CookieMonsterTask(cookie_monster), | 982 : CookieMonsterTask(cookie_monster), |
929 callback_(callback) { } | 983 callback_(callback) { |
| 984 } |
930 | 985 |
| 986 // CookieMonster::CookieMonsterTask: |
931 virtual void Run() OVERRIDE; | 987 virtual void Run() OVERRIDE; |
932 | 988 |
| 989 protected: |
| 990 virtual ~DeleteSessionCookiesTask() {} |
| 991 |
933 private: | 992 private: |
934 CookieMonster::DeleteCallback callback_; | 993 CookieMonster::DeleteCallback callback_; |
935 | 994 |
936 DISALLOW_COPY_AND_ASSIGN(DeleteSessionCookiesTask); | 995 DISALLOW_COPY_AND_ASSIGN(DeleteSessionCookiesTask); |
937 }; | 996 }; |
938 | 997 |
939 void CookieMonster::DeleteSessionCookiesTask::Run() { | 998 void CookieMonster::DeleteSessionCookiesTask::Run() { |
940 int num_deleted = this->cookie_monster()->DeleteSessionCookies(); | 999 int num_deleted = this->cookie_monster()->DeleteSessionCookies(); |
941 if (!callback_.is_null()) { | 1000 if (!callback_.is_null()) { |
942 this->InvokeCallback(base::Bind(&CookieMonster::DeleteCallback::Run, | 1001 this->InvokeCallback(base::Bind(&CookieMonster::DeleteCallback::Run, |
(...skipping 1843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2786 std::string CookieMonster::CanonicalCookie::DebugString() const { | 2845 std::string CookieMonster::CanonicalCookie::DebugString() const { |
2787 return base::StringPrintf( | 2846 return base::StringPrintf( |
2788 "name: %s value: %s domain: %s path: %s creation: %" | 2847 "name: %s value: %s domain: %s path: %s creation: %" |
2789 PRId64, | 2848 PRId64, |
2790 name_.c_str(), value_.c_str(), | 2849 name_.c_str(), value_.c_str(), |
2791 domain_.c_str(), path_.c_str(), | 2850 domain_.c_str(), path_.c_str(), |
2792 static_cast<int64>(creation_date_.ToTimeT())); | 2851 static_cast<int64>(creation_date_.ToTimeT())); |
2793 } | 2852 } |
2794 | 2853 |
2795 } // namespace | 2854 } // namespace |
OLD | NEW |