Left: | ||
Right: |
OLD | NEW |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 17 matching lines...) Expand all Loading... | |
28 void operator()(LogLevel logLevel, const std::string& message, | 28 void operator()(LogLevel logLevel, const std::string& message, |
29 const std::string& source) | 29 const std::string& source) |
30 { | 30 { |
31 throw std::runtime_error("Unexpected error: " + message); | 31 throw std::runtime_error("Unexpected error: " + message); |
32 } | 32 } |
33 }; | 33 }; |
34 | 34 |
35 class ThrowingFileSystem : public AdblockPlus::FileSystem | 35 class ThrowingFileSystem : public AdblockPlus::FileSystem |
36 { | 36 { |
37 public: | 37 public: |
38 std::tr1::shared_ptr<std::istream> Read(const std::string& path) const | 38 std::shared_ptr<std::istream> Read(const std::string& path) const |
39 { | 39 { |
40 throw std::runtime_error("Not implemented"); | 40 throw std::runtime_error("Not implemented"); |
41 } | 41 } |
42 | 42 |
43 void Write(const std::string& path, | 43 void Write(const std::string& path, |
44 std::tr1::shared_ptr<std::istream> content) | 44 std::shared_ptr<std::istream> content) |
Felix Dahlke
2015/08/05 21:28:05
Nit: This was wrapped because it didn't fit in 80
sergei
2015/08/06 07:35:30
Done.
| |
45 { | 45 { |
46 throw std::runtime_error("Not implemented"); | 46 throw std::runtime_error("Not implemented"); |
47 } | 47 } |
48 | 48 |
49 void Move(const std::string& fromPath, const std::string& toPath) | 49 void Move(const std::string& fromPath, const std::string& toPath) |
50 { | 50 { |
51 throw std::runtime_error("Not implemented"); | 51 throw std::runtime_error("Not implemented"); |
52 } | 52 } |
53 | 53 |
54 void Remove(const std::string& path) | 54 void Remove(const std::string& path) |
(...skipping 18 matching lines...) Expand all Loading... | |
73 public: | 73 public: |
74 AdblockPlus::ServerResponse GET(const std::string& url, const AdblockPlus::Hea derList& requestHeaders) const | 74 AdblockPlus::ServerResponse GET(const std::string& url, const AdblockPlus::Hea derList& requestHeaders) const |
75 { | 75 { |
76 throw std::runtime_error("Unexpected GET: " + url); | 76 throw std::runtime_error("Unexpected GET: " + url); |
77 } | 77 } |
78 }; | 78 }; |
79 | 79 |
80 class LazyFileSystem : public AdblockPlus::FileSystem | 80 class LazyFileSystem : public AdblockPlus::FileSystem |
81 { | 81 { |
82 public: | 82 public: |
83 std::tr1::shared_ptr<std::istream> Read(const std::string& path) const | 83 std::shared_ptr<std::istream> Read(const std::string& path) const |
84 { | 84 { |
85 std::string dummyData(""); | 85 std::string dummyData(""); |
86 if (path == "patterns.ini") | 86 if (path == "patterns.ini") |
87 dummyData = "# Adblock Plus preferences\n[Subscription]\nurl=~fl~"; | 87 dummyData = "# Adblock Plus preferences\n[Subscription]\nurl=~fl~"; |
88 else if (path == "prefs.json") | 88 else if (path == "prefs.json") |
89 dummyData = "{}"; | 89 dummyData = "{}"; |
90 return std::tr1::shared_ptr<std::istream>(new std::istringstream(dummyData)) ; | 90 return std::shared_ptr<std::istream>(new std::istringstream(dummyData)); |
91 } | 91 } |
92 | 92 |
93 void Write(const std::string& path, | 93 void Write(const std::string& path, |
94 std::tr1::shared_ptr<std::istream> content) | 94 std::shared_ptr<std::istream> content) |
Felix Dahlke
2015/08/05 21:28:05
Nit: This was wrapped because it didn't fit in 80
sergei
2015/08/06 07:35:30
Done.
| |
95 { | 95 { |
96 } | 96 } |
97 | 97 |
98 void Move(const std::string& fromPath, const std::string& toPath) | 98 void Move(const std::string& fromPath, const std::string& toPath) |
99 { | 99 { |
100 } | 100 } |
101 | 101 |
102 void Remove(const std::string& path) | 102 void Remove(const std::string& path) |
103 { | 103 { |
104 } | 104 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
148 virtual void SetUp() | 148 virtual void SetUp() |
149 { | 149 { |
150 jsEngine = AdblockPlus::JsEngine::New(); | 150 jsEngine = AdblockPlus::JsEngine::New(); |
151 jsEngine->SetLogSystem(AdblockPlus::LogSystemPtr(new ThrowingLogSystem)); | 151 jsEngine->SetLogSystem(AdblockPlus::LogSystemPtr(new ThrowingLogSystem)); |
152 jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new ThrowingFileSystem)); | 152 jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new ThrowingFileSystem)); |
153 jsEngine->SetWebRequest(AdblockPlus::WebRequestPtr(new ThrowingWebRequest)); | 153 jsEngine->SetWebRequest(AdblockPlus::WebRequestPtr(new ThrowingWebRequest)); |
154 } | 154 } |
155 }; | 155 }; |
156 | 156 |
157 #endif | 157 #endif |
OLD | NEW |