Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: include/AdblockPlus/ReferrerMapping.h

Issue 5768603836088320: Issue 1564-Fix FilterEngine::Matches for allowing request which is whitelisted in the ascendant node
Patch Set: rename BuildReferrerChain to BuildFrameStructure Created Nov. 25, 2014, 12:40 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/ReferrerMapping.cpp » ('j') | src/ReferrerMapping.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/AdblockPlus/ReferrerMapping.h
===================================================================
--- a/include/AdblockPlus/ReferrerMapping.h
+++ b/include/AdblockPlus/ReferrerMapping.h
@@ -22,14 +22,14 @@
#include <map>
#include <string>
#include <vector>
+#include "FilterEngine.h"
namespace AdblockPlus
{
/**
* Stores a mapping between URLs and their referrers.
- * This can be used to build a chain of referrers for any URL
- * (see `BuildReferrerChain()`), which approximates the frame structure, see
- * FilterEngine::Matches().
+ * This can be used to build a frame structure for any URL
+ * (see `BuildFrameStructure()`), it's useful for FilterEngine::Matches().
*/
class ReferrerMapping
{
@@ -46,20 +46,31 @@
* Records the refferer for a URL.
* @param url Request URL.
* @param referrer Request referrer.
+ * @param requestType Request type.
*/
- void Add(const std::string& url, const std::string& referrer);
+ void Add(const std::string& url, const std::string& referrer,
+ FilterEngine::ContentType requestType);
/**
- * Builds a chain of referrers for the supplied URL.
+ * Builds a frame structure for the supplied URL.
* This should reconstruct a document's parent frame URLs.
* @param url URL to build the chain for.
- * @return List of URLs, starting with `url`.
+ * @return List of URLs, finishing with `url`.
*/
- std::vector<std::string> BuildReferrerChain(const std::string& url) const;
+ std::vector<std::string> BuildFrameStructure(const std::string& url) const;
private:
const int maxCachedUrls;
- std::map<std::string, std::string> mapping;
+ struct RequestInfo
+ {
+ RequestInfo(const std::string& referrerArg, FilterEngine::ContentType typeArg)
+ : referrer(referrerArg) , type(typeArg)
+ {
+ }
+ std::string referrer;
+ FilterEngine::ContentType type;
Wladimir Palant 2014/11/25 15:46:37 It is unnecessary to store the actual type here -
sergei 2014/11/26 10:34:43 I would use `isFrame` because it's not necessary t
+ };
+ std::map</*url*/std::string, RequestInfo> mapping;
Wladimir Palant 2014/11/25 15:46:37 How about |using URL = std::string| so that you ca
sergei 2014/11/26 10:34:43 Added typedef for `Url` and `Urls`.
std::list<std::string> cachedUrls;
};
}
« no previous file with comments | « no previous file | src/ReferrerMapping.cpp » ('j') | src/ReferrerMapping.cpp » ('J')

Powered by Google App Engine
This is Rietveld