OLD | NEW |
---|---|
1 // Copyright (c) 2008, Google Inc. | 1 // Copyright (c) 2008, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 1808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1819 V8DOMWindow::GetShadowObjectTemplate(); | 1819 V8DOMWindow::GetShadowObjectTemplate(); |
1820 if (global_template.IsEmpty()) | 1820 if (global_template.IsEmpty()) |
1821 return; | 1821 return; |
1822 | 1822 |
1823 // Install a security handler with V8. | 1823 // Install a security handler with V8. |
1824 global_template->SetAccessCheckCallbacks( | 1824 global_template->SetAccessCheckCallbacks( |
1825 V8Custom::v8DOMWindowNamedSecurityCheck, | 1825 V8Custom::v8DOMWindowNamedSecurityCheck, |
1826 V8Custom::v8DOMWindowIndexedSecurityCheck, | 1826 V8Custom::v8DOMWindowIndexedSecurityCheck, |
1827 v8::Integer::New(V8ClassIndex::DOMWINDOW)); | 1827 v8::Integer::New(V8ClassIndex::DOMWINDOW)); |
1828 | 1828 |
1829 // Create a new context. | 1829 if (ScriptController::shouldExposeGCController()) { |
1830 m_context = v8::Context::New(NULL, global_template, m_global); | 1830 v8::RegisterExtension(new v8::Extension("v8/GCController", |
1831 "(function v8_GCController() {" | |
1832 " var v8_gc;" | |
1833 " if (gc) v8_gc = gc;" | |
1834 " GCController = new Object();" | |
1835 " GCController.collect =" | |
1836 " function() {if (v8_gc) v8_gc(); };" | |
Mike Belshe
2008/11/14 01:11:54
Cool - in JS!
Could this be just:
if (gc)
gc(
| |
1837 " })()")); | |
1838 const char* extension_names[] = { "v8/GCController" }; | |
1839 v8::ExtensionConfiguration extensions(1, extension_names); | |
1840 // Create a new context. | |
1841 m_context = v8::Context::New(&extensions, global_template, m_global); | |
1842 } else { | |
1843 m_context = v8::Context::New(NULL, global_template, m_global); | |
1844 } | |
1845 | |
1831 if (m_context.IsEmpty()) | 1846 if (m_context.IsEmpty()) |
1832 return; | 1847 return; |
1833 | 1848 |
1834 // Starting from now, use local context only. | 1849 // Starting from now, use local context only. |
1835 v8::Local<v8::Context> context = GetContext(); | 1850 v8::Local<v8::Context> context = GetContext(); |
1836 v8::Context::Scope scope(context); | 1851 v8::Context::Scope scope(context); |
1837 | 1852 |
1838 // Store the first global object created so we can reuse it. | 1853 // Store the first global object created so we can reuse it. |
1839 if (m_global.IsEmpty()) { | 1854 if (m_global.IsEmpty()) { |
1840 m_global = v8::Persistent<v8::Object>::New(context->Global()); | 1855 m_global = v8::Persistent<v8::Object>::New(context->Global()); |
(...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2862 v8::Handle<v8::Object> global = context->Global(); | 2877 v8::Handle<v8::Object> global = context->Global(); |
2863 global->Set(v8::String::New(name), instance); | 2878 global->Set(v8::String::New(name), instance); |
2864 } | 2879 } |
2865 | 2880 |
2866 void V8Proxy::ProcessConsoleMessages() | 2881 void V8Proxy::ProcessConsoleMessages() |
2867 { | 2882 { |
2868 ConsoleMessageManager::ProcessDelayedMessages(); | 2883 ConsoleMessageManager::ProcessDelayedMessages(); |
2869 } | 2884 } |
2870 | 2885 |
2871 } // namespace WebCore | 2886 } // namespace WebCore |
OLD | NEW |