| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/bookmarks/bookmark_extension_api.h" | 5 #include "chrome/browser/bookmarks/bookmark_extension_api.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/i18n/file_util_icu.h" | 9 #include "base/i18n/file_util_icu.h" |
| 10 #include "base/i18n/time_formatting.h" | 10 #include "base/i18n/time_formatting.h" |
| (...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 // For bookmarks.remove. | 787 // For bookmarks.remove. |
| 788 static void BuildForRemove(QuotaLimitHeuristics* heuristics, | 788 static void BuildForRemove(QuotaLimitHeuristics* heuristics, |
| 789 Profile* profile) { | 789 Profile* profile) { |
| 790 BuildWithMappers(heuristics, new RemoveBookmarksBucketMapper(profile), | 790 BuildWithMappers(heuristics, new RemoveBookmarksBucketMapper(profile), |
| 791 new RemoveBookmarksBucketMapper(profile)); | 791 new RemoveBookmarksBucketMapper(profile)); |
| 792 } | 792 } |
| 793 | 793 |
| 794 private: | 794 private: |
| 795 static void BuildWithMappers(QuotaLimitHeuristics* heuristics, | 795 static void BuildWithMappers(QuotaLimitHeuristics* heuristics, |
| 796 BucketMapper* short_mapper, BucketMapper* long_mapper) { | 796 BucketMapper* short_mapper, BucketMapper* long_mapper) { |
| 797 const Config kShortLimitConfig = { |
| 798 2, // 2 tokens per interval. |
| 799 TimeDelta::FromMinutes(1) // 1 minute long refill interval. |
| 800 }; |
| 801 const Config kLongLimitConfig = { |
| 802 100, // 100 tokens per interval. |
| 803 TimeDelta::FromHours(1) // 1 hour long refill interval. |
| 804 }; |
| 805 |
| 797 TimedLimit* timed = new TimedLimit(kLongLimitConfig, long_mapper); | 806 TimedLimit* timed = new TimedLimit(kLongLimitConfig, long_mapper); |
| 798 // A max of two operations per minute, sustained over 10 minutes. | 807 // A max of two operations per minute, sustained over 10 minutes. |
| 799 SustainedLimit* sustained = new SustainedLimit(TimeDelta::FromMinutes(10), | 808 SustainedLimit* sustained = new SustainedLimit(TimeDelta::FromMinutes(10), |
| 800 kShortLimitConfig, short_mapper); | 809 kShortLimitConfig, short_mapper); |
| 801 heuristics->push_back(timed); | 810 heuristics->push_back(timed); |
| 802 heuristics->push_back(sustained); | 811 heuristics->push_back(sustained); |
| 803 } | 812 } |
| 804 | 813 |
| 805 // The quota configurations used for all BookmarkFunctions. | |
| 806 static const Config kShortLimitConfig; | |
| 807 static const Config kLongLimitConfig; | |
| 808 | |
| 809 DISALLOW_IMPLICIT_CONSTRUCTORS(BookmarksQuotaLimitFactory); | 814 DISALLOW_IMPLICIT_CONSTRUCTORS(BookmarksQuotaLimitFactory); |
| 810 }; | 815 }; |
| 811 | 816 |
| 812 const Config BookmarksQuotaLimitFactory::kShortLimitConfig = { | |
| 813 2, // 2 tokens per interval. | |
| 814 TimeDelta::FromMinutes(1) // 1 minute long refill interval. | |
| 815 }; | |
| 816 | |
| 817 const Config BookmarksQuotaLimitFactory::kLongLimitConfig = { | |
| 818 100, // 100 tokens per interval. | |
| 819 TimeDelta::FromHours(1) // 1 hour long refill interval. | |
| 820 }; | |
| 821 | |
| 822 // And finally, building the individual heuristics for each function. | 817 // And finally, building the individual heuristics for each function. |
| 823 void RemoveBookmarkFunction::GetQuotaLimitHeuristics( | 818 void RemoveBookmarkFunction::GetQuotaLimitHeuristics( |
| 824 QuotaLimitHeuristics* heuristics) const { | 819 QuotaLimitHeuristics* heuristics) const { |
| 825 BookmarksQuotaLimitFactory::BuildForRemove(heuristics, profile()); | 820 BookmarksQuotaLimitFactory::BuildForRemove(heuristics, profile()); |
| 826 } | 821 } |
| 827 | 822 |
| 828 void MoveBookmarkFunction::GetQuotaLimitHeuristics( | 823 void MoveBookmarkFunction::GetQuotaLimitHeuristics( |
| 829 QuotaLimitHeuristics* heuristics) const { | 824 QuotaLimitHeuristics* heuristics) const { |
| 830 BookmarksQuotaLimitFactory::Build<MoveBookmarkFunction>(heuristics); | 825 BookmarksQuotaLimitFactory::Build<MoveBookmarkFunction>(heuristics); |
| 831 } | 826 } |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE); | 930 SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE); |
| 936 return true; | 931 return true; |
| 937 } | 932 } |
| 938 | 933 |
| 939 void ExportBookmarksFunction::FileSelected(const FilePath& path, | 934 void ExportBookmarksFunction::FileSelected(const FilePath& path, |
| 940 int index, | 935 int index, |
| 941 void* params) { | 936 void* params) { |
| 942 bookmark_html_writer::WriteBookmarks(profile(), path, NULL); | 937 bookmark_html_writer::WriteBookmarks(profile(), path, NULL); |
| 943 Release(); // Balanced in BookmarksIOFunction::SelectFile() | 938 Release(); // Balanced in BookmarksIOFunction::SelectFile() |
| 944 } | 939 } |
| OLD | NEW |