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

Side by Side Diff: src/ConsoleJsObject.cpp

Issue 10310030: Convert references to FileSystem & Co. into shared pointers (avoid use after free) (Closed)
Patch Set: Created April 18, 2013, 11:59 a.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 #include <AdblockPlus/JsEngine.h> 1 #include <AdblockPlus/JsEngine.h>
2 #include <AdblockPlus/JsValue.h> 2 #include <AdblockPlus/JsValue.h>
3 #include <AdblockPlus/ErrorCallback.h> 3 #include <AdblockPlus/ErrorCallback.h>
4 #include <sstream> 4 #include <sstream>
5 5
6 #include "ConsoleJsObject.h" 6 #include "ConsoleJsObject.h"
7 7
8 namespace 8 namespace
9 { 9 {
10 v8::Handle<v8::Value> ErrorCallback(const v8::Arguments& arguments) 10 v8::Handle<v8::Value> ErrorCallback(const v8::Arguments& arguments)
11 { 11 {
12 AdblockPlus::JsEngine& jsEngine = AdblockPlus::JsEngine::FromArguments(argum ents); 12 AdblockPlus::JsEngine& jsEngine = AdblockPlus::JsEngine::FromArguments(argum ents);
13 const AdblockPlus::JsEngine::Context context(jsEngine); 13 const AdblockPlus::JsEngine::Context context(jsEngine);
14 AdblockPlus::JsValueList converted = jsEngine.ConvertArguments(arguments); 14 AdblockPlus::JsValueList converted = jsEngine.ConvertArguments(arguments);
15 15
16 std::stringstream message; 16 std::stringstream message;
17 for (size_t i = 0; i < converted.size(); i++) 17 for (size_t i = 0; i < converted.size(); i++)
18 message << converted[i]->AsString(); 18 message << converted[i]->AsString();
19 19
20 (jsEngine.GetErrorCallback())(message.str()); 20 AdblockPlus::ErrorCallbackPtr callback = jsEngine.GetErrorCallback();
21 (*callback)(message.str());
21 return v8::Undefined(); 22 return v8::Undefined();
22 } 23 }
23 24
24 v8::Handle<v8::Value> TraceCallback(const v8::Arguments& arguments) 25 v8::Handle<v8::Value> TraceCallback(const v8::Arguments& arguments)
25 { 26 {
26 return v8::Undefined(); 27 return v8::Undefined();
27 } 28 }
28 } 29 }
29 30
30 AdblockPlus::JsValuePtr AdblockPlus::ConsoleJsObject::Setup( 31 AdblockPlus::JsValuePtr AdblockPlus::ConsoleJsObject::Setup(
31 AdblockPlus::JsEngine& jsEngine, AdblockPlus::JsValuePtr obj) 32 AdblockPlus::JsEngine& jsEngine, AdblockPlus::JsValuePtr obj)
32 { 33 {
33 obj->SetProperty("error", jsEngine.NewCallback(::ErrorCallback)); 34 obj->SetProperty("error", jsEngine.NewCallback(::ErrorCallback));
34 obj->SetProperty("trace", jsEngine.NewCallback(::TraceCallback)); 35 obj->SetProperty("trace", jsEngine.NewCallback(::TraceCallback));
35 return obj; 36 return obj;
36 } 37 }
OLDNEW
« no previous file with comments | « shell/src/Main.cpp ('k') | src/DefaultErrorCallback.cpp » ('j') | src/JsEngine.cpp » ('J')

Powered by Google App Engine
This is Rietveld