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

Side by Side Diff: test/BaseJsTest.h

Issue 29481704: Noissue - Use buffer for FileSystem IO (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Nit addressed Created July 7, 2017, 12:50 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/Utils.cpp ('k') | test/DefaultFileSystem.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 void operator()(LogLevel logLevel, const std::string& message, 98 void operator()(LogLevel logLevel, const std::string& message,
99 const std::string& source) 99 const std::string& source)
100 { 100 {
101 throw std::runtime_error("Unexpected error: " + message); 101 throw std::runtime_error("Unexpected error: " + message);
102 } 102 }
103 }; 103 };
104 104
105 class ThrowingFileSystem : public AdblockPlus::FileSystem 105 class ThrowingFileSystem : public AdblockPlus::FileSystem
106 { 106 {
107 public: 107 public:
108 std::shared_ptr<std::istream> Read(const std::string& path) const 108 FileSystem::IOBuffer Read(const std::string& path) const
109 { 109 {
110 throw std::runtime_error("Not implemented"); 110 throw std::runtime_error("Not implemented");
111 } 111 }
112 112
113 void Write(const std::string& path, std::istream& content) 113 void Write(const std::string& path, const FileSystem::IOBuffer& content)
114 { 114 {
115 throw std::runtime_error("Not implemented"); 115 throw std::runtime_error("Not implemented");
116 } 116 }
117 117
118 void Move(const std::string& fromPath, const std::string& toPath) 118 void Move(const std::string& fromPath, const std::string& toPath)
119 { 119 {
120 throw std::runtime_error("Not implemented"); 120 throw std::runtime_error("Not implemented");
121 } 121 }
122 122
123 void Remove(const std::string& path) 123 void Remove(const std::string& path)
(...skipping 18 matching lines...) Expand all
142 public: 142 public:
143 void GET(const std::string& url, const AdblockPlus::HeaderList& requestHeaders , const GetCallback&) override 143 void GET(const std::string& url, const AdblockPlus::HeaderList& requestHeaders , const GetCallback&) override
144 { 144 {
145 throw std::runtime_error("Unexpected GET: " + url); 145 throw std::runtime_error("Unexpected GET: " + url);
146 } 146 }
147 }; 147 };
148 148
149 class LazyFileSystem : public AdblockPlus::FileSystem 149 class LazyFileSystem : public AdblockPlus::FileSystem
150 { 150 {
151 public: 151 public:
152 std::shared_ptr<std::istream> Read(const std::string& path) const 152 IOBuffer Read(const std::string& path) const
153 { 153 {
154 std::string dummyData(""); 154 std::string dummyData("");
155 if (path == "patterns.ini") 155 if (path == "patterns.ini")
156 dummyData = "# Adblock Plus preferences\n[Subscription]\nurl=~fl~"; 156 dummyData = "# Adblock Plus preferences\n[Subscription]\nurl=~fl~";
157 else if (path == "prefs.json") 157 else if (path == "prefs.json")
158 dummyData = "{}"; 158 dummyData = "{}";
159 return std::shared_ptr<std::istream>(new std::istringstream(dummyData)); 159 return IOBuffer(dummyData.cbegin(), dummyData.cend());
160 } 160 }
161 161
162 void Write(const std::string& path, std::istream& content) 162 void Write(const std::string& path, const IOBuffer& content)
163 { 163 {
164 } 164 }
165 165
166 void Move(const std::string& fromPath, const std::string& toPath) 166 void Move(const std::string& fromPath, const std::string& toPath)
167 { 167 {
168 } 168 }
169 169
170 void Remove(const std::string& path) 170 void Remove(const std::string& path)
171 { 171 {
172 } 172 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 protected: 240 protected:
241 AdblockPlus::JsEnginePtr jsEngine; 241 AdblockPlus::JsEnginePtr jsEngine;
242 242
243 virtual void SetUp() 243 virtual void SetUp()
244 { 244 {
245 jsEngine = CreateJsEngine(); 245 jsEngine = CreateJsEngine();
246 } 246 }
247 }; 247 };
248 248
249 #endif 249 #endif
OLDNEW
« no previous file with comments | « src/Utils.cpp ('k') | test/DefaultFileSystem.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld