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

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

Issue 2370643004: Port messages sent by WebIDBFactoryImpl to Mojo. (Closed)
Patch Set: Allow cpp_only to be set by the invoker. Created 4 years, 2 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 IDBOpenDBRequest::~IDBOpenDBRequest() 58 IDBOpenDBRequest::~IDBOpenDBRequest()
59 { 59 {
60 } 60 }
61 61
62 DEFINE_TRACE(IDBOpenDBRequest) 62 DEFINE_TRACE(IDBOpenDBRequest)
63 { 63 {
64 visitor->trace(m_databaseCallbacks); 64 visitor->trace(m_databaseCallbacks);
65 IDBRequest::trace(visitor); 65 IDBRequest::trace(visitor);
66 } 66 }
67 67
68 void IDBOpenDBRequest::stop()
69 {
70 IDBRequest::stop();
71 if (m_databaseCallbacks)
72 m_databaseCallbacks->detachWebCallbacks();
73 }
74
68 const AtomicString& IDBOpenDBRequest::interfaceName() const 75 const AtomicString& IDBOpenDBRequest::interfaceName() const
69 { 76 {
70 return EventTargetNames::IDBOpenDBRequest; 77 return EventTargetNames::IDBOpenDBRequest;
71 } 78 }
72 79
73 void IDBOpenDBRequest::onBlocked(int64_t oldVersion) 80 void IDBOpenDBRequest::onBlocked(int64_t oldVersion)
74 { 81 {
75 IDB_TRACE("IDBOpenDBRequest::onBlocked()"); 82 IDB_TRACE("IDBOpenDBRequest::onBlocked()");
76 if (!shouldEnqueueEvent()) 83 if (!shouldEnqueueEvent())
77 return; 84 return;
78 Nullable<unsigned long long> newVersionNullable = (m_version == IDBDatabaseM etadata::DefaultVersion) ? Nullable<unsigned long long>() : Nullable<unsigned lo ng long>(m_version); 85 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)); 86 enqueueEvent(IDBVersionChangeEvent::create(EventTypeNames::blocked, oldVersi on, newVersionNullable));
80 } 87 }
81 88
82 void IDBOpenDBRequest::onUpgradeNeeded(int64_t oldVersion, std::unique_ptr<WebID BDatabase> backend, const IDBDatabaseMetadata& metadata, WebIDBDataLoss dataLoss , String dataLossMessage) 89 void IDBOpenDBRequest::onUpgradeNeeded(int64_t oldVersion, std::unique_ptr<WebID BDatabase> backend, const IDBDatabaseMetadata& metadata, WebIDBDataLoss dataLoss , String dataLossMessage)
83 { 90 {
84 IDB_TRACE("IDBOpenDBRequest::onUpgradeNeeded()"); 91 IDB_TRACE("IDBOpenDBRequest::onUpgradeNeeded()");
85 if (m_contextStopped || !getExecutionContext()) {
86 std::unique_ptr<WebIDBDatabase> db = std::move(backend);
87 db->abort(m_transactionId);
88 db->close();
89 return;
90 }
91 if (!shouldEnqueueEvent()) 92 if (!shouldEnqueueEvent())
92 return; 93 return;
93 94
94 DCHECK(m_databaseCallbacks); 95 DCHECK(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(backend), 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::createVersionChange(getScriptState(), m_tran sactionId, idbDatabase, this, oldMetadata); 107 m_transaction = IDBTransaction::createVersionChange(getScriptState(), m_tran sactionId, idbDatabase, 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<WebIDBDatabase> backend, const IDBDatabaseMetadata& metadata)
115 { 116 {
116 IDB_TRACE("IDBOpenDBRequest::onSuccess()"); 117 IDB_TRACE("IDBOpenDBRequest::onSuccess()");
117 if (m_contextStopped || !getExecutionContext()) {
118 std::unique_ptr<WebIDBDatabase> db = std::move(backend);
119 if (db)
120 db->close();
121 return;
122 }
123 if (!shouldEnqueueEvent()) 118 if (!shouldEnqueueEvent())
124 return; 119 return;
125 120
126 IDBDatabase* idbDatabase = nullptr; 121 IDBDatabase* idbDatabase = nullptr;
127 if (resultAsAny()) { 122 if (resultAsAny()) {
128 // Previous onUpgradeNeeded call delivered the backend. 123 // Previous onUpgradeNeeded call delivered the backend.
129 DCHECK(!backend.get()); 124 DCHECK(!backend.get());
130 idbDatabase = resultAsAny()->idbDatabase(); 125 idbDatabase = resultAsAny()->idbDatabase();
131 DCHECK(idbDatabase); 126 DCHECK(idbDatabase);
132 DCHECK(!m_databaseCallbacks); 127 DCHECK(!m_databaseCallbacks);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 dequeueEvent(event); 166 dequeueEvent(event);
172 setResult(nullptr); 167 setResult(nullptr);
173 onError(DOMException::create(AbortError, "The connection was closed.")); 168 onError(DOMException::create(AbortError, "The connection was closed."));
174 return DispatchEventResult::CanceledBeforeDispatch; 169 return DispatchEventResult::CanceledBeforeDispatch;
175 } 170 }
176 171
177 return IDBRequest::dispatchEventInternal(event); 172 return IDBRequest::dispatchEventInternal(event);
178 } 173 }
179 174
180 } // namespace blink 175 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698