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

Side by Side Diff: Source/modules/indexeddb/IDBVersionChangeEvent.cpp

Issue 177633006: Implement IDBVersionChangeEvent ctor w/ IDBVersionChangeEventInit dict (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 months 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 | Annotate | Revision Log
OLDNEW
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
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 PassRefPtr<IDBVersionChangeEvent> IDBVersionChangeEvent::create(PassRefPtr<IDBAn y> oldVersion, PassRefPtr<IDBAny> newVersion, const AtomicString& eventType, bli nk::WebIDBDataLoss dataLoss, const String& dataLossMessage) 34
35 IDBVersionChangeEventInit::IDBVersionChangeEventInit()
36 : oldVersion(0)
37 , newVersion(0)
35 { 38 {
36 return adoptRef(new IDBVersionChangeEvent(oldVersion, newVersion, eventType, dataLoss, dataLossMessage));
37 } 39 }
38 40
39 IDBVersionChangeEvent::IDBVersionChangeEvent(PassRefPtr<IDBAny> oldVersion, Pass RefPtr<IDBAny> newVersion, const AtomicString& eventType, blink::WebIDBDataLoss dataLoss, const String& dataLossMessage) 41 IDBVersionChangeEvent::IDBVersionChangeEvent()
42 : m_dataLoss(blink::WebIDBDataLossNone)
43 {
44 ScriptWrappable::init(this);
45 }
46
47 IDBVersionChangeEvent::IDBVersionChangeEvent(const AtomicString& eventType, Pass RefPtr<SerializedScriptValue> oldVersion, PassRefPtr<SerializedScriptValue> newV ersion, blink::WebIDBDataLoss dataLoss, const String& dataLossMessage)
40 : Event(eventType, false /*canBubble*/, false /*cancelable*/) 48 : Event(eventType, false /*canBubble*/, false /*cancelable*/)
41 , m_oldVersion(oldVersion) 49 , m_oldVersion(oldVersion)
42 , m_newVersion(newVersion) 50 , m_newVersion(newVersion)
43 , m_dataLoss(dataLoss) 51 , m_dataLoss(dataLoss)
44 , m_dataLossMessage(dataLossMessage) 52 , m_dataLossMessage(dataLossMessage)
45 { 53 {
46 ScriptWrappable::init(this); 54 ScriptWrappable::init(this);
47 } 55 }
48 56
49 IDBVersionChangeEvent::~IDBVersionChangeEvent() 57 IDBVersionChangeEvent::IDBVersionChangeEvent(const AtomicString& eventType, cons t IDBVersionChangeEventInit& initializer)
58 : Event(eventType, false /*canBubble*/, false /*cancelable*/)
59 , m_oldVersion(SerializedScriptValue::numberValue(initializer.oldVersion))
60 , m_newVersion(SerializedScriptValue::numberValue(initializer.newVersion))
61 , m_dataLoss(blink::WebIDBDataLossNone)
50 { 62 {
51 } 63 ScriptWrappable::init(this);
52
53 ScriptValue IDBVersionChangeEvent::oldVersion(ExecutionContext* context) const
54 {
55 DOMRequestState requestState(context);
56 return idbAnyToScriptValue(&requestState, m_oldVersion);
57 }
58
59 ScriptValue IDBVersionChangeEvent::newVersion(ExecutionContext* context) const
60 {
61 DOMRequestState requestState(context);
62 return idbAnyToScriptValue(&requestState, m_newVersion);
63 } 64 }
64 65
65 const AtomicString& IDBVersionChangeEvent::dataLoss() const 66 const AtomicString& IDBVersionChangeEvent::dataLoss() const
66 { 67 {
67 DEFINE_STATIC_LOCAL(AtomicString, total, ("total", AtomicString::ConstructFr omLiteral)); 68 DEFINE_STATIC_LOCAL(AtomicString, total, ("total", AtomicString::ConstructFr omLiteral));
68 if (m_dataLoss == blink::WebIDBDataLossTotal) 69 if (m_dataLoss == blink::WebIDBDataLossTotal)
69 return total; 70 return total;
70 DEFINE_STATIC_LOCAL(AtomicString, none, ("none", AtomicString::ConstructFrom Literal)); 71 DEFINE_STATIC_LOCAL(AtomicString, none, ("none", AtomicString::ConstructFrom Literal));
71 return none; 72 return none;
72 } 73 }
73 74
74 const AtomicString& IDBVersionChangeEvent::interfaceName() const 75 const AtomicString& IDBVersionChangeEvent::interfaceName() const
75 { 76 {
76 return EventNames::IDBVersionChangeEvent; 77 return EventNames::IDBVersionChangeEvent;
77 } 78 }
78 79
79 } // namespace WebCore 80 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698