Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(590)

Side by Side Diff: chrome/browser/bookmarks/bookmark_extension_api.cc

Issue 10871034: Make all quota-exceeding messages in the storage API explain what the failure (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update... the other error message Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/api/test/test_api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #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 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 // For bookmarks.remove. 798 // For bookmarks.remove.
799 static void BuildForRemove(QuotaLimitHeuristics* heuristics, 799 static void BuildForRemove(QuotaLimitHeuristics* heuristics,
800 Profile* profile) { 800 Profile* profile) {
801 BuildWithMappers(heuristics, new RemoveBookmarksBucketMapper(profile), 801 BuildWithMappers(heuristics, new RemoveBookmarksBucketMapper(profile),
802 new RemoveBookmarksBucketMapper(profile)); 802 new RemoveBookmarksBucketMapper(profile));
803 } 803 }
804 804
805 private: 805 private:
806 static void BuildWithMappers(QuotaLimitHeuristics* heuristics, 806 static void BuildWithMappers(QuotaLimitHeuristics* heuristics,
807 BucketMapper* short_mapper, BucketMapper* long_mapper) { 807 BucketMapper* short_mapper, BucketMapper* long_mapper) {
808 const Config kShortLimitConfig = { 808 const Config kSustainedLimitConfig = {
809 2, // 2 tokens per interval. 809 // See bookmarks.json for current value.
810 TimeDelta::FromMinutes(1) // 1 minute long refill interval. 810 bookmarks::MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE,
811 TimeDelta::FromMinutes(1)
811 }; 812 };
812 const Config kLongLimitConfig = { 813 heuristics->push_back(new SustainedLimit(
813 100, // 100 tokens per interval. 814 TimeDelta::FromMinutes(10),
814 TimeDelta::FromHours(1) // 1 hour long refill interval. 815 kSustainedLimitConfig,
816 short_mapper,
817 "MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE"));
818
819 const Config kTimedLimitConfig = {
820 // See bookmarks.json for current value.
821 bookmarks::MAX_WRITE_OPERATIONS_PER_HOUR,
822 TimeDelta::FromHours(1)
815 }; 823 };
816 824 heuristics->push_back(new TimedLimit(
817 TimedLimit* timed = new TimedLimit(kLongLimitConfig, long_mapper); 825 kTimedLimitConfig,
818 // A max of two operations per minute, sustained over 10 minutes. 826 long_mapper,
819 SustainedLimit* sustained = new SustainedLimit(TimeDelta::FromMinutes(10), 827 "MAX_WRITE_OPERATIONS_PER_HOUR"));
820 kShortLimitConfig, short_mapper);
821 heuristics->push_back(timed);
822 heuristics->push_back(sustained);
823 } 828 }
824 829
825 DISALLOW_IMPLICIT_CONSTRUCTORS(BookmarksQuotaLimitFactory); 830 DISALLOW_IMPLICIT_CONSTRUCTORS(BookmarksQuotaLimitFactory);
826 }; 831 };
827 832
828 // And finally, building the individual heuristics for each function. 833 // And finally, building the individual heuristics for each function.
829 void RemoveBookmarkFunction::GetQuotaLimitHeuristics( 834 void RemoveBookmarkFunction::GetQuotaLimitHeuristics(
830 QuotaLimitHeuristics* heuristics) const { 835 QuotaLimitHeuristics* heuristics) const {
831 BookmarksQuotaLimitFactory::BuildForRemove(heuristics, profile()); 836 BookmarksQuotaLimitFactory::BuildForRemove(heuristics, profile());
832 } 837 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 int index, 957 int index,
953 void* params) { 958 void* params) {
954 #if !defined(OS_ANDROID) 959 #if !defined(OS_ANDROID)
955 // Android does not have support for the standard exporter. 960 // Android does not have support for the standard exporter.
956 // TODO(jgreenwald): remove ifdef once extensions are no longer built on 961 // TODO(jgreenwald): remove ifdef once extensions are no longer built on
957 // Android. 962 // Android.
958 bookmark_html_writer::WriteBookmarks(profile(), path, NULL); 963 bookmark_html_writer::WriteBookmarks(profile(), path, NULL);
959 #endif 964 #endif
960 Release(); // Balanced in BookmarksIOFunction::SelectFile() 965 Release(); // Balanced in BookmarksIOFunction::SelectFile()
961 } 966 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/test/test_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698