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

Side by Side Diff: chrome/browser/extensions/api/web_request/web_request_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: Created 8 years, 4 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
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/extensions/api/web_request/web_request_api.h" 5 #include "chrome/browser/extensions/api/web_request/web_request_api.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 1530 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 // 1541 //
1542 // As we want to account for the number of times the cache is really cleared 1542 // As we want to account for the number of times the cache is really cleared
1543 // (opposed to the number of times webRequest.handlerBehaviorChanged() is 1543 // (opposed to the number of times webRequest.handlerBehaviorChanged() is
1544 // called), we cannot decide whether a call of 1544 // called), we cannot decide whether a call of
1545 // webRequest.handlerBehaviorChanged() should trigger a quota violation at the 1545 // webRequest.handlerBehaviorChanged() should trigger a quota violation at the
1546 // time it is called. Instead we only decrement the bucket counter at the time 1546 // time it is called. Instead we only decrement the bucket counter at the time
1547 // when the cache is cleared (when page loads happen). 1547 // when the cache is cleared (when page loads happen).
1548 class ClearCacheQuotaHeuristic : public QuotaLimitHeuristic { 1548 class ClearCacheQuotaHeuristic : public QuotaLimitHeuristic {
1549 public: 1549 public:
1550 ClearCacheQuotaHeuristic(const Config& config, BucketMapper* map) 1550 ClearCacheQuotaHeuristic(const Config& config, BucketMapper* map)
1551 : QuotaLimitHeuristic(config, map), 1551 : QuotaLimitHeuristic(config, map, "clear cache"),
Matt Perry 2012/08/23 18:30:35 This won't make sense to the extension author. Let
not at google - send to devlin 2012/08/24 04:45:04 Changed to "MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER
1552 callback_registered_(false), 1552 callback_registered_(false),
1553 weak_ptr_factory_(this) {} 1553 weak_ptr_factory_(this) {}
1554 virtual ~ClearCacheQuotaHeuristic() {} 1554 virtual ~ClearCacheQuotaHeuristic() {}
1555 virtual bool Apply(Bucket* bucket, 1555 virtual bool Apply(Bucket* bucket,
1556 const base::TimeTicks& event_time) OVERRIDE; 1556 const base::TimeTicks& event_time) OVERRIDE;
1557 1557
1558 private: 1558 private:
1559 // Callback that is triggered by the ExtensionWebRequestEventRouter on a page 1559 // Callback that is triggered by the ExtensionWebRequestEventRouter on a page
1560 // load. 1560 // load.
1561 // 1561 //
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1785 20, // Refill 20 tokens per interval. 1785 20, // Refill 20 tokens per interval.
1786 base::TimeDelta::FromMinutes(10) // 10 minutes refill interval. 1786 base::TimeDelta::FromMinutes(10) // 10 minutes refill interval.
1787 }; 1787 };
1788 QuotaLimitHeuristic::BucketMapper* bucket_mapper = 1788 QuotaLimitHeuristic::BucketMapper* bucket_mapper =
1789 new QuotaLimitHeuristic::SingletonBucketMapper(); 1789 new QuotaLimitHeuristic::SingletonBucketMapper();
1790 ClearCacheQuotaHeuristic* heuristic = 1790 ClearCacheQuotaHeuristic* heuristic =
1791 new ClearCacheQuotaHeuristic(config, bucket_mapper); 1791 new ClearCacheQuotaHeuristic(config, bucket_mapper);
1792 heuristics->push_back(heuristic); 1792 heuristics->push_back(heuristic);
1793 } 1793 }
1794 1794
1795 void WebRequestHandlerBehaviorChanged::OnQuotaExceeded() { 1795 void WebRequestHandlerBehaviorChanged::OnQuotaExceeded(
1796 const std::string& violation_error) {
1796 // Post warning message. 1797 // Post warning message.
1797 std::set<std::string> extension_ids; 1798 std::set<std::string> extension_ids;
1798 extension_ids.insert(extension_id()); 1799 extension_ids.insert(extension_id());
1799 BrowserThread::PostTask( 1800 BrowserThread::PostTask(
1800 BrowserThread::UI, 1801 BrowserThread::UI,
1801 FROM_HERE, 1802 FROM_HERE,
1802 base::Bind(&ExtensionWarningSet::NotifyWarningsOnUI, 1803 base::Bind(&ExtensionWarningSet::NotifyWarningsOnUI,
1803 profile_id(), 1804 profile_id(),
1804 extension_ids, 1805 extension_ids,
1805 ExtensionWarningSet::kRepeatedCacheFlushes)); 1806 ExtensionWarningSet::kRepeatedCacheFlushes));
(...skipping 26 matching lines...) Expand all
1832 } else if ((*it)->name().find("AdBlock") != std::string::npos) { 1833 } else if ((*it)->name().find("AdBlock") != std::string::npos) {
1833 adblock = true; 1834 adblock = true;
1834 } else { 1835 } else {
1835 other = true; 1836 other = true;
1836 } 1837 }
1837 } 1838 }
1838 } 1839 }
1839 1840
1840 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); 1841 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other));
1841 } 1842 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698