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

Unified Diff: extensions/browser/guest_view/web_view/web_view_guest.cc

Issue 885493007: Refactoring: de-couple Extensions from "script injection System" [render side] : 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert key of IsolatedWorldMap as std::string. Created 5 years, 10 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: extensions/browser/guest_view/web_view/web_view_guest.cc
diff --git a/extensions/browser/guest_view/web_view/web_view_guest.cc b/extensions/browser/guest_view/web_view/web_view_guest.cc
index 9e60bfddef4d22bf074249c6b43c9b6dcf436630..dd0d14bfda625eff134c8e96834844cede90e6b6 100644
--- a/extensions/browser/guest_view/web_view/web_view_guest.cc
+++ b/extensions/browser/guest_view/web_view/web_view_guest.cc
@@ -59,6 +59,11 @@ namespace extensions {
namespace {
+using WebViewKey = std::pair<int, int>;
+using WebViewKeyToIDMap = std::map<WebViewKey, int>;
+base::LazyInstance<WebViewKeyToIDMap> web_view_key_to_id_map =
+ LAZY_INSTANCE_INITIALIZER;
+
std::string WindowOpenDispositionToString(
WindowOpenDisposition window_open_disposition) {
switch (window_open_disposition) {
@@ -181,30 +186,24 @@ bool WebViewGuest::GetGuestPartitionConfigForSite(
// static
const char WebViewGuest::Type[] = "webview";
-using WebViewKey = std::pair<int, int>;
-using WebViewKeyToIDMap = std::map<WebViewKey, int>;
-static base::LazyInstance<WebViewKeyToIDMap> web_view_key_to_id_map =
Devlin 2015/02/13 18:27:08 Since we're not really adding anything to these fi
Xi Han 2015/02/13 19:11:28 Ok, revert all the changes.
- LAZY_INSTANCE_INITIALIZER;
-
// static
int WebViewGuest::GetOrGenerateRulesRegistryID(
int embedder_process_id,
- int webview_instance_id) {
- bool is_web_view = embedder_process_id && webview_instance_id;
- if (!is_web_view)
+ int web_view_instance_id) {
+ if (!embedder_process_id || !web_view_instance_id)
return RulesRegistryService::kDefaultRulesRegistryID;
- WebViewKey key = std::make_pair(embedder_process_id, webview_instance_id);
- auto it = web_view_key_to_id_map.Get().find(key);
- if (it != web_view_key_to_id_map.Get().end())
+ WebViewKey key(embedder_process_id, web_view_instance_id);
+ WebViewKeyToIDMap& map = web_view_key_to_id_map.Get();
+ auto it = map.find(key);
+ if (it != map.end())
return it->second;
auto rph = content::RenderProcessHost::FromID(embedder_process_id);
- int rules_registry_id =
- RulesRegistryService::Get(rph->GetBrowserContext())->
- GetNextRulesRegistryID();
- web_view_key_to_id_map.Get()[key] = rules_registry_id;
- return rules_registry_id;
+ int id = RulesRegistryService::Get(rph->GetBrowserContext())->
+ GetNextRulesRegistryID();
+ map[key] = id;
+ return id;
}
// static

Powered by Google App Engine
This is Rietveld 408576698