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

Side by Side Diff: src/shared/ContentType.cpp

Issue 5316782940225536: Issue 1557 - Update to the recent libadblockplus to reduce additional updates in the logic later. (Closed)
Patch Set: add hg subrepo file Created Jan. 28, 2015, 1:36 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/shared/ContentType.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #include "ContentType.h"
2
3 // Based on impl from libadblockplus
4
5 using AdblockPlus::FilterEngine;
6
7 namespace
8 {
9 typedef std::map<FilterEngine::ContentType, std::string> ContentTypeMap;
10 ContentTypeMap CreateContentTypeMap()
11 {
12 ContentTypeMap contentTypes;
13 contentTypes[FilterEngine::CONTENT_TYPE_OTHER] = "OTHER";
14 contentTypes[FilterEngine::CONTENT_TYPE_SCRIPT] = "SCRIPT";
15 contentTypes[FilterEngine::CONTENT_TYPE_IMAGE] = "IMAGE";
16 contentTypes[FilterEngine::CONTENT_TYPE_STYLESHEET] = "STYLESHEET";
17 contentTypes[FilterEngine::CONTENT_TYPE_OBJECT] = "OBJECT";
18 contentTypes[FilterEngine::CONTENT_TYPE_SUBDOCUMENT] = "SUBDOCUMENT";
19 contentTypes[FilterEngine::CONTENT_TYPE_DOCUMENT] = "DOCUMENT";
20 contentTypes[FilterEngine::CONTENT_TYPE_XMLHTTPREQUEST] = "XMLHTTPREQUEST";
21 contentTypes[FilterEngine::CONTENT_TYPE_OBJECT_SUBREQUEST] = "OBJECT_SUBREQU EST";
22 contentTypes[FilterEngine::CONTENT_TYPE_FONT] = "FONT";
23 contentTypes[FilterEngine::CONTENT_TYPE_MEDIA] = "MEDIA";
24 contentTypes[FilterEngine::CONTENT_TYPE_ELEMHIDE] = "ELEMHIDE";
25 return contentTypes;
26 }
27 const ContentTypeMap g_contentTypes = CreateContentTypeMap();
28 }
29
30 std::string ContentTypeToString(AdblockPlus::FilterEngine::ContentType contentTy pe)
31 {
32 ContentTypeMap::const_iterator it = g_contentTypes.find(contentType);
33 if (it != g_contentTypes.end())
34 return it->second;
35 throw std::invalid_argument("Argument is not a valid ContentType");
36 }
37
38 #include "Communication.h"
39
40 using Communication::InputBuffer;
41 using Communication::OutputBuffer;
42
43 InputBuffer& operator>>(InputBuffer& in, FilterEngine::ContentType& contentType)
44 {
45 int32_t type;
46 in >> type;
47 contentType = static_cast<FilterEngine::ContentType>(contentType);
48 return in;
49 }
50
51 OutputBuffer& operator<<(OutputBuffer& out, FilterEngine::ContentType contentTyp e)
52 {
53 return out << static_cast<int32_t>(contentType);
54 }
OLDNEW
« no previous file with comments | « src/shared/ContentType.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld