Commit 3a41274e authored by Victor Costan's avatar Victor Costan Committed by Commit Bot

AppCache: Remove unnecessary type aliases.

AppCacheNamespaceVector is std::vector<AppCacheNamespace>.
AppCacheResourceInfoVector is std::vector<AppCacheResourceInfo>. These
aliases don't hold their weight, because the noise saved is outweighed
by the reader having to figure out / remember if they represent special
data types, or just std::vector.

kEnableExecutableHeaders is unused.

Change-Id: I19a32054dd0d08e7026e9aaf8a2b19e0c48d51ed
Reviewed-on: https://chromium-review.googlesource.com/1188383Reviewed-by: default avatarJoshua Bell <jsbell@chromium.org>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Commit-Queue: Victor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585998}
parent e589565c
......@@ -85,8 +85,9 @@ const AppCacheEntry* AppCache::GetEntryAndUrlWithResponseId(
return nullptr;
}
GURL AppCache::GetNamespaceEntryUrl(const AppCacheNamespaceVector& namespaces,
const GURL& namespace_url) const {
GURL AppCache::GetNamespaceEntryUrl(
const std::vector<AppCacheNamespace>& namespaces,
const GURL& namespace_url) const {
size_t count = namespaces.size();
for (size_t i = 0; i < count; ++i) {
if (namespaces[i].namespace_url == namespace_url)
......@@ -262,8 +263,8 @@ bool AppCache::FindResponseForRequest(const GURL& url,
return *found_network_namespace;
}
void AppCache::ToResourceInfoVector(AppCacheResourceInfoVector* infos) const {
void AppCache::ToResourceInfoVector(
std::vector<AppCacheResourceInfo>* infos) const {
DCHECK(infos && infos->empty());
for (const auto& pair : entries_) {
infos->push_back(AppCacheResourceInfo());
......@@ -282,7 +283,7 @@ void AppCache::ToResourceInfoVector(AppCacheResourceInfoVector* infos) const {
// static
const AppCacheNamespace* AppCache::FindNamespace(
const AppCacheNamespaceVector& namespaces,
const std::vector<AppCacheNamespace>& namespaces,
const GURL& url) {
size_t count = namespaces.size();
for (size_t i = 0; i < count; ++i) {
......
......@@ -130,10 +130,10 @@ class CONTENT_EXPORT AppCache
bool* found_network_namespace);
// Populates the 'infos' vector with an element per entry in the appcache.
void ToResourceInfoVector(AppCacheResourceInfoVector* infos) const;
void ToResourceInfoVector(std::vector<AppCacheResourceInfo>* infos) const;
static const AppCacheNamespace* FindNamespace(
const AppCacheNamespaceVector& namespaces,
const std::vector<AppCacheNamespace>& namespaces,
const GURL& url);
private:
......@@ -160,7 +160,7 @@ class CONTENT_EXPORT AppCache
return FindNamespace(online_whitelist_namespaces_, url) != nullptr;
}
GURL GetNamespaceEntryUrl(const AppCacheNamespaceVector& namespaces,
GURL GetNamespaceEntryUrl(const std::vector<AppCacheNamespace>& namespaces,
const GURL& namespace_url) const;
// Use AppCacheHost::Associate*Cache() to manipulate host association.
......@@ -175,9 +175,9 @@ class CONTENT_EXPORT AppCache
EntryMap entries_; // contains entries of all types
AppCacheNamespaceVector intercept_namespaces_;
AppCacheNamespaceVector fallback_namespaces_;
AppCacheNamespaceVector online_whitelist_namespaces_;
std::vector<AppCacheNamespace> intercept_namespaces_;
std::vector<AppCacheNamespace> fallback_namespaces_;
std::vector<AppCacheNamespace> online_whitelist_namespaces_;
bool online_whitelist_all_;
bool is_complete_;
......
......@@ -4,6 +4,8 @@
#include "content/browser/appcache/appcache_host.h"
#include <vector>
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/strings/string_util.h"
......@@ -319,7 +321,7 @@ std::unique_ptr<AppCacheRequestHandler> AppCacheHost::CreateRequestHandler(
}
void AppCacheHost::GetResourceList(
AppCacheResourceInfoVector* resource_infos) {
std::vector<AppCacheResourceInfo>* resource_infos) {
if (associated_cache_.get() && associated_cache_->is_complete())
associated_cache_->ToResourceInfoVector(resource_infos);
}
......
......@@ -127,7 +127,7 @@ GetDictionaryValueForAppCacheResourceInfo(
}
std::unique_ptr<base::ListValue> GetListValueForAppCacheResourceInfoVector(
AppCacheResourceInfoVector* resource_info_vector) {
std::vector<AppCacheResourceInfo>* resource_info_vector) {
std::unique_ptr<base::ListValue> list(new base::ListValue);
for (const AppCacheResourceInfo& res_info : *resource_info_vector)
list->Append(GetDictionaryValueForAppCacheResourceInfo(res_info));
......@@ -238,9 +238,9 @@ void AppCacheInternalsUI::Proxy::RequestAppCacheDetails(
void AppCacheInternalsUI::Proxy::OnGroupLoaded(AppCacheGroup* appcache_group,
const GURL& manifest_gurl) {
std::unique_ptr<AppCacheResourceInfoVector> resource_info_vector;
std::unique_ptr<std::vector<AppCacheResourceInfo>> resource_info_vector;
if (appcache_group && appcache_group->newest_complete_cache()) {
resource_info_vector.reset(new AppCacheResourceInfoVector);
resource_info_vector.reset(new std::vector<AppCacheResourceInfo>);
appcache_group->newest_complete_cache()->ToResourceInfoVector(
resource_info_vector.get());
std::sort(resource_info_vector->begin(), resource_info_vector->end(),
......@@ -445,7 +445,7 @@ void AppCacheInternalsUI::OnAppCacheInfoDeleted(
void AppCacheInternalsUI::OnAppCacheDetailsReady(
const base::FilePath& partition_path,
const std::string& manifest_url,
std::unique_ptr<AppCacheResourceInfoVector> resource_info_vector) {
std::unique_ptr<std::vector<AppCacheResourceInfo>> resource_info_vector) {
if (resource_info_vector) {
web_ui()->CallJavascriptFunctionUnsafe(
kFunctionOnAppCacheDetailsReady, base::Value(manifest_url),
......
......@@ -9,6 +9,7 @@
#include <list>
#include <memory>
#include <vector>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
......@@ -108,7 +109,7 @@ class AppCacheInternalsUI : public WebUIController {
void OnAppCacheDetailsReady(
const base::FilePath& partition_path,
const std::string& manifest_url,
std::unique_ptr<AppCacheResourceInfoVector> resource_info_vector);
std::unique_ptr<std::vector<AppCacheResourceInfo>> resource_info_vector);
void OnFileDetailsReady(const Proxy::ResponseEnquiry& response_enquiry,
scoped_refptr<AppCacheResponseInfo> response_info,
scoped_refptr<net::IOBuffer> response_data,
......
......@@ -48,9 +48,9 @@ struct CONTENT_EXPORT AppCacheManifest {
~AppCacheManifest();
base::hash_set<std::string> explicit_urls;
AppCacheNamespaceVector intercept_namespaces;
AppCacheNamespaceVector fallback_namespaces;
AppCacheNamespaceVector online_whitelist_namespaces;
std::vector<AppCacheNamespace> intercept_namespaces;
std::vector<AppCacheNamespace> fallback_namespaces;
std::vector<AppCacheNamespace> online_whitelist_namespaces;
bool online_whitelist_all = false;
bool did_ignore_intercept_namespaces = false;
bool did_ignore_fallback_namespaces = false;
......
......@@ -5,6 +5,7 @@
#include <stddef.h>
#include <string>
#include <vector>
#include "base/macros.h"
#include "content/browser/appcache/appcache_manifest_parser.h"
......@@ -174,7 +175,8 @@ TEST(AppCacheManifestParserTest, WhitelistUrls) {
EXPECT_FALSE(manifest.did_ignore_intercept_namespaces);
EXPECT_FALSE(manifest.did_ignore_fallback_namespaces);
const AppCacheNamespaceVector& online = manifest.online_whitelist_namespaces;
const std::vector<AppCacheNamespace>& online =
manifest.online_whitelist_namespaces;
const size_t kExpected = 6;
ASSERT_EQ(kExpected, online.size());
EXPECT_EQ(APPCACHE_NETWORK_NAMESPACE, online[0].type);
......@@ -223,7 +225,8 @@ TEST(AppCacheManifestParserTest, FallbackUrls) {
EXPECT_FALSE(manifest.did_ignore_intercept_namespaces);
EXPECT_FALSE(manifest.did_ignore_fallback_namespaces);
const AppCacheNamespaceVector& fallbacks = manifest.fallback_namespaces;
const std::vector<AppCacheNamespace>& fallbacks =
manifest.fallback_namespaces;
const size_t kExpected = 5;
ASSERT_EQ(kExpected, fallbacks.size());
EXPECT_EQ(APPCACHE_FALLBACK_NAMESPACE, fallbacks[0].type);
......@@ -281,7 +284,8 @@ TEST(AppCacheManifestParserTest, FallbackUrlsWithPort) {
EXPECT_TRUE(manifest.online_whitelist_namespaces.empty());
EXPECT_FALSE(manifest.online_whitelist_all);
const AppCacheNamespaceVector& fallbacks = manifest.fallback_namespaces;
const std::vector<AppCacheNamespace>& fallbacks =
manifest.fallback_namespaces;
const size_t kExpected = 3;
ASSERT_EQ(kExpected, fallbacks.size());
EXPECT_EQ(APPCACHE_FALLBACK_NAMESPACE, fallbacks[0].type);
......@@ -334,7 +338,8 @@ TEST(AppCacheManifestParserTest, InterceptUrls) {
EXPECT_FALSE(manifest.did_ignore_intercept_namespaces);
EXPECT_FALSE(manifest.did_ignore_fallback_namespaces);
const AppCacheNamespaceVector& intercepts = manifest.intercept_namespaces;
const std::vector<AppCacheNamespace>& intercepts =
manifest.intercept_namespaces;
const size_t kExpected = 3;
ASSERT_EQ(kExpected, intercepts.size());
EXPECT_EQ(APPCACHE_INTERCEPT_NAMESPACE, intercepts[0].type);
......@@ -401,7 +406,8 @@ TEST(AppCacheManifestParserTest, ComboUrls) {
EXPECT_TRUE(urls.find("http://combo.com:99/explicit-2") != urls.end());
EXPECT_TRUE(urls.find("http://www.diff.com/explicit-3") != urls.end());
const AppCacheNamespaceVector& online = manifest.online_whitelist_namespaces;
const std::vector<AppCacheNamespace>& online =
manifest.online_whitelist_namespaces;
expected = 4;
ASSERT_EQ(expected, online.size());
EXPECT_EQ(GURL("http://combo.com/whitelist-1"),
......@@ -413,7 +419,8 @@ TEST(AppCacheManifestParserTest, ComboUrls) {
EXPECT_EQ(GURL("http://combo.com:99/whitelist-4"),
online[3].namespace_url);
const AppCacheNamespaceVector& fallbacks = manifest.fallback_namespaces;
const std::vector<AppCacheNamespace>& fallbacks =
manifest.fallback_namespaces;
expected = 2;
ASSERT_EQ(expected, fallbacks.size());
EXPECT_EQ(APPCACHE_FALLBACK_NAMESPACE, fallbacks[0].type);
......
......@@ -872,7 +872,7 @@ class NetworkNamespaceHelper {
bool IsInNetworkNamespace(const GURL& url, int64_t cache_id) {
std::pair<WhiteListMap::iterator, bool> result = namespaces_map_.insert(
WhiteListMap::value_type(cache_id, AppCacheNamespaceVector()));
WhiteListMap::value_type(cache_id, std::vector<AppCacheNamespace>()));
if (result.second)
GetOnlineWhiteListForCache(cache_id, &result.first->second);
return AppCache::FindNamespace(result.first->second, url) != nullptr;
......@@ -880,7 +880,7 @@ class NetworkNamespaceHelper {
private:
void GetOnlineWhiteListForCache(int64_t cache_id,
AppCacheNamespaceVector* namespaces) {
std::vector<AppCacheNamespace>* namespaces) {
DCHECK(namespaces && namespaces->empty());
using WhiteListVector =
std::vector<AppCacheDatabase::OnlineWhiteListRecord>;
......@@ -896,7 +896,7 @@ class NetworkNamespaceHelper {
}
// Key is cache id
using WhiteListMap = std::map<int64_t, AppCacheNamespaceVector>;
using WhiteListMap = std::map<int64_t, std::vector<AppCacheNamespace>>;
WhiteListMap namespaces_map_;
AppCacheDatabase* database_;
};
......
......@@ -5,6 +5,8 @@
#include <stddef.h>
#include <stdint.h>
#include <vector>
#include "base/test/scoped_task_environment.h"
#include "content/browser/appcache/appcache.h"
#include "content/browser/appcache/appcache_host.h"
......@@ -136,7 +138,7 @@ TEST_F(AppCacheTest, InitializeWithManifest) {
EXPECT_EQ(GURL("http://fb1.com"), fallbacks[0].namespace_url);
EXPECT_EQ(GURL("http://fbone.com"), fallbacks[0].target_url);
EXPECT_TRUE(fallbacks[0].is_pattern);
const AppCacheNamespaceVector& whitelist =
const std::vector<AppCacheNamespace>& whitelist =
cache->online_whitelist_namespaces_;
expected = 2;
EXPECT_EQ(expected, whitelist.size());
......
......@@ -42,8 +42,6 @@ enum AppCacheNamespaceType {
APPCACHE_NETWORK_NAMESPACE
};
typedef std::vector<AppCacheResourceInfo> AppCacheResourceInfoVector;
struct CONTENT_EXPORT AppCacheNamespace {
AppCacheNamespace(); // Type is APPCACHE_FALLBACK_NAMESPACE by default.
AppCacheNamespace(AppCacheNamespaceType type, const GURL& url,
......@@ -58,8 +56,6 @@ struct CONTENT_EXPORT AppCacheNamespace {
bool is_pattern;
};
typedef std::vector<AppCacheNamespace> AppCacheNamespaceVector;
// Interface used by backend (browser-process) to talk to frontend (renderer).
class CONTENT_EXPORT AppCacheFrontend {
public:
......@@ -117,9 +113,6 @@ class CONTENT_EXPORT AppCacheBackend {
CONTENT_EXPORT extern const char kHttpGETMethod[];
CONTENT_EXPORT extern const char kHttpHEADMethod[];
// base::CommandLine flag to turn this experimental feature on.
CONTENT_EXPORT extern const char kEnableExecutableHandlers[];
CONTENT_EXPORT bool IsSchemeSupportedForAppCache(const GURL& url);
CONTENT_EXPORT bool IsMethodSupportedForAppCache(
const std::string& method);
......
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