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

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

Issue 177633006: Implement IDBVersionChangeEvent ctor w/ IDBVersionChangeEventInit dict (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 6 years, 9 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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
11 * notice, this list of conditions and the following disclaimer in the 11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution. 12 * documentation and/or other materials provided with the distribution.
13 * 13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "modules/indexeddb/IDBOpenDBRequest.h" 27 #include "modules/indexeddb/IDBOpenDBRequest.h"
28 28
29 #include "bindings/v8/Nullable.h"
29 #include "core/dom/ExceptionCode.h" 30 #include "core/dom/ExceptionCode.h"
30 #include "core/dom/ExecutionContext.h" 31 #include "core/dom/ExecutionContext.h"
31 #include "modules/indexeddb/IDBDatabase.h" 32 #include "modules/indexeddb/IDBDatabase.h"
32 #include "modules/indexeddb/IDBDatabaseCallbacks.h" 33 #include "modules/indexeddb/IDBDatabaseCallbacks.h"
33 #include "modules/indexeddb/IDBPendingTransactionMonitor.h" 34 #include "modules/indexeddb/IDBPendingTransactionMonitor.h"
34 #include "modules/indexeddb/IDBTracing.h" 35 #include "modules/indexeddb/IDBTracing.h"
35 #include "modules/indexeddb/IDBVersionChangeEvent.h" 36 #include "modules/indexeddb/IDBVersionChangeEvent.h"
36 37
37 using blink::WebIDBDatabase; 38 using blink::WebIDBDatabase;
38 39
(...skipping 23 matching lines...) Expand all
62 const AtomicString& IDBOpenDBRequest::interfaceName() const 63 const AtomicString& IDBOpenDBRequest::interfaceName() const
63 { 64 {
64 return EventTargetNames::IDBOpenDBRequest; 65 return EventTargetNames::IDBOpenDBRequest;
65 } 66 }
66 67
67 void IDBOpenDBRequest::onBlocked(int64_t oldVersion) 68 void IDBOpenDBRequest::onBlocked(int64_t oldVersion)
68 { 69 {
69 IDB_TRACE("IDBOpenDBRequest::onBlocked()"); 70 IDB_TRACE("IDBOpenDBRequest::onBlocked()");
70 if (!shouldEnqueueEvent()) 71 if (!shouldEnqueueEvent())
71 return; 72 return;
72 RefPtr<IDBAny> newVersionAny = (m_version == IDBDatabaseMetadata::DefaultInt Version) ? IDBAny::createNull() : IDBAny::create(m_version); 73 Nullable<unsigned long long> newVersionNullable = (m_version == IDBDatabaseM etadata::DefaultIntVersion) ? Nullable<unsigned long long>() : Nullable<unsigned long long>(m_version);
73 enqueueEvent(IDBVersionChangeEvent::create(IDBAny::create(oldVersion), newVe rsionAny.release(), EventTypeNames::blocked)); 74 enqueueEvent(IDBVersionChangeEvent::create(EventTypeNames::blocked, oldVersi on, newVersionNullable));
74 } 75 }
75 76
76 void IDBOpenDBRequest::onUpgradeNeeded(int64_t oldVersion, PassOwnPtr<WebIDBData base> backend, const IDBDatabaseMetadata& metadata, blink::WebIDBDataLoss dataLo ss, String dataLossMessage) 77 void IDBOpenDBRequest::onUpgradeNeeded(int64_t oldVersion, PassOwnPtr<WebIDBData base> backend, const IDBDatabaseMetadata& metadata, blink::WebIDBDataLoss dataLo ss, String dataLossMessage)
77 { 78 {
78 IDB_TRACE("IDBOpenDBRequest::onUpgradeNeeded()"); 79 IDB_TRACE("IDBOpenDBRequest::onUpgradeNeeded()");
79 if (m_contextStopped || !executionContext()) { 80 if (m_contextStopped || !executionContext()) {
80 OwnPtr<WebIDBDatabase> db = backend; 81 OwnPtr<WebIDBDatabase> db = backend;
81 db->abort(m_transactionId); 82 db->abort(m_transactionId);
82 db->close(); 83 db->close();
83 return; 84 return;
(...skipping 11 matching lines...) Expand all
95 oldVersion = IDBDatabaseMetadata::DefaultIntVersion; 96 oldVersion = IDBDatabaseMetadata::DefaultIntVersion;
96 } 97 }
97 IDBDatabaseMetadata oldMetadata(metadata); 98 IDBDatabaseMetadata oldMetadata(metadata);
98 oldMetadata.intVersion = oldVersion; 99 oldMetadata.intVersion = oldVersion;
99 100
100 m_transaction = IDBTransaction::create(executionContext(), m_transactionId, idbDatabase.get(), this, oldMetadata); 101 m_transaction = IDBTransaction::create(executionContext(), m_transactionId, idbDatabase.get(), this, oldMetadata);
101 setResult(IDBAny::create(idbDatabase.release())); 102 setResult(IDBAny::create(idbDatabase.release()));
102 103
103 if (m_version == IDBDatabaseMetadata::NoIntVersion) 104 if (m_version == IDBDatabaseMetadata::NoIntVersion)
104 m_version = 1; 105 m_version = 1;
105 enqueueEvent(IDBVersionChangeEvent::create(IDBAny::create(oldVersion), IDBAn y::create(m_version), EventTypeNames::upgradeneeded, dataLoss, dataLossMessage)) ; 106 enqueueEvent(IDBVersionChangeEvent::create(EventTypeNames::upgradeneeded, ol dVersion, m_version, dataLoss, dataLossMessage));
106 } 107 }
107 108
108 void IDBOpenDBRequest::onSuccess(PassOwnPtr<WebIDBDatabase> backend, const IDBDa tabaseMetadata& metadata) 109 void IDBOpenDBRequest::onSuccess(PassOwnPtr<WebIDBDatabase> backend, const IDBDa tabaseMetadata& metadata)
109 { 110 {
110 IDB_TRACE("IDBOpenDBRequest::onSuccess()"); 111 IDB_TRACE("IDBOpenDBRequest::onSuccess()");
111 if (m_contextStopped || !executionContext()) { 112 if (m_contextStopped || !executionContext()) {
112 OwnPtr<WebIDBDatabase> db = backend; 113 OwnPtr<WebIDBDatabase> db = backend;
113 if (db) 114 if (db)
114 db->close(); 115 db->close();
115 return; 116 return;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 dequeueEvent(event.get()); 153 dequeueEvent(event.get());
153 setResult(nullptr); 154 setResult(nullptr);
154 onError(DOMError::create(AbortError, "The connection was closed.")); 155 onError(DOMError::create(AbortError, "The connection was closed."));
155 return false; 156 return false;
156 } 157 }
157 158
158 return IDBRequest::dispatchEvent(event); 159 return IDBRequest::dispatchEvent(event);
159 } 160 }
160 161
161 } // namespace WebCore 162 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/indexeddb/IDBDatabase.cpp ('k') | Source/modules/indexeddb/IDBVersionChangeEvent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698