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

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

Issue 1963293002: Replacing Indexed DB Chromium IPC with Mojo Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Some (incomplete) work on struct traits. Created 4 years, 5 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
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
(...skipping 13 matching lines...) Expand all
24 */ 24 */
25 25
26 #include "modules/indexeddb/IDBOpenDBRequest.h" 26 #include "modules/indexeddb/IDBOpenDBRequest.h"
27 27
28 #include "bindings/core/v8/Nullable.h" 28 #include "bindings/core/v8/Nullable.h"
29 #include "core/dom/DOMException.h" 29 #include "core/dom/DOMException.h"
30 #include "core/dom/ExceptionCode.h" 30 #include "core/dom/ExceptionCode.h"
31 #include "core/dom/ExecutionContext.h" 31 #include "core/dom/ExecutionContext.h"
32 #include "modules/indexeddb/IDBDatabase.h" 32 #include "modules/indexeddb/IDBDatabase.h"
33 #include "modules/indexeddb/IDBDatabaseCallbacks.h" 33 #include "modules/indexeddb/IDBDatabaseCallbacks.h"
34 #include "modules/indexeddb/IDBDatabaseProxy.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 #include <memory> 37 #include <memory>
37 38
38 using blink::WebIDBDatabase; 39 using blink::IDBDatabaseProxy;
39 40
40 namespace blink { 41 namespace blink {
41 42
42 IDBOpenDBRequest* IDBOpenDBRequest::create(ScriptState* scriptState, IDBDatabase Callbacks* callbacks, int64_t transactionId, int64_t version) 43 IDBOpenDBRequest* IDBOpenDBRequest::create(ScriptState* scriptState, IDBDatabase Callbacks* callbacks, int64_t transactionId, int64_t version)
43 { 44 {
44 IDBOpenDBRequest* request = new IDBOpenDBRequest(scriptState, callbacks, tra nsactionId, version); 45 IDBOpenDBRequest* request = new IDBOpenDBRequest(scriptState, callbacks, tra nsactionId, version);
45 request->suspendIfNeeded(); 46 request->suspendIfNeeded();
46 return request; 47 return request;
47 } 48 }
48 49
(...skipping 23 matching lines...) Expand all
72 73
73 void IDBOpenDBRequest::onBlocked(int64_t oldVersion) 74 void IDBOpenDBRequest::onBlocked(int64_t oldVersion)
74 { 75 {
75 IDB_TRACE("IDBOpenDBRequest::onBlocked()"); 76 IDB_TRACE("IDBOpenDBRequest::onBlocked()");
76 if (!shouldEnqueueEvent()) 77 if (!shouldEnqueueEvent())
77 return; 78 return;
78 Nullable<unsigned long long> newVersionNullable = (m_version == IDBDatabaseM etadata::DefaultVersion) ? Nullable<unsigned long long>() : Nullable<unsigned lo ng long>(m_version); 79 Nullable<unsigned long long> newVersionNullable = (m_version == IDBDatabaseM etadata::DefaultVersion) ? Nullable<unsigned long long>() : Nullable<unsigned lo ng long>(m_version);
79 enqueueEvent(IDBVersionChangeEvent::create(EventTypeNames::blocked, oldVersi on, newVersionNullable)); 80 enqueueEvent(IDBVersionChangeEvent::create(EventTypeNames::blocked, oldVersi on, newVersionNullable));
80 } 81 }
81 82
82 void IDBOpenDBRequest::onUpgradeNeeded(int64_t oldVersion, std::unique_ptr<WebID BDatabase> backend, const IDBDatabaseMetadata& metadata, WebIDBDataLoss dataLoss , String dataLossMessage) 83 void IDBOpenDBRequest::onUpgradeNeeded(int64_t oldVersion, std::unique_ptr<IDBDa tabaseProxy> backend, const IDBDatabaseMetadata& metadata, indexed_db::mojom::bl ink::DataLoss dataLoss, String dataLossMessage)
83 { 84 {
84 IDB_TRACE("IDBOpenDBRequest::onUpgradeNeeded()"); 85 IDB_TRACE("IDBOpenDBRequest::onUpgradeNeeded()");
86 std::unique_ptr<IDBDatabaseProxy> db = std::move(backend);
85 if (m_contextStopped || !getExecutionContext()) { 87 if (m_contextStopped || !getExecutionContext()) {
86 std::unique_ptr<WebIDBDatabase> db = std::move(backend); 88 db->Abort(m_transactionId);
87 db->abort(m_transactionId); 89 db->Close();
88 db->close();
89 return; 90 return;
90 } 91 }
91 if (!shouldEnqueueEvent()) 92 if (!shouldEnqueueEvent())
92 return; 93 return;
93 94
94 ASSERT(m_databaseCallbacks); 95 ASSERT(m_databaseCallbacks);
95 96
96 IDBDatabase* idbDatabase = IDBDatabase::create(getExecutionContext(), std::m ove(backend), m_databaseCallbacks.release()); 97 IDBDatabase* idbDatabase = IDBDatabase::create(getExecutionContext(), std::m ove(db), m_databaseCallbacks.release());
97 idbDatabase->setMetadata(metadata); 98 idbDatabase->setMetadata(metadata);
98 99
99 if (oldVersion == IDBDatabaseMetadata::NoVersion) { 100 if (oldVersion == IDBDatabaseMetadata::NoVersion) {
100 // This database hasn't had a version before. 101 // This database hasn't had a version before.
101 oldVersion = IDBDatabaseMetadata::DefaultVersion; 102 oldVersion = IDBDatabaseMetadata::DefaultVersion;
102 } 103 }
103 IDBDatabaseMetadata oldMetadata(metadata); 104 IDBDatabaseMetadata oldMetadata(metadata);
104 oldMetadata.version = oldVersion; 105 oldMetadata.version = oldVersion;
105 106
106 m_transaction = IDBTransaction::create(getScriptState(), m_transactionId, id bDatabase, this, oldMetadata); 107 m_transaction = IDBTransaction::create(getScriptState(), m_transactionId, id bDatabase, this, oldMetadata);
107 setResult(IDBAny::create(idbDatabase)); 108 setResult(IDBAny::create(idbDatabase));
108 109
109 if (m_version == IDBDatabaseMetadata::NoVersion) 110 if (m_version == IDBDatabaseMetadata::NoVersion)
110 m_version = 1; 111 m_version = 1;
111 enqueueEvent(IDBVersionChangeEvent::create(EventTypeNames::upgradeneeded, ol dVersion, m_version, dataLoss, dataLossMessage)); 112 enqueueEvent(IDBVersionChangeEvent::create(EventTypeNames::upgradeneeded, ol dVersion, m_version, dataLoss, dataLossMessage));
112 } 113 }
113 114
114 void IDBOpenDBRequest::onSuccess(std::unique_ptr<WebIDBDatabase> backend, const IDBDatabaseMetadata& metadata) 115 void IDBOpenDBRequest::onSuccess(std::unique_ptr<IDBDatabaseProxy> backend, cons t IDBDatabaseMetadata& metadata)
115 { 116 {
116 IDB_TRACE("IDBOpenDBRequest::onSuccess()"); 117 IDB_TRACE("IDBOpenDBRequest::onSuccess()");
117 if (m_contextStopped || !getExecutionContext()) { 118 if (m_contextStopped || !getExecutionContext()) {
118 std::unique_ptr<WebIDBDatabase> db = std::move(backend); 119 std::unique_ptr<IDBDatabaseProxy> db = std::move(backend);
119 if (db) 120 if (db)
120 db->close(); 121 db->Close();
121 return; 122 return;
122 } 123 }
123 if (!shouldEnqueueEvent()) 124 if (!shouldEnqueueEvent())
124 return; 125 return;
125 126
126 IDBDatabase* idbDatabase = nullptr; 127 IDBDatabase* idbDatabase = nullptr;
127 if (resultAsAny()) { 128 if (resultAsAny()) {
128 // Previous onUpgradeNeeded call delivered the backend. 129 // Previous onUpgradeNeeded call delivered the backend.
129 ASSERT(!backend.get()); 130 ASSERT(!backend.get());
130 idbDatabase = resultAsAny()->idbDatabase(); 131 idbDatabase = resultAsAny()->idbDatabase();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 dequeueEvent(event); 172 dequeueEvent(event);
172 setResult(nullptr); 173 setResult(nullptr);
173 onError(DOMException::create(AbortError, "The connection was closed.")); 174 onError(DOMException::create(AbortError, "The connection was closed."));
174 return DispatchEventResult::CanceledBeforeDispatch; 175 return DispatchEventResult::CanceledBeforeDispatch;
175 } 176 }
176 177
177 return IDBRequest::dispatchEventInternal(event); 178 return IDBRequest::dispatchEventInternal(event);
178 } 179 }
179 180
180 } // namespace blink 181 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698