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