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

Side by Side Diff: src/FileSystemJsObject.cpp

Issue 29393589: Issue 5013 - Make more methods const.- introduced JsConstValuePtr and JsConstValueList- JsValue:… (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Created March 23, 2017, 6:12 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
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } 69 }
70 catch (...) 70 catch (...)
71 { 71 {
72 error = "Unknown error while reading from " + path; 72 error = "Unknown error while reading from " + path;
73 } 73 }
74 74
75 const JsContext context(jsEngine); 75 const JsContext context(jsEngine);
76 JsValuePtr result = jsEngine->NewObject(); 76 JsValuePtr result = jsEngine->NewObject();
77 result->SetProperty("content", content); 77 result->SetProperty("content", content);
78 result->SetProperty("error", error); 78 result->SetProperty("error", error);
79 JsValueList params; 79 JsConstValueList params;
80 params.push_back(result); 80 params.push_back(result);
81 callback->Call(params); 81 callback->Call(params);
82 } 82 }
83 83
84 private: 84 private:
85 std::string path; 85 std::string path;
86 }; 86 };
87 87
88 class WriteThread : public IoThread 88 class WriteThread : public IoThread
89 { 89 {
(...skipping 17 matching lines...) Expand all
107 { 107 {
108 error = e.what(); 108 error = e.what();
109 } 109 }
110 catch (...) 110 catch (...)
111 { 111 {
112 error = "Unknown error while writing to " + path; 112 error = "Unknown error while writing to " + path;
113 } 113 }
114 114
115 const JsContext context(jsEngine); 115 const JsContext context(jsEngine);
116 JsValuePtr errorValue = jsEngine->NewValue(error); 116 JsValuePtr errorValue = jsEngine->NewValue(error);
117 JsValueList params; 117 JsConstValueList params;
118 params.push_back(errorValue); 118 params.push_back(errorValue);
119 callback->Call(params); 119 callback->Call(params);
120 } 120 }
121 121
122 private: 122 private:
123 std::string path; 123 std::string path;
124 std::string content; 124 std::string content;
125 }; 125 };
126 126
127 class MoveThread : public IoThread 127 class MoveThread : public IoThread
(...skipping 16 matching lines...) Expand all
144 { 144 {
145 error = e.what(); 145 error = e.what();
146 } 146 }
147 catch (...) 147 catch (...)
148 { 148 {
149 error = "Unknown error while moving " + fromPath + " to " + toPath; 149 error = "Unknown error while moving " + fromPath + " to " + toPath;
150 } 150 }
151 151
152 const JsContext context(jsEngine); 152 const JsContext context(jsEngine);
153 JsValuePtr errorValue = jsEngine->NewValue(error); 153 JsValuePtr errorValue = jsEngine->NewValue(error);
154 JsValueList params; 154 JsConstValueList params;
155 params.push_back(errorValue); 155 params.push_back(errorValue);
156 callback->Call(params); 156 callback->Call(params);
157 } 157 }
158 158
159 private: 159 private:
160 std::string fromPath; 160 std::string fromPath;
161 std::string toPath; 161 std::string toPath;
162 }; 162 };
163 163
164 class RemoveThread : public IoThread 164 class RemoveThread : public IoThread
(...skipping 16 matching lines...) Expand all
181 { 181 {
182 error = e.what(); 182 error = e.what();
183 } 183 }
184 catch (...) 184 catch (...)
185 { 185 {
186 error = "Unknown error while removing " + path; 186 error = "Unknown error while removing " + path;
187 } 187 }
188 188
189 const JsContext context(jsEngine); 189 const JsContext context(jsEngine);
190 JsValuePtr errorValue = jsEngine->NewValue(error); 190 JsValuePtr errorValue = jsEngine->NewValue(error);
191 JsValueList params; 191 JsConstValueList params;
192 params.push_back(errorValue); 192 params.push_back(errorValue);
193 callback->Call(params); 193 callback->Call(params);
194 } 194 }
195 195
196 private: 196 private:
197 std::string path; 197 std::string path;
198 }; 198 };
199 199
200 200
201 class StatThread : public IoThread 201 class StatThread : public IoThread
(...skipping 23 matching lines...) Expand all
225 } 225 }
226 226
227 const JsContext context(jsEngine); 227 const JsContext context(jsEngine);
228 JsValuePtr result = jsEngine->NewObject(); 228 JsValuePtr result = jsEngine->NewObject();
229 result->SetProperty("exists", statResult.exists); 229 result->SetProperty("exists", statResult.exists);
230 result->SetProperty("isFile", statResult.isFile); 230 result->SetProperty("isFile", statResult.isFile);
231 result->SetProperty("isDirectory", statResult.isDirectory); 231 result->SetProperty("isDirectory", statResult.isDirectory);
232 result->SetProperty("lastModified", statResult.lastModified); 232 result->SetProperty("lastModified", statResult.lastModified);
233 result->SetProperty("error", error); 233 result->SetProperty("error", error);
234 234
235 JsValueList params; 235 JsConstValueList params;
236 params.push_back(result); 236 params.push_back(result);
237 callback->Call(params); 237 callback->Call(params);
238 } 238 }
239 239
240 private: 240 private:
241 std::string path; 241 std::string path;
242 }; 242 };
243 243
244 v8::Handle<v8::Value> ReadCallback(const v8::Arguments& arguments) 244 v8::Handle<v8::Value> ReadCallback(const v8::Arguments& arguments)
245 { 245 {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 JsValuePtr FileSystemJsObject::Setup(JsEnginePtr jsEngine, JsValuePtr obj) 352 JsValuePtr FileSystemJsObject::Setup(JsEnginePtr jsEngine, JsValuePtr obj)
353 { 353 {
354 obj->SetProperty("read", jsEngine->NewCallback(::ReadCallback)); 354 obj->SetProperty("read", jsEngine->NewCallback(::ReadCallback));
355 obj->SetProperty("write", jsEngine->NewCallback(::WriteCallback)); 355 obj->SetProperty("write", jsEngine->NewCallback(::WriteCallback));
356 obj->SetProperty("move", jsEngine->NewCallback(::MoveCallback)); 356 obj->SetProperty("move", jsEngine->NewCallback(::MoveCallback));
357 obj->SetProperty("remove", jsEngine->NewCallback(::RemoveCallback)); 357 obj->SetProperty("remove", jsEngine->NewCallback(::RemoveCallback));
358 obj->SetProperty("stat", jsEngine->NewCallback(::StatCallback)); 358 obj->SetProperty("stat", jsEngine->NewCallback(::StatCallback));
359 obj->SetProperty("resolve", jsEngine->NewCallback(::ResolveCallback)); 359 obj->SetProperty("resolve", jsEngine->NewCallback(::ResolveCallback));
360 return obj; 360 return obj;
361 } 361 }
OLDNEW

Powered by Google App Engine
This is Rietveld