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

Side by Side Diff: src/FileSystemJsObject.cpp

Issue 10727002: Get rid of dependencies on v8.h in public header files (Closed)
Patch Set: Created May 23, 2013, 2:43 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/ConsoleJsObject.cpp ('k') | src/JsContext.h » ('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 <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #include <AdblockPlus/FileSystem.h> 18 #include <AdblockPlus/FileSystem.h>
19 #include <stdexcept> 19 #include <stdexcept>
20 #include <sstream> 20 #include <sstream>
21 #include <vector> 21 #include <vector>
22 22
23 #include <AdblockPlus/JsValue.h> 23 #include <AdblockPlus/JsValue.h>
24 #include "FileSystemJsObject.h" 24 #include "FileSystemJsObject.h"
25 #include "Utils.h" 25 #include "JsContext.h"
26 #include "Thread.h" 26 #include "Thread.h"
27 #include "Utils.h" 27 #include "Utils.h"
28 28
29 using namespace AdblockPlus; 29 using namespace AdblockPlus;
30 30
31 namespace 31 namespace
32 { 32 {
33 class IoThread : public Thread 33 class IoThread : public Thread
34 { 34 {
35 public: 35 public:
(...skipping 29 matching lines...) Expand all
65 } 65 }
66 catch (std::exception& e) 66 catch (std::exception& e)
67 { 67 {
68 error = e.what(); 68 error = e.what();
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 JsEngine::Context 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 JsValueList params;
80 params.push_back(result); 80 params.push_back(result);
81 callback->Call(params); 81 callback->Call(params);
82 delete this; 82 delete this;
83 } 83 }
84 84
85 private: 85 private:
(...skipping 20 matching lines...) Expand all
106 } 106 }
107 catch (std::exception& e) 107 catch (std::exception& e)
108 { 108 {
109 error = e.what(); 109 error = e.what();
110 } 110 }
111 catch (...) 111 catch (...)
112 { 112 {
113 error = "Unknown error while writing to " + path; 113 error = "Unknown error while writing to " + path;
114 } 114 }
115 115
116 const JsEngine::Context context(jsEngine); 116 const JsContext context(jsEngine);
117 JsValuePtr errorValue = jsEngine->NewValue(error); 117 JsValuePtr errorValue = jsEngine->NewValue(error);
118 JsValueList params; 118 JsValueList params;
119 params.push_back(errorValue); 119 params.push_back(errorValue);
120 callback->Call(params); 120 callback->Call(params);
121 delete this; 121 delete this;
122 } 122 }
123 123
124 private: 124 private:
125 std::string path; 125 std::string path;
126 std::string content; 126 std::string content;
(...skipping 17 matching lines...) Expand all
144 } 144 }
145 catch (std::exception& e) 145 catch (std::exception& e)
146 { 146 {
147 error = e.what(); 147 error = e.what();
148 } 148 }
149 catch (...) 149 catch (...)
150 { 150 {
151 error = "Unknown error while moving " + fromPath + " to " + toPath; 151 error = "Unknown error while moving " + fromPath + " to " + toPath;
152 } 152 }
153 153
154 const JsEngine::Context context(jsEngine); 154 const JsContext context(jsEngine);
155 JsValuePtr errorValue = jsEngine->NewValue(error); 155 JsValuePtr errorValue = jsEngine->NewValue(error);
156 JsValueList params; 156 JsValueList params;
157 params.push_back(errorValue); 157 params.push_back(errorValue);
158 callback->Call(params); 158 callback->Call(params);
159 delete this; 159 delete this;
160 } 160 }
161 161
162 private: 162 private:
163 std::string fromPath; 163 std::string fromPath;
164 std::string toPath; 164 std::string toPath;
(...skipping 17 matching lines...) Expand all
182 } 182 }
183 catch (std::exception& e) 183 catch (std::exception& e)
184 { 184 {
185 error = e.what(); 185 error = e.what();
186 } 186 }
187 catch (...) 187 catch (...)
188 { 188 {
189 error = "Unknown error while removing " + path; 189 error = "Unknown error while removing " + path;
190 } 190 }
191 191
192 const JsEngine::Context context(jsEngine); 192 const JsContext context(jsEngine);
193 JsValuePtr errorValue = jsEngine->NewValue(error); 193 JsValuePtr errorValue = jsEngine->NewValue(error);
194 JsValueList params; 194 JsValueList params;
195 params.push_back(errorValue); 195 params.push_back(errorValue);
196 callback->Call(params); 196 callback->Call(params);
197 delete this; 197 delete this;
198 } 198 }
199 199
200 private: 200 private:
201 std::string path; 201 std::string path;
202 }; 202 };
(...skipping 18 matching lines...) Expand all
221 } 221 }
222 catch (std::exception& e) 222 catch (std::exception& e)
223 { 223 {
224 error = e.what(); 224 error = e.what();
225 } 225 }
226 catch (...) 226 catch (...)
227 { 227 {
228 error = "Unknown error while calling stat on " + path; 228 error = "Unknown error while calling stat on " + path;
229 } 229 }
230 230
231 const JsEngine::Context context(jsEngine); 231 const JsContext context(jsEngine);
232 JsValuePtr result = jsEngine->NewObject(); 232 JsValuePtr result = jsEngine->NewObject();
233 result->SetProperty("exists", statResult.exists); 233 result->SetProperty("exists", statResult.exists);
234 result->SetProperty("isFile", statResult.isFile); 234 result->SetProperty("isFile", statResult.isFile);
235 result->SetProperty("isDirectory", statResult.isDirectory); 235 result->SetProperty("isDirectory", statResult.isDirectory);
236 result->SetProperty("lastModified", statResult.lastModified); 236 result->SetProperty("lastModified", statResult.lastModified);
237 result->SetProperty("error", error); 237 result->SetProperty("error", error);
238 238
239 JsValueList params; 239 JsValueList params;
240 params.push_back(result); 240 params.push_back(result);
241 callback->Call(params); 241 callback->Call(params);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 JsValuePtr FileSystemJsObject::Setup(JsEnginePtr jsEngine, JsValuePtr obj) 351 JsValuePtr FileSystemJsObject::Setup(JsEnginePtr jsEngine, JsValuePtr obj)
352 { 352 {
353 obj->SetProperty("read", jsEngine->NewCallback(::ReadCallback)); 353 obj->SetProperty("read", jsEngine->NewCallback(::ReadCallback));
354 obj->SetProperty("write", jsEngine->NewCallback(::WriteCallback)); 354 obj->SetProperty("write", jsEngine->NewCallback(::WriteCallback));
355 obj->SetProperty("move", jsEngine->NewCallback(::MoveCallback)); 355 obj->SetProperty("move", jsEngine->NewCallback(::MoveCallback));
356 obj->SetProperty("remove", jsEngine->NewCallback(::RemoveCallback)); 356 obj->SetProperty("remove", jsEngine->NewCallback(::RemoveCallback));
357 obj->SetProperty("stat", jsEngine->NewCallback(::StatCallback)); 357 obj->SetProperty("stat", jsEngine->NewCallback(::StatCallback));
358 obj->SetProperty("resolve", jsEngine->NewCallback(::ResolveCallback)); 358 obj->SetProperty("resolve", jsEngine->NewCallback(::ResolveCallback));
359 return obj; 359 return obj;
360 } 360 }
OLDNEW
« no previous file with comments | « src/ConsoleJsObject.cpp ('k') | src/JsContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld