| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "modules/indexeddb/IDBVersionChangeEvent.h" | 27 #include "modules/indexeddb/IDBVersionChangeEvent.h" |
| 28 | 28 |
| 29 #include "bindings/v8/IDBBindingUtilities.h" | 29 #include "bindings/v8/IDBBindingUtilities.h" |
| 30 #include "core/events/ThreadLocalEventNames.h" | 30 #include "core/events/ThreadLocalEventNames.h" |
| 31 | 31 |
| 32 namespace WebCore { | 32 namespace WebCore { |
| 33 | 33 |
| 34 PassRefPtrWillBeRawPtr<IDBVersionChangeEvent> IDBVersionChangeEvent::create(Pass
RefPtr<IDBAny> oldVersion, PassRefPtr<IDBAny> newVersion, const AtomicString& ev
entType, blink::WebIDBDataLoss dataLoss, const String& dataLossMessage) | 34 |
| 35 IDBVersionChangeEventInit::IDBVersionChangeEventInit() |
| 36 : oldVersion(0) |
| 35 { | 37 { |
| 36 return adoptRefWillBeRefCountedGarbageCollected(new IDBVersionChangeEvent(ol
dVersion, newVersion, eventType, dataLoss, dataLossMessage)); | |
| 37 } | 38 } |
| 38 | 39 |
| 39 IDBVersionChangeEvent::IDBVersionChangeEvent(PassRefPtr<IDBAny> oldVersion, Pass
RefPtr<IDBAny> newVersion, const AtomicString& eventType, blink::WebIDBDataLoss
dataLoss, const String& dataLossMessage) | 40 IDBVersionChangeEvent::IDBVersionChangeEvent() |
| 41 : m_dataLoss(blink::WebIDBDataLossNone) |
| 42 { |
| 43 ScriptWrappable::init(this); |
| 44 } |
| 45 |
| 46 IDBVersionChangeEvent::IDBVersionChangeEvent(const AtomicString& eventType, unsi
gned long long oldVersion, const Nullable<unsigned long long>& newVersion, blink
::WebIDBDataLoss dataLoss, const String& dataLossMessage) |
| 40 : Event(eventType, false /*canBubble*/, false /*cancelable*/) | 47 : Event(eventType, false /*canBubble*/, false /*cancelable*/) |
| 41 , m_oldVersion(oldVersion) | 48 , m_oldVersion(oldVersion) |
| 42 , m_newVersion(newVersion) | 49 , m_newVersion(newVersion) |
| 43 , m_dataLoss(dataLoss) | 50 , m_dataLoss(dataLoss) |
| 44 , m_dataLossMessage(dataLossMessage) | 51 , m_dataLossMessage(dataLossMessage) |
| 45 { | 52 { |
| 46 ScriptWrappable::init(this); | 53 ScriptWrappable::init(this); |
| 47 } | 54 } |
| 48 | 55 |
| 49 IDBVersionChangeEvent::~IDBVersionChangeEvent() | 56 IDBVersionChangeEvent::IDBVersionChangeEvent(const AtomicString& eventType, cons
t IDBVersionChangeEventInit& initializer) |
| 57 : Event(eventType, false /*canBubble*/, false /*cancelable*/) |
| 58 , m_oldVersion(initializer.oldVersion) |
| 59 , m_newVersion(initializer.newVersion) |
| 60 , m_dataLoss(blink::WebIDBDataLossNone) |
| 50 { | 61 { |
| 62 ScriptWrappable::init(this); |
| 51 } | 63 } |
| 52 | 64 |
| 53 ScriptValue IDBVersionChangeEvent::oldVersion(ExecutionContext* context) const | 65 unsigned long long IDBVersionChangeEvent::newVersion(bool& isNull) const |
| 54 { | 66 { |
| 55 DOMRequestState requestState(context); | 67 isNull = m_newVersion.isNull(); |
| 56 return idbAnyToScriptValue(&requestState, m_oldVersion); | 68 return isNull ? 0 : m_newVersion.get(); |
| 57 } | |
| 58 | |
| 59 ScriptValue IDBVersionChangeEvent::newVersion(ExecutionContext* context) const | |
| 60 { | |
| 61 DOMRequestState requestState(context); | |
| 62 return idbAnyToScriptValue(&requestState, m_newVersion); | |
| 63 } | 69 } |
| 64 | 70 |
| 65 const AtomicString& IDBVersionChangeEvent::dataLoss() const | 71 const AtomicString& IDBVersionChangeEvent::dataLoss() const |
| 66 { | 72 { |
| 67 DEFINE_STATIC_LOCAL(AtomicString, total, ("total", AtomicString::ConstructFr
omLiteral)); | 73 DEFINE_STATIC_LOCAL(AtomicString, total, ("total", AtomicString::ConstructFr
omLiteral)); |
| 68 if (m_dataLoss == blink::WebIDBDataLossTotal) | 74 if (m_dataLoss == blink::WebIDBDataLossTotal) |
| 69 return total; | 75 return total; |
| 70 DEFINE_STATIC_LOCAL(AtomicString, none, ("none", AtomicString::ConstructFrom
Literal)); | 76 DEFINE_STATIC_LOCAL(AtomicString, none, ("none", AtomicString::ConstructFrom
Literal)); |
| 71 return none; | 77 return none; |
| 72 } | 78 } |
| 73 | 79 |
| 74 const AtomicString& IDBVersionChangeEvent::interfaceName() const | 80 const AtomicString& IDBVersionChangeEvent::interfaceName() const |
| 75 { | 81 { |
| 76 return EventNames::IDBVersionChangeEvent; | 82 return EventNames::IDBVersionChangeEvent; |
| 77 } | 83 } |
| 78 | 84 |
| 79 void IDBVersionChangeEvent::trace(Visitor* visitor) | 85 void IDBVersionChangeEvent::trace(Visitor* visitor) |
| 80 { | 86 { |
| 81 Event::trace(visitor); | 87 Event::trace(visitor); |
| 82 } | 88 } |
| 83 | 89 |
| 84 } // namespace WebCore | 90 } // namespace WebCore |
| OLD | NEW |