| 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 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 domain_(domain), | 584 domain_(domain), |
| 585 path_(path), | 585 path_(path), |
| 586 expiration_time_(expiration_time), | 586 expiration_time_(expiration_time), |
| 587 secure_(secure), | 587 secure_(secure), |
| 588 http_only_(http_only), | 588 http_only_(http_only), |
| 589 callback_(callback) { } | 589 callback_(callback) { } |
| 590 | 590 |
| 591 virtual void Run() OVERRIDE; | 591 virtual void Run() OVERRIDE; |
| 592 | 592 |
| 593 private: | 593 private: |
| 594 virtual ~SetCookieWithDetailsTask() {} |
| 595 |
| 594 GURL url_; | 596 GURL url_; |
| 595 std::string name_; | 597 std::string name_; |
| 596 std::string value_; | 598 std::string value_; |
| 597 std::string domain_; | 599 std::string domain_; |
| 598 std::string path_; | 600 std::string path_; |
| 599 base::Time expiration_time_; | 601 base::Time expiration_time_; |
| 600 bool secure_; | 602 bool secure_; |
| 601 bool http_only_; | 603 bool http_only_; |
| 602 CookieMonster::SetCookiesCallback callback_; | 604 CookieMonster::SetCookiesCallback callback_; |
| 603 | 605 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 619 : public CookieMonster::CookieMonsterTask { | 621 : public CookieMonster::CookieMonsterTask { |
| 620 public: | 622 public: |
| 621 GetAllCookiesTask(CookieMonster* cookie_monster, | 623 GetAllCookiesTask(CookieMonster* cookie_monster, |
| 622 const CookieMonster::GetCookieListCallback& callback) | 624 const CookieMonster::GetCookieListCallback& callback) |
| 623 : CookieMonsterTask(cookie_monster), | 625 : CookieMonsterTask(cookie_monster), |
| 624 callback_(callback) { } | 626 callback_(callback) { } |
| 625 | 627 |
| 626 virtual void Run() OVERRIDE; | 628 virtual void Run() OVERRIDE; |
| 627 | 629 |
| 628 private: | 630 private: |
| 631 virtual ~GetAllCookiesTask() {} |
| 632 |
| 629 CookieMonster::GetCookieListCallback callback_; | 633 CookieMonster::GetCookieListCallback callback_; |
| 630 | 634 |
| 631 DISALLOW_COPY_AND_ASSIGN(GetAllCookiesTask); | 635 DISALLOW_COPY_AND_ASSIGN(GetAllCookiesTask); |
| 632 }; | 636 }; |
| 633 | 637 |
| 634 void CookieMonster::GetAllCookiesTask::Run() { | 638 void CookieMonster::GetAllCookiesTask::Run() { |
| 635 if (!callback_.is_null()) { | 639 if (!callback_.is_null()) { |
| 636 CookieList cookies = this->cookie_monster()->GetAllCookies(); | 640 CookieList cookies = this->cookie_monster()->GetAllCookies(); |
| 637 this->InvokeCallback(base::Bind(&CookieMonster::GetCookieListCallback::Run, | 641 this->InvokeCallback(base::Bind(&CookieMonster::GetCookieListCallback::Run, |
| 638 base::Unretained(&callback_), cookies)); | 642 base::Unretained(&callback_), cookies)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 649 const CookieOptions& options, | 653 const CookieOptions& options, |
| 650 const CookieMonster::GetCookieListCallback& callback) | 654 const CookieMonster::GetCookieListCallback& callback) |
| 651 : CookieMonsterTask(cookie_monster), | 655 : CookieMonsterTask(cookie_monster), |
| 652 url_(url), | 656 url_(url), |
| 653 options_(options), | 657 options_(options), |
| 654 callback_(callback) { } | 658 callback_(callback) { } |
| 655 | 659 |
| 656 virtual void Run() OVERRIDE; | 660 virtual void Run() OVERRIDE; |
| 657 | 661 |
| 658 private: | 662 private: |
| 663 virtual ~GetAllCookiesForURLWithOptionsTask() {} |
| 664 |
| 659 GURL url_; | 665 GURL url_; |
| 660 CookieOptions options_; | 666 CookieOptions options_; |
| 661 CookieMonster::GetCookieListCallback callback_; | 667 CookieMonster::GetCookieListCallback callback_; |
| 662 | 668 |
| 663 DISALLOW_COPY_AND_ASSIGN(GetAllCookiesForURLWithOptionsTask); | 669 DISALLOW_COPY_AND_ASSIGN(GetAllCookiesForURLWithOptionsTask); |
| 664 }; | 670 }; |
| 665 | 671 |
| 666 void CookieMonster::GetAllCookiesForURLWithOptionsTask::Run() { | 672 void CookieMonster::GetAllCookiesForURLWithOptionsTask::Run() { |
| 667 if (!callback_.is_null()) { | 673 if (!callback_.is_null()) { |
| 668 CookieList cookies = this->cookie_monster()-> | 674 CookieList cookies = this->cookie_monster()-> |
| 669 GetAllCookiesForURLWithOptions(url_, options_); | 675 GetAllCookiesForURLWithOptions(url_, options_); |
| 670 this->InvokeCallback(base::Bind(&CookieMonster::GetCookieListCallback::Run, | 676 this->InvokeCallback(base::Bind(&CookieMonster::GetCookieListCallback::Run, |
| 671 base::Unretained(&callback_), cookies)); | 677 base::Unretained(&callback_), cookies)); |
| 672 } | 678 } |
| 673 } | 679 } |
| 674 | 680 |
| 675 // Task class for DeleteAll call. | 681 // Task class for DeleteAll call. |
| 676 class CookieMonster::DeleteAllTask : public CookieMonster::CookieMonsterTask { | 682 class CookieMonster::DeleteAllTask : public CookieMonster::CookieMonsterTask { |
| 677 public: | 683 public: |
| 678 DeleteAllTask(CookieMonster* cookie_monster, | 684 DeleteAllTask(CookieMonster* cookie_monster, |
| 679 const CookieMonster::DeleteCallback& callback) | 685 const CookieMonster::DeleteCallback& callback) |
| 680 : CookieMonsterTask(cookie_monster), | 686 : CookieMonsterTask(cookie_monster), |
| 681 callback_(callback) { } | 687 callback_(callback) { } |
| 682 | 688 |
| 683 virtual void Run() OVERRIDE; | 689 virtual void Run() OVERRIDE; |
| 684 | 690 |
| 685 private: | 691 private: |
| 692 virtual ~DeleteAllTask() {} |
| 693 |
| 686 CookieMonster::DeleteCallback callback_; | 694 CookieMonster::DeleteCallback callback_; |
| 687 | 695 |
| 688 DISALLOW_COPY_AND_ASSIGN(DeleteAllTask); | 696 DISALLOW_COPY_AND_ASSIGN(DeleteAllTask); |
| 689 }; | 697 }; |
| 690 | 698 |
| 691 void CookieMonster::DeleteAllTask::Run() { | 699 void CookieMonster::DeleteAllTask::Run() { |
| 692 int num_deleted = this->cookie_monster()->DeleteAll(true); | 700 int num_deleted = this->cookie_monster()->DeleteAll(true); |
| 693 if (!callback_.is_null()) { | 701 if (!callback_.is_null()) { |
| 694 this->InvokeCallback(base::Bind(&CookieMonster::DeleteCallback::Run, | 702 this->InvokeCallback(base::Bind(&CookieMonster::DeleteCallback::Run, |
| 695 base::Unretained(&callback_), num_deleted)); | 703 base::Unretained(&callback_), num_deleted)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 706 const Time& delete_end, | 714 const Time& delete_end, |
| 707 const CookieMonster::DeleteCallback& callback) | 715 const CookieMonster::DeleteCallback& callback) |
| 708 : CookieMonsterTask(cookie_monster), | 716 : CookieMonsterTask(cookie_monster), |
| 709 delete_begin_(delete_begin), | 717 delete_begin_(delete_begin), |
| 710 delete_end_(delete_end), | 718 delete_end_(delete_end), |
| 711 callback_(callback) { } | 719 callback_(callback) { } |
| 712 | 720 |
| 713 virtual void Run() OVERRIDE; | 721 virtual void Run() OVERRIDE; |
| 714 | 722 |
| 715 private: | 723 private: |
| 724 virtual ~DeleteAllCreatedBetweenTask() {} |
| 725 |
| 716 Time delete_begin_; | 726 Time delete_begin_; |
| 717 Time delete_end_; | 727 Time delete_end_; |
| 718 CookieMonster::DeleteCallback callback_; | 728 CookieMonster::DeleteCallback callback_; |
| 719 | 729 |
| 720 DISALLOW_COPY_AND_ASSIGN(DeleteAllCreatedBetweenTask); | 730 DISALLOW_COPY_AND_ASSIGN(DeleteAllCreatedBetweenTask); |
| 721 }; | 731 }; |
| 722 | 732 |
| 723 void CookieMonster::DeleteAllCreatedBetweenTask::Run() { | 733 void CookieMonster::DeleteAllCreatedBetweenTask::Run() { |
| 724 int num_deleted = this->cookie_monster()-> | 734 int num_deleted = this->cookie_monster()-> |
| 725 DeleteAllCreatedBetween(delete_begin_, delete_end_); | 735 DeleteAllCreatedBetween(delete_begin_, delete_end_); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 736 DeleteAllForHostTask(CookieMonster* cookie_monster, | 746 DeleteAllForHostTask(CookieMonster* cookie_monster, |
| 737 const GURL& url, | 747 const GURL& url, |
| 738 const CookieMonster::DeleteCallback& callback) | 748 const CookieMonster::DeleteCallback& callback) |
| 739 : CookieMonsterTask(cookie_monster), | 749 : CookieMonsterTask(cookie_monster), |
| 740 url_(url), | 750 url_(url), |
| 741 callback_(callback) { } | 751 callback_(callback) { } |
| 742 | 752 |
| 743 virtual void Run() OVERRIDE; | 753 virtual void Run() OVERRIDE; |
| 744 | 754 |
| 745 private: | 755 private: |
| 756 virtual ~DeleteAllForHostTask() {} |
| 757 |
| 746 GURL url_; | 758 GURL url_; |
| 747 CookieMonster::DeleteCallback callback_; | 759 CookieMonster::DeleteCallback callback_; |
| 748 | 760 |
| 749 DISALLOW_COPY_AND_ASSIGN(DeleteAllForHostTask); | 761 DISALLOW_COPY_AND_ASSIGN(DeleteAllForHostTask); |
| 750 }; | 762 }; |
| 751 | 763 |
| 752 void CookieMonster::DeleteAllForHostTask::Run() { | 764 void CookieMonster::DeleteAllForHostTask::Run() { |
| 753 int num_deleted = this->cookie_monster()->DeleteAllForHost(url_); | 765 int num_deleted = this->cookie_monster()->DeleteAllForHost(url_); |
| 754 if (!callback_.is_null()) { | 766 if (!callback_.is_null()) { |
| 755 this->InvokeCallback(base::Bind(&CookieMonster::DeleteCallback::Run, | 767 this->InvokeCallback(base::Bind(&CookieMonster::DeleteCallback::Run, |
| 756 base::Unretained(&callback_), num_deleted)); | 768 base::Unretained(&callback_), num_deleted)); |
| 757 } | 769 } |
| 758 } | 770 } |
| 759 | 771 |
| 760 // Task class for DeleteCanonicalCookie call. | 772 // Task class for DeleteCanonicalCookie call. |
| 761 class CookieMonster::DeleteCanonicalCookieTask | 773 class CookieMonster::DeleteCanonicalCookieTask |
| 762 : public CookieMonster::CookieMonsterTask { | 774 : public CookieMonster::CookieMonsterTask { |
| 763 public: | 775 public: |
| 764 DeleteCanonicalCookieTask( | 776 DeleteCanonicalCookieTask( |
| 765 CookieMonster* cookie_monster, | 777 CookieMonster* cookie_monster, |
| 766 const CookieMonster::CanonicalCookie& cookie, | 778 const CookieMonster::CanonicalCookie& cookie, |
| 767 const CookieMonster::DeleteCookieCallback& callback) | 779 const CookieMonster::DeleteCookieCallback& callback) |
| 768 : CookieMonsterTask(cookie_monster), | 780 : CookieMonsterTask(cookie_monster), |
| 769 cookie_(cookie), | 781 cookie_(cookie), |
| 770 callback_(callback) { } | 782 callback_(callback) { } |
| 771 | 783 |
| 772 virtual void Run() OVERRIDE; | 784 virtual void Run() OVERRIDE; |
| 773 | 785 |
| 774 private: | 786 private: |
| 787 virtual ~DeleteCanonicalCookieTask() {} |
| 788 |
| 775 CookieMonster::CanonicalCookie cookie_; | 789 CookieMonster::CanonicalCookie cookie_; |
| 776 CookieMonster::DeleteCookieCallback callback_; | 790 CookieMonster::DeleteCookieCallback callback_; |
| 777 | 791 |
| 778 DISALLOW_COPY_AND_ASSIGN(DeleteCanonicalCookieTask); | 792 DISALLOW_COPY_AND_ASSIGN(DeleteCanonicalCookieTask); |
| 779 }; | 793 }; |
| 780 | 794 |
| 781 void CookieMonster::DeleteCanonicalCookieTask::Run() { | 795 void CookieMonster::DeleteCanonicalCookieTask::Run() { |
| 782 bool result = this->cookie_monster()->DeleteCanonicalCookie(cookie_); | 796 bool result = this->cookie_monster()->DeleteCanonicalCookie(cookie_); |
| 783 if (!callback_.is_null()) { | 797 if (!callback_.is_null()) { |
| 784 this->InvokeCallback(base::Bind(&CookieMonster::DeleteCookieCallback::Run, | 798 this->InvokeCallback(base::Bind(&CookieMonster::DeleteCookieCallback::Run, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 797 const CookieMonster::SetCookiesCallback& callback) | 811 const CookieMonster::SetCookiesCallback& callback) |
| 798 : CookieMonsterTask(cookie_monster), | 812 : CookieMonsterTask(cookie_monster), |
| 799 url_(url), | 813 url_(url), |
| 800 cookie_line_(cookie_line), | 814 cookie_line_(cookie_line), |
| 801 options_(options), | 815 options_(options), |
| 802 callback_(callback) { } | 816 callback_(callback) { } |
| 803 | 817 |
| 804 virtual void Run() OVERRIDE; | 818 virtual void Run() OVERRIDE; |
| 805 | 819 |
| 806 private: | 820 private: |
| 821 virtual ~SetCookieWithOptionsTask() {} |
| 822 |
| 807 GURL url_; | 823 GURL url_; |
| 808 std::string cookie_line_; | 824 std::string cookie_line_; |
| 809 CookieOptions options_; | 825 CookieOptions options_; |
| 810 CookieMonster::SetCookiesCallback callback_; | 826 CookieMonster::SetCookiesCallback callback_; |
| 811 | 827 |
| 812 DISALLOW_COPY_AND_ASSIGN(SetCookieWithOptionsTask); | 828 DISALLOW_COPY_AND_ASSIGN(SetCookieWithOptionsTask); |
| 813 }; | 829 }; |
| 814 | 830 |
| 815 void CookieMonster::SetCookieWithOptionsTask::Run() { | 831 void CookieMonster::SetCookieWithOptionsTask::Run() { |
| 816 bool result = this->cookie_monster()-> | 832 bool result = this->cookie_monster()-> |
| (...skipping 13 matching lines...) Expand all Loading... |
| 830 const CookieOptions& options, | 846 const CookieOptions& options, |
| 831 const CookieMonster::GetCookiesCallback& callback) | 847 const CookieMonster::GetCookiesCallback& callback) |
| 832 : CookieMonsterTask(cookie_monster), | 848 : CookieMonsterTask(cookie_monster), |
| 833 url_(url), | 849 url_(url), |
| 834 options_(options), | 850 options_(options), |
| 835 callback_(callback) { } | 851 callback_(callback) { } |
| 836 | 852 |
| 837 virtual void Run() OVERRIDE; | 853 virtual void Run() OVERRIDE; |
| 838 | 854 |
| 839 private: | 855 private: |
| 856 virtual ~GetCookiesWithOptionsTask() {} |
| 857 |
| 840 GURL url_; | 858 GURL url_; |
| 841 CookieOptions options_; | 859 CookieOptions options_; |
| 842 CookieMonster::GetCookiesCallback callback_; | 860 CookieMonster::GetCookiesCallback callback_; |
| 843 | 861 |
| 844 DISALLOW_COPY_AND_ASSIGN(GetCookiesWithOptionsTask); | 862 DISALLOW_COPY_AND_ASSIGN(GetCookiesWithOptionsTask); |
| 845 }; | 863 }; |
| 846 | 864 |
| 847 void CookieMonster::GetCookiesWithOptionsTask::Run() { | 865 void CookieMonster::GetCookiesWithOptionsTask::Run() { |
| 848 std::string cookie = this->cookie_monster()-> | 866 std::string cookie = this->cookie_monster()-> |
| 849 GetCookiesWithOptions(url_, options_); | 867 GetCookiesWithOptions(url_, options_); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 862 const CookieOptions& options, | 880 const CookieOptions& options, |
| 863 const CookieMonster::GetCookieInfoCallback& callback) | 881 const CookieMonster::GetCookieInfoCallback& callback) |
| 864 : CookieMonsterTask(cookie_monster), | 882 : CookieMonsterTask(cookie_monster), |
| 865 url_(url), | 883 url_(url), |
| 866 options_(options), | 884 options_(options), |
| 867 callback_(callback) { } | 885 callback_(callback) { } |
| 868 | 886 |
| 869 virtual void Run() OVERRIDE; | 887 virtual void Run() OVERRIDE; |
| 870 | 888 |
| 871 private: | 889 private: |
| 890 virtual ~GetCookiesWithInfoTask() {} |
| 891 |
| 872 GURL url_; | 892 GURL url_; |
| 873 CookieOptions options_; | 893 CookieOptions options_; |
| 874 CookieMonster::GetCookieInfoCallback callback_; | 894 CookieMonster::GetCookieInfoCallback callback_; |
| 875 | 895 |
| 876 DISALLOW_COPY_AND_ASSIGN(GetCookiesWithInfoTask); | 896 DISALLOW_COPY_AND_ASSIGN(GetCookiesWithInfoTask); |
| 877 }; | 897 }; |
| 878 | 898 |
| 879 void CookieMonster::GetCookiesWithInfoTask::Run() { | 899 void CookieMonster::GetCookiesWithInfoTask::Run() { |
| 880 if (!callback_.is_null()) { | 900 if (!callback_.is_null()) { |
| 881 std::string cookie_line; | 901 std::string cookie_line; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 897 const std::string& cookie_name, | 917 const std::string& cookie_name, |
| 898 const base::Closure& callback) | 918 const base::Closure& callback) |
| 899 : CookieMonsterTask(cookie_monster), | 919 : CookieMonsterTask(cookie_monster), |
| 900 url_(url), | 920 url_(url), |
| 901 cookie_name_(cookie_name), | 921 cookie_name_(cookie_name), |
| 902 callback_(callback) { } | 922 callback_(callback) { } |
| 903 | 923 |
| 904 virtual void Run() OVERRIDE; | 924 virtual void Run() OVERRIDE; |
| 905 | 925 |
| 906 private: | 926 private: |
| 927 virtual ~DeleteCookieTask() {} |
| 928 |
| 907 GURL url_; | 929 GURL url_; |
| 908 std::string cookie_name_; | 930 std::string cookie_name_; |
| 909 base::Closure callback_; | 931 base::Closure callback_; |
| 910 | 932 |
| 911 DISALLOW_COPY_AND_ASSIGN(DeleteCookieTask); | 933 DISALLOW_COPY_AND_ASSIGN(DeleteCookieTask); |
| 912 }; | 934 }; |
| 913 | 935 |
| 914 void CookieMonster::DeleteCookieTask::Run() { | 936 void CookieMonster::DeleteCookieTask::Run() { |
| 915 this->cookie_monster()->DeleteCookie(url_, cookie_name_); | 937 this->cookie_monster()->DeleteCookie(url_, cookie_name_); |
| 916 if (!callback_.is_null()) { | 938 if (!callback_.is_null()) { |
| (...skipping 1815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2732 std::string CookieMonster::CanonicalCookie::DebugString() const { | 2754 std::string CookieMonster::CanonicalCookie::DebugString() const { |
| 2733 return base::StringPrintf( | 2755 return base::StringPrintf( |
| 2734 "name: %s value: %s domain: %s path: %s creation: %" | 2756 "name: %s value: %s domain: %s path: %s creation: %" |
| 2735 PRId64, | 2757 PRId64, |
| 2736 name_.c_str(), value_.c_str(), | 2758 name_.c_str(), value_.c_str(), |
| 2737 domain_.c_str(), path_.c_str(), | 2759 domain_.c_str(), path_.c_str(), |
| 2738 static_cast<int64>(creation_date_.ToTimeT())); | 2760 static_cast<int64>(creation_date_.ToTimeT())); |
| 2739 } | 2761 } |
| 2740 | 2762 |
| 2741 } // namespace | 2763 } // namespace |
| OLD | NEW |