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

Side by Side Diff: src/JsEngine.cpp

Issue 5598762307158016: Issue 1550 - Get rid of V8ValueHolder.h (Closed)
Patch Set: rebase Created May 20, 2016, 3:20 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/JsContext.cpp ('k') | src/JsValue.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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 71 }
72 72
73 AdblockPlus::JsEnginePtr AdblockPlus::JsEngine::New(const AppInfo& appInfo) 73 AdblockPlus::JsEnginePtr AdblockPlus::JsEngine::New(const AppInfo& appInfo)
74 { 74 {
75 V8Initializer::Init(); 75 V8Initializer::Init();
76 JsEnginePtr result(new JsEngine()); 76 JsEnginePtr result(new JsEngine());
77 77
78 const v8::Locker locker(result->isolate); 78 const v8::Locker locker(result->isolate);
79 const v8::HandleScope handleScope; 79 const v8::HandleScope handleScope;
80 80
81 result->context.reset(result->isolate, v8::Context::New(result->isolate)); 81 result->context.reset(new v8::Persistent<v8::Context>(result->isolate,
82 82 v8::Context::New(result->isolate)));
83 v8::Local<v8::Object> globalContext = v8::Local<v8::Context>::New( 83 v8::Local<v8::Object> globalContext = v8::Local<v8::Context>::New(
84 result->isolate, result->context)->Global(); 84 result->isolate, *result->context)->Global();
85 result->globalJsObject = JsValuePtr(new JsValue(result, globalContext)); 85 result->globalJsObject = JsValuePtr(new JsValue(result, globalContext));
86
87 AdblockPlus::GlobalJsObject::Setup(result, appInfo, result->globalJsObject); 86 AdblockPlus::GlobalJsObject::Setup(result, appInfo, result->globalJsObject);
88 return result; 87 return result;
89 } 88 }
90 89
91 AdblockPlus::JsValuePtr AdblockPlus::JsEngine::Evaluate(const std::string& sourc e, 90 AdblockPlus::JsValuePtr AdblockPlus::JsEngine::Evaluate(const std::string& sourc e,
92 const std::string& filename) 91 const std::string& filename)
93 { 92 {
94 const JsContext context(shared_from_this()); 93 const JsContext context(shared_from_this());
95 const v8::TryCatch tryCatch; 94 const v8::TryCatch tryCatch;
96 const v8::Handle<v8::Script> script = CompileScript(isolate, source, 95 const v8::Handle<v8::Script> script = CompileScript(isolate, source,
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 231
233 232
234 void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name, 233 void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name,
235 AdblockPlus::JsValuePtr value) 234 AdblockPlus::JsValuePtr value)
236 { 235 {
237 if (!globalJsObject) 236 if (!globalJsObject)
238 throw std::runtime_error("Global object cannot be null"); 237 throw std::runtime_error("Global object cannot be null");
239 238
240 globalJsObject->SetProperty(name, value); 239 globalJsObject->SetProperty(name, value);
241 } 240 }
OLDNEW
« no previous file with comments | « src/JsContext.cpp ('k') | src/JsValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld