Commit a3774c16 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Use flat containers in ContentSettingsObserver.

Change-Id: Ic6489f81849456c7ce225cda73c5c08ec41e8e29
Reviewed-on: https://chromium-review.googlesource.com/747161
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: default avatarTarun Bansal <tbansal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#513012}
parent 65bd80c6
...@@ -172,9 +172,8 @@ void ContentSettingsObserver::DidBlockContentType( ...@@ -172,9 +172,8 @@ void ContentSettingsObserver::DidBlockContentType(
ContentSettingsType settings_type, ContentSettingsType settings_type,
const base::string16& details) { const base::string16& details) {
// Send multiple ContentBlocked messages if details are provided. // Send multiple ContentBlocked messages if details are provided.
bool& blocked = content_blocked_[settings_type]; bool newly_blocked = content_blocked_.insert(settings_type).second;
if (!blocked || !details.empty()) { if (newly_blocked || !details.empty()) {
blocked = true;
Send(new ChromeViewHostMsg_ContentBlocked(routing_id(), settings_type, Send(new ChromeViewHostMsg_ContentBlocked(routing_id(), settings_type,
details)); details));
} }
...@@ -531,7 +530,7 @@ void ContentSettingsObserver::OnSetAsInterstitial() { ...@@ -531,7 +530,7 @@ void ContentSettingsObserver::OnSetAsInterstitial() {
void ContentSettingsObserver::OnRequestFileSystemAccessAsyncResponse( void ContentSettingsObserver::OnRequestFileSystemAccessAsyncResponse(
int request_id, int request_id,
bool allowed) { bool allowed) {
PermissionRequestMap::iterator it = permission_requests_.find(request_id); auto it = permission_requests_.find(request_id);
if (it == permission_requests_.end()) if (it == permission_requests_.end())
return; return;
......
...@@ -5,12 +5,11 @@ ...@@ -5,12 +5,11 @@
#ifndef CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_ #ifndef CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_
#define CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_ #define CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_
#include <map>
#include <set>
#include <string> #include <string>
#include <unordered_map>
#include <utility> #include <utility>
#include "base/containers/flat_map.h"
#include "base/containers/flat_set.h"
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/common/insecure_content_renderer.mojom.h" #include "chrome/common/insecure_content_renderer.mojom.h"
...@@ -164,22 +163,20 @@ class ContentSettingsObserver ...@@ -164,22 +163,20 @@ class ContentSettingsObserver
const RendererContentSettingRules* content_setting_rules_; const RendererContentSettingRules* content_setting_rules_;
// Stores if images, scripts, and plugins have actually been blocked. // Stores if images, scripts, and plugins have actually been blocked.
std::map<ContentSettingsType, bool> content_blocked_; base::flat_set<ContentSettingsType> content_blocked_;
// Caches the result of AllowStorage. // Caches the result of AllowStorage.
using StoragePermissionsKey = std::pair<GURL, bool>; using StoragePermissionsKey = std::pair<GURL, bool>;
std::map<StoragePermissionsKey, bool> cached_storage_permissions_; base::flat_map<StoragePermissionsKey, bool> cached_storage_permissions_;
// Caches the result of AllowScript. // Caches the result of AllowScript.
std::unordered_map<blink::WebFrame*, bool> cached_script_permissions_; base::flat_map<blink::WebFrame*, bool> cached_script_permissions_;
std::set<std::string> temporarily_allowed_plugins_; base::flat_set<std::string> temporarily_allowed_plugins_;
bool is_interstitial_page_; bool is_interstitial_page_;
int current_request_id_; int current_request_id_;
using PermissionRequestMap = base::flat_map<int, blink::WebContentSettingCallbacks> permission_requests_;
std::unordered_map<int, blink::WebContentSettingCallbacks>;
PermissionRequestMap permission_requests_;
// If true, IsWhitelistedForContentSettings will always return true. // If true, IsWhitelistedForContentSettings will always return true.
const bool should_whitelist_; const bool should_whitelist_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment