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

Unified Diff: chrome/browser/extensions/api/declarative/rules_registry_with_cache.cc

Issue 28273006: <webview>: Implement declarativeWebRequest API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added tests Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/declarative/rules_registry_with_cache.cc
diff --git a/chrome/browser/extensions/api/declarative/rules_registry_with_cache.cc b/chrome/browser/extensions/api/declarative/rules_registry_with_cache.cc
index a452130fb03c26eacd4b2a2c1590c28fdd0c1538..aeebde6e898451cd65a97fd909c3d3e11f6d192e 100644
--- a/chrome/browser/extensions/api/declarative/rules_registry_with_cache.cc
+++ b/chrome/browser/extensions/api/declarative/rules_registry_with_cache.cc
@@ -60,12 +60,13 @@ std::vector<linked_ptr<extensions::RulesRegistry::Rule> > RulesFromValue(
}
// Returns the key to use for storing declarative rules in the state store.
-std::string GetDeclarativeRuleStorageKey(const std::string& event_name,
- bool incognito) {
- if (incognito)
- return "declarative_rules.incognito." + event_name;
- else
- return "declarative_rules." + event_name;
+std::string GetDeclarativeRuleStorageKey(
+ const std::string& event_name,
+ bool incognito,
+ const extensions::RulesRegistry::WebViewKey& webview_key) {
+ return base::StringPrintf("declarative_rules%s.%s.%d.%d",
+ incognito ? ".incognito" : "",
+ event_name.c_str(), webview_key.first, webview_key.second);
vabr (Chromium) 2013/10/25 20:40:24 Is this stable across browser restarts? As far as
Fady Samuel 2013/10/25 22:48:08 I was hoping to chat with someone about these chan
}
} // namespace
@@ -80,15 +81,17 @@ RulesRegistryWithCache::RulesRegistryWithCache(
const std::string& event_name,
content::BrowserThread::ID owner_thread,
bool log_storage_init_delay,
- scoped_ptr<RuleStorageOnUI>* ui_part)
- : RulesRegistry(owner_thread, event_name),
+ scoped_ptr<RuleStorageOnUI>* ui_part,
+ const WebViewKey& webview_key)
+ : RulesRegistry(owner_thread, event_name, webview_key),
weak_ptr_factory_(profile ? this : NULL),
storage_on_ui_(
(profile ? (new RuleStorageOnUI(profile,
event_name,
owner_thread,
weak_ptr_factory_.GetWeakPtr(),
- log_storage_init_delay))->GetWeakPtr()
+ log_storage_init_delay,
+ webview_key))->GetWeakPtr()
: base::WeakPtr<RuleStorageOnUI>())),
process_changed_rules_requested_(profile ? NOT_SCHEDULED_FOR_PROCESSING
: NEVER_PROCESS) {
@@ -276,12 +279,15 @@ RulesRegistryWithCache::RuleStorageOnUI::RuleStorageOnUI(
const std::string& event_name,
content::BrowserThread::ID rules_registry_thread,
base::WeakPtr<RulesRegistryWithCache> registry,
- bool log_storage_init_delay)
+ bool log_storage_init_delay,
+ const WebViewKey& webview_key)
: profile_(profile),
storage_key_(GetDeclarativeRuleStorageKey(event_name,
- profile->IsOffTheRecord())),
+ profile->IsOffTheRecord(),
+ webview_key)),
rules_stored_key_(GetRulesStoredKey(event_name,
- profile->IsOffTheRecord())),
+ profile->IsOffTheRecord(),
+ webview_key)),
log_storage_init_delay_(log_storage_init_delay),
registry_(registry),
rules_registry_thread_(rules_registry_thread),
@@ -294,10 +300,12 @@ RulesRegistryWithCache::RuleStorageOnUI::~RuleStorageOnUI() {}
// static
std::string RulesRegistryWithCache::RuleStorageOnUI::GetRulesStoredKey(
const std::string& event_name,
- bool incognito) {
- std::string result(kRulesStoredKey);
- result += incognito ? ".incognito." : ".";
- return result + event_name;
+ bool incognito,
+ const WebViewKey& webview_key) {
+ return base::StringPrintf("%s.%s%s.%d.%d",
+ kRulesStoredKey, incognito ? "incognito." : "",
+ event_name.c_str(),
+ webview_key.first, webview_key.second);
}
// This is called from the constructor of RulesRegistryWithCache, so it is

Powered by Google App Engine
This is Rietveld 408576698