| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009, 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009, 2011 Google Inc. 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 return; | 54 return; |
| 55 | 55 |
| 56 if (behavior == DetachGlobal && !m_globalProxy.isEmpty()) { | 56 if (behavior == DetachGlobal && !m_globalProxy.isEmpty()) { |
| 57 m_globalProxy.get().SetWrapperClassId(0); | 57 m_globalProxy.get().SetWrapperClassId(0); |
| 58 V8DOMWrapper::clearNativeInfo(isolate(), m_globalProxy.newLocal(isolate())); | 58 V8DOMWrapper::clearNativeInfo(isolate(), m_globalProxy.newLocal(isolate())); |
| 59 #if DCHECK_IS_ON() | 59 #if DCHECK_IS_ON() |
| 60 didDetachGlobalObject(); | 60 didDetachGlobalObject(); |
| 61 #endif | 61 #endif |
| 62 } | 62 } |
| 63 | 63 |
| 64 DCHECK(m_lifecycle == Lifecycle::ContextInitialized); | 64 DCHECK_EQ(m_lifecycle, Lifecycle::ContextInitialized); |
| 65 m_lifecycle = Lifecycle::ContextDetached; | 65 m_lifecycle = behavior == DetachGlobal ? Lifecycle::GlobalObjectDetached |
| 66 : Lifecycle::ContextDetachedFromFrame; |
| 66 } | 67 } |
| 67 | 68 |
| 68 void RemoteWindowProxy::initialize() { | 69 void RemoteWindowProxy::initialize() { |
| 69 TRACE_EVENT1("v8", "RemoteWindowProxy::initialize", "isMainWindow", | 70 TRACE_EVENT1("v8", "RemoteWindowProxy::initialize", "isMainWindow", |
| 70 frame()->isMainFrame()); | 71 frame()->isMainFrame()); |
| 71 SCOPED_BLINK_UMA_HISTOGRAM_TIMER( | 72 SCOPED_BLINK_UMA_HISTOGRAM_TIMER( |
| 72 frame()->isMainFrame() | 73 frame()->isMainFrame() |
| 73 ? "Blink.Binding.InitializeMainRemoteWindowProxy" | 74 ? "Blink.Binding.InitializeMainRemoteWindowProxy" |
| 74 : "Blink.Binding.InitializeNonMainRemoteWindowProxy"); | 75 : "Blink.Binding.InitializeNonMainRemoteWindowProxy"); |
| 75 | 76 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 94 if (m_globalProxy.isEmpty()) | 95 if (m_globalProxy.isEmpty()) |
| 95 m_globalProxy.set(isolate(), globalProxy); | 96 m_globalProxy.set(isolate(), globalProxy); |
| 96 else | 97 else |
| 97 DCHECK(m_globalProxy.get() == globalProxy); | 98 DCHECK(m_globalProxy.get() == globalProxy); |
| 98 CHECK(!m_globalProxy.isEmpty()); | 99 CHECK(!m_globalProxy.isEmpty()); |
| 99 | 100 |
| 100 #if DCHECK_IS_ON() | 101 #if DCHECK_IS_ON() |
| 101 didAttachGlobalObject(); | 102 didAttachGlobalObject(); |
| 102 #endif | 103 #endif |
| 103 | 104 |
| 104 // TODO(haraken): Currently we cannot enable the following DCHECK because | 105 DCHECK(m_lifecycle == Lifecycle::ContextUninitialized || |
| 105 // an already detached window proxy can be re-initialized. This is wrong. | 106 m_lifecycle == Lifecycle::GlobalObjectDetached); |
| 106 // DCHECK(m_lifecycle == Lifecycle::ContextUninitialized); | |
| 107 m_lifecycle = Lifecycle::ContextInitialized; | 107 m_lifecycle = Lifecycle::ContextInitialized; |
| 108 } | 108 } |
| 109 | 109 |
| 110 void RemoteWindowProxy::setupWindowPrototypeChain() { | 110 void RemoteWindowProxy::setupWindowPrototypeChain() { |
| 111 // Associate the window wrapper object and its prototype chain with the | 111 // Associate the window wrapper object and its prototype chain with the |
| 112 // corresponding native DOMWindow object. | 112 // corresponding native DOMWindow object. |
| 113 DOMWindow* window = frame()->domWindow(); | 113 DOMWindow* window = frame()->domWindow(); |
| 114 const WrapperTypeInfo* wrapperTypeInfo = window->wrapperTypeInfo(); | 114 const WrapperTypeInfo* wrapperTypeInfo = window->wrapperTypeInfo(); |
| 115 | 115 |
| 116 // The global proxy object. Note this is not the global object. | 116 // The global proxy object. Note this is not the global object. |
| 117 v8::Local<v8::Object> globalProxy = m_globalProxy.newLocal(isolate()); | 117 v8::Local<v8::Object> globalProxy = m_globalProxy.newLocal(isolate()); |
| 118 CHECK(m_globalProxy == globalProxy); | 118 CHECK(m_globalProxy == globalProxy); |
| 119 V8DOMWrapper::setNativeInfo(isolate(), globalProxy, wrapperTypeInfo, window); | 119 V8DOMWrapper::setNativeInfo(isolate(), globalProxy, wrapperTypeInfo, window); |
| 120 // Mark the handle to be traced by Oilpan, since the global proxy has a | 120 // Mark the handle to be traced by Oilpan, since the global proxy has a |
| 121 // reference to the DOMWindow. | 121 // reference to the DOMWindow. |
| 122 m_globalProxy.get().SetWrapperClassId(wrapperTypeInfo->wrapperClassId); | 122 m_globalProxy.get().SetWrapperClassId(wrapperTypeInfo->wrapperClassId); |
| 123 | 123 |
| 124 // The global object, aka window wrapper object. | 124 // The global object, aka window wrapper object. |
| 125 v8::Local<v8::Object> windowWrapper = | 125 v8::Local<v8::Object> windowWrapper = |
| 126 globalProxy->GetPrototype().As<v8::Object>(); | 126 globalProxy->GetPrototype().As<v8::Object>(); |
| 127 v8::Local<v8::Object> associatedWrapper = | 127 v8::Local<v8::Object> associatedWrapper = |
| 128 associateWithWrapper(window, wrapperTypeInfo, windowWrapper); | 128 associateWithWrapper(window, wrapperTypeInfo, windowWrapper); |
| 129 DCHECK(associatedWrapper == windowWrapper); | 129 DCHECK(associatedWrapper == windowWrapper); |
| 130 } | 130 } |
| 131 | 131 |
| 132 } // namespace blink | 132 } // namespace blink |
| OLD | NEW |