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(
ContentSettingsType settings_type,
const base::string16& details) {
// Send multiple ContentBlocked messages if details are provided.
bool& blocked = content_blocked_[settings_type];
if (!blocked || !details.empty()) {
blocked = true;
bool newly_blocked = content_blocked_.insert(settings_type).second;
if (newly_blocked || !details.empty()) {
Send(new ChromeViewHostMsg_ContentBlocked(routing_id(), settings_type,
details));
}
......@@ -531,7 +530,7 @@ void ContentSettingsObserver::OnSetAsInterstitial() {
void ContentSettingsObserver::OnRequestFileSystemAccessAsyncResponse(
int request_id,
bool allowed) {
PermissionRequestMap::iterator it = permission_requests_.find(request_id);
auto it = permission_requests_.find(request_id);
if (it == permission_requests_.end())
return;
......
......@@ -5,12 +5,11 @@
#ifndef CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_
#define CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include "base/containers/flat_map.h"
#include "base/containers/flat_set.h"
#include "base/gtest_prod_util.h"
#include "base/time/time.h"
#include "chrome/common/insecure_content_renderer.mojom.h"
......@@ -164,22 +163,20 @@ class ContentSettingsObserver
const RendererContentSettingRules* content_setting_rules_;
// 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.
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.
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_;
int current_request_id_;
using PermissionRequestMap =
std::unordered_map<int, blink::WebContentSettingCallbacks>;
PermissionRequestMap permission_requests_;
base::flat_map<int, blink::WebContentSettingCallbacks> permission_requests_;
// If true, IsWhitelistedForContentSettings will always return true.
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