| Index: include/AdblockPlus/ReferrerMapping.h |
| =================================================================== |
| --- a/include/AdblockPlus/ReferrerMapping.h |
| +++ b/include/AdblockPlus/ReferrerMapping.h |
| @@ -22,18 +22,29 @@ |
| #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 |
| { |
| public: |
| + /// The type for URL. |
| + typedef std::string Url; |
| + |
| + /// Contains the ordered list of URLs. |
|
Wladimir Palant
2014/12/09 21:20:03
Nit: *an* ordered list
|
| + typedef std::vector<Url> Urls; |
| + |
| + /// Indicates whether the URL is a frame or not. |
| + enum FrameIndicator |
| + { |
| + FRAME_INDICATOR_NOT_A_FRAME = 0, FRAME_INDICATOR_FRAME= 1 |
|
Wladimir Palant
2014/12/09 21:20:03
Extreme nit: articles seem wrong in constant names
sergei
2014/12/12 17:07:07
I know, I thought about it but don't remember the
|
| + }; |
| /** |
| * Constructor. |
| * @param maxCachedUrls Number of URL mappings to store. The higher the |
| @@ -46,21 +57,37 @@ |
| * Records the refferer for a URL. |
| * @param url Request URL. |
| * @param referrer Request referrer. |
| + * @param isFrame Indicates whether the url is a frame. |
| */ |
| - void Add(const std::string& url, const std::string& referrer); |
| + void Add(const Url& url, const Url& referrer, FrameIndicator isFrame); |
| /** |
| - * 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; |
| + Urls BuildFrameStructure(const Url& url) const; |
| private: |
| const int maxCachedUrls; |
| - std::map<std::string, std::string> mapping; |
| - std::list<std::string> cachedUrls; |
| + struct RequestInfo |
| + { |
| + explicit RequestInfo(const Url& referrerArg = Url(), |
| + FrameIndicator frameIndicatorArg = FrameIndicator::FRAME_INDICATOR_NOT_A_FRAME) |
|
Wladimir Palant
2014/12/09 21:20:03
Shouldn't you have that default value in method Ad
sergei
2014/12/12 17:07:07
These default arguments are required by std::map,
|
| + : referrer(referrerArg), frameIndicator(frameIndicatorArg) |
| + { |
| + } |
| + bool IsFrame() const |
| + { |
| + return frameIndicator == FrameIndicator::FRAME_INDICATOR_FRAME; |
| + } |
| + Url referrer; |
| + FrameIndicator frameIndicator; |
| + }; |
| + typedef std::map<Url, RequestInfo> ReferrerMap; |
| + ReferrerMap mapping; |
| + std::list<Url> cachedUrls; |
| }; |
| } |