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

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

Issue 2370643004: Port messages sent by WebIDBFactoryImpl to Mojo. (Closed)
Patch Set: Addressed most of dcheng@'s feedback. 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 DCHECK(!resultAsAny()); 60 DCHECK(!resultAsAny());
61 } 61 }
62 62
63 IDBOpenDBRequest::~IDBOpenDBRequest() {} 63 IDBOpenDBRequest::~IDBOpenDBRequest() {}
64 64
65 DEFINE_TRACE(IDBOpenDBRequest) { 65 DEFINE_TRACE(IDBOpenDBRequest) {
66 visitor->trace(m_databaseCallbacks); 66 visitor->trace(m_databaseCallbacks);
67 IDBRequest::trace(visitor); 67 IDBRequest::trace(visitor);
68 } 68 }
69 69
70 void IDBOpenDBRequest::contextDestroyed() {
71 IDBRequest::contextDestroyed();
72 if (m_databaseCallbacks)
73 m_databaseCallbacks->detachWebCallbacks();
74 }
75
70 const AtomicString& IDBOpenDBRequest::interfaceName() const { 76 const AtomicString& IDBOpenDBRequest::interfaceName() const {
71 return EventTargetNames::IDBOpenDBRequest; 77 return EventTargetNames::IDBOpenDBRequest;
72 } 78 }
73 79
74 void IDBOpenDBRequest::onBlocked(int64_t oldVersion) { 80 void IDBOpenDBRequest::onBlocked(int64_t oldVersion) {
75 IDB_TRACE("IDBOpenDBRequest::onBlocked()"); 81 IDB_TRACE("IDBOpenDBRequest::onBlocked()");
76 if (!shouldEnqueueEvent()) 82 if (!shouldEnqueueEvent())
77 return; 83 return;
78 Nullable<unsigned long long> newVersionNullable = 84 Nullable<unsigned long long> newVersionNullable =
79 (m_version == IDBDatabaseMetadata::DefaultVersion) 85 (m_version == IDBDatabaseMetadata::DefaultVersion)
80 ? Nullable<unsigned long long>() 86 ? Nullable<unsigned long long>()
81 : Nullable<unsigned long long>(m_version); 87 : Nullable<unsigned long long>(m_version);
82 enqueueEvent(IDBVersionChangeEvent::create(EventTypeNames::blocked, 88 enqueueEvent(IDBVersionChangeEvent::create(EventTypeNames::blocked,
83 oldVersion, newVersionNullable)); 89 oldVersion, newVersionNullable));
84 } 90 }
85 91
86 void IDBOpenDBRequest::onUpgradeNeeded(int64_t oldVersion, 92 void IDBOpenDBRequest::onUpgradeNeeded(int64_t oldVersion,
87 std::unique_ptr<WebIDBDatabase> backend, 93 std::unique_ptr<WebIDBDatabase> backend,
88 const IDBDatabaseMetadata& metadata, 94 const IDBDatabaseMetadata& metadata,
89 WebIDBDataLoss dataLoss, 95 WebIDBDataLoss dataLoss,
90 String dataLossMessage) { 96 String dataLossMessage) {
91 IDB_TRACE("IDBOpenDBRequest::onUpgradeNeeded()"); 97 IDB_TRACE("IDBOpenDBRequest::onUpgradeNeeded()");
92 if (m_contextStopped || !getExecutionContext()) {
93 std::unique_ptr<WebIDBDatabase> db = std::move(backend);
94 db->abort(m_transactionId);
95 db->close();
96 return;
97 }
98 if (!shouldEnqueueEvent()) 98 if (!shouldEnqueueEvent())
99 return; 99 return;
100 100
101 DCHECK(m_databaseCallbacks); 101 DCHECK(m_databaseCallbacks);
102 102
103 IDBDatabase* idbDatabase = IDBDatabase::create( 103 IDBDatabase* idbDatabase = IDBDatabase::create(
104 getExecutionContext(), std::move(backend), m_databaseCallbacks.release()); 104 getExecutionContext(), std::move(backend), m_databaseCallbacks.release());
105 idbDatabase->setMetadata(metadata); 105 idbDatabase->setMetadata(metadata);
106 106
107 if (oldVersion == IDBDatabaseMetadata::NoVersion) { 107 if (oldVersion == IDBDatabaseMetadata::NoVersion) {
(...skipping 10 matching lines...) Expand all
118 if (m_version == IDBDatabaseMetadata::NoVersion) 118 if (m_version == IDBDatabaseMetadata::NoVersion)
119 m_version = 1; 119 m_version = 1;
120 enqueueEvent(IDBVersionChangeEvent::create(EventTypeNames::upgradeneeded, 120 enqueueEvent(IDBVersionChangeEvent::create(EventTypeNames::upgradeneeded,
121 oldVersion, m_version, dataLoss, 121 oldVersion, m_version, dataLoss,
122 dataLossMessage)); 122 dataLossMessage));
123 } 123 }
124 124
125 void IDBOpenDBRequest::onSuccess(std::unique_ptr<WebIDBDatabase> backend, 125 void IDBOpenDBRequest::onSuccess(std::unique_ptr<WebIDBDatabase> backend,
126 const IDBDatabaseMetadata& metadata) { 126 const IDBDatabaseMetadata& metadata) {
127 IDB_TRACE("IDBOpenDBRequest::onSuccess()"); 127 IDB_TRACE("IDBOpenDBRequest::onSuccess()");
128 if (m_contextStopped || !getExecutionContext()) {
129 std::unique_ptr<WebIDBDatabase> db = std::move(backend);
130 if (db)
131 db->close();
132 return;
133 }
134 if (!shouldEnqueueEvent()) 128 if (!shouldEnqueueEvent())
135 return; 129 return;
136 130
137 IDBDatabase* idbDatabase = nullptr; 131 IDBDatabase* idbDatabase = nullptr;
138 if (resultAsAny()) { 132 if (resultAsAny()) {
139 // Previous onUpgradeNeeded call delivered the backend. 133 // Previous onUpgradeNeeded call delivered the backend.
140 DCHECK(!backend.get()); 134 DCHECK(!backend.get());
141 idbDatabase = resultAsAny()->idbDatabase(); 135 idbDatabase = resultAsAny()->idbDatabase();
142 DCHECK(idbDatabase); 136 DCHECK(idbDatabase);
143 DCHECK(!m_databaseCallbacks); 137 DCHECK(!m_databaseCallbacks);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 dequeueEvent(event); 177 dequeueEvent(event);
184 setResult(nullptr); 178 setResult(nullptr);
185 onError(DOMException::create(AbortError, "The connection was closed.")); 179 onError(DOMException::create(AbortError, "The connection was closed."));
186 return DispatchEventResult::CanceledBeforeDispatch; 180 return DispatchEventResult::CanceledBeforeDispatch;
187 } 181 }
188 182
189 return IDBRequest::dispatchEventInternal(event); 183 return IDBRequest::dispatchEventInternal(event);
190 } 184 }
191 185
192 } // namespace blink 186 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698