Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: fpdfsdk/src/javascript/JS_Runtime.cpp

Issue 1407063012: Merge to XFA: Keep "static" objects per-context rather than per isolate. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/src/javascript/JS_Runtime.h ('k') | fpdfsdk/src/jsapi/fxjs_v8.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 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "JS_Runtime.h" 7 #include "JS_Runtime.h"
8 8
9 #include "../../../xfa/src/fxjse/src/value.h" 9 #include "../../../xfa/src/fxjse/src/value.h"
10 #include "../../include/fpdfxfa/fpdfxfa_app.h" 10 #include "../../include/fpdfxfa/fpdfxfa_app.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 } 70 }
71 m_isolateManaged = FXJS_GetIsolate(&m_isolate); 71 m_isolateManaged = FXJS_GetIsolate(&m_isolate);
72 } 72 }
73 73
74 v8::Isolate* isolate = m_isolate; 74 v8::Isolate* isolate = m_isolate;
75 v8::Isolate::Scope isolate_scope(isolate); 75 v8::Isolate::Scope isolate_scope(isolate);
76 v8::Locker locker(isolate); 76 v8::Locker locker(isolate);
77 v8::HandleScope handle_scope(isolate); 77 v8::HandleScope handle_scope(isolate);
78 if (CPDFXFA_App::GetInstance()->IsJavaScriptInitialized()) { 78 if (CPDFXFA_App::GetInstance()->IsJavaScriptInitialized()) {
79 CJS_Context* pContext = (CJS_Context*)NewContext(); 79 CJS_Context* pContext = (CJS_Context*)NewContext();
80 FXJS_InitializeRuntime(GetIsolate(), this, m_context); 80 FXJS_InitializeRuntime(GetIsolate(), this, &m_context, &m_StaticObjects);
81 ReleaseContext(pContext); 81 ReleaseContext(pContext);
82 return; 82 return;
83 } 83 }
84 84
85 if (m_isolateManaged || FXJS_GlobalIsolateRefCount() == 0) 85 if (m_isolateManaged || FXJS_GlobalIsolateRefCount() == 0)
86 DefineJSObjects(); 86 DefineJSObjects();
87 87
88 CPDFXFA_App::GetInstance()->SetJavaScriptInitialized(TRUE); 88 CPDFXFA_App::GetInstance()->SetJavaScriptInitialized(TRUE);
89 89
90 CJS_Context* pContext = (CJS_Context*)NewContext(); 90 CJS_Context* pContext = (CJS_Context*)NewContext();
91 FXJS_InitializeRuntime(GetIsolate(), this, m_context); 91 FXJS_InitializeRuntime(GetIsolate(), this, &m_context, &m_StaticObjects);
92 ReleaseContext(pContext); 92 ReleaseContext(pContext);
93 } 93 }
94 94
95 CJS_Runtime::~CJS_Runtime() { 95 CJS_Runtime::~CJS_Runtime() {
96 for (auto* obs : m_observers) 96 for (auto* obs : m_observers)
97 obs->OnDestroyed(); 97 obs->OnDestroyed();
98 98
99 int size = m_ContextArray.GetSize(); 99 int size = m_ContextArray.GetSize();
100 for (int i = 0; i < size; i++) 100 for (int i = 0; i < size; i++)
101 delete m_ContextArray.GetAt(i); 101 delete m_ContextArray.GetAt(i);
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 300
301 void CJS_Runtime::AddObserver(Observer* observer) { 301 void CJS_Runtime::AddObserver(Observer* observer) {
302 ASSERT(m_observers.find(observer) == m_observers.end()); 302 ASSERT(m_observers.find(observer) == m_observers.end());
303 m_observers.insert(observer); 303 m_observers.insert(observer);
304 } 304 }
305 305
306 void CJS_Runtime::RemoveObserver(Observer* observer) { 306 void CJS_Runtime::RemoveObserver(Observer* observer) {
307 ASSERT(m_observers.find(observer) != m_observers.end()); 307 ASSERT(m_observers.find(observer) != m_observers.end());
308 m_observers.erase(observer); 308 m_observers.erase(observer);
309 } 309 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/javascript/JS_Runtime.h ('k') | fpdfsdk/src/jsapi/fxjs_v8.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698