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

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

Issue 2742393002: Turn IDBTransaction into the ContextLifecycleObserver it needs to be. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « third_party/WebKit/Source/modules/indexeddb/IDBTransaction.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 Persistent<IDBTransaction> m_transaction; 102 Persistent<IDBTransaction> m_transaction;
103 }; 103 };
104 104
105 } // namespace 105 } // namespace
106 106
107 IDBTransaction::IDBTransaction(ExecutionContext* executionContext, 107 IDBTransaction::IDBTransaction(ExecutionContext* executionContext,
108 int64_t id, 108 int64_t id,
109 const HashSet<String>& scope, 109 const HashSet<String>& scope,
110 IDBDatabase* db) 110 IDBDatabase* db)
111 : ContextClient(executionContext), 111 : ContextLifecycleObserver(executionContext),
112 m_id(id), 112 m_id(id),
113 m_database(db), 113 m_database(db),
114 m_mode(WebIDBTransactionModeReadOnly), 114 m_mode(WebIDBTransactionModeReadOnly),
115 m_scope(scope), 115 m_scope(scope),
116 m_state(Active) { 116 m_state(Active) {
117 DCHECK(m_database); 117 DCHECK(m_database);
118 DCHECK(!m_scope.isEmpty()) << "Observer transactions must operate " 118 DCHECK(!m_scope.isEmpty()) << "Observer transactions must operate "
119 "on a well-defined set of stores"; 119 "on a well-defined set of stores";
120 m_database->transactionCreated(this); 120 m_database->transactionCreated(this);
121 } 121 }
122 122
123 IDBTransaction::IDBTransaction(ScriptState* scriptState, 123 IDBTransaction::IDBTransaction(ScriptState* scriptState,
124 int64_t id, 124 int64_t id,
125 const HashSet<String>& scope, 125 const HashSet<String>& scope,
126 WebIDBTransactionMode mode, 126 WebIDBTransactionMode mode,
127 IDBDatabase* db) 127 IDBDatabase* db)
128 : ContextClient(scriptState->getExecutionContext()), 128 : ContextLifecycleObserver(scriptState->getExecutionContext()),
129 m_id(id), 129 m_id(id),
130 m_database(db), 130 m_database(db),
131 m_mode(mode), 131 m_mode(mode),
132 m_scope(scope) { 132 m_scope(scope) {
133 DCHECK(m_database); 133 DCHECK(m_database);
134 DCHECK(!m_scope.isEmpty()) << "Non-versionchange transactions must operate " 134 DCHECK(!m_scope.isEmpty()) << "Non-versionchange transactions must operate "
135 "on a well-defined set of stores"; 135 "on a well-defined set of stores";
136 DCHECK(m_mode == WebIDBTransactionModeReadOnly || 136 DCHECK(m_mode == WebIDBTransactionModeReadOnly ||
137 m_mode == WebIDBTransactionModeReadWrite) 137 m_mode == WebIDBTransactionModeReadWrite)
138 << "Invalid transaction mode"; 138 << "Invalid transaction mode";
139 139
140 DCHECK_EQ(m_state, Active); 140 DCHECK_EQ(m_state, Active);
141 V8PerIsolateData::from(scriptState->isolate()) 141 V8PerIsolateData::from(scriptState->isolate())
142 ->addEndOfScopeTask(DeactivateTransactionTask::create(this)); 142 ->addEndOfScopeTask(DeactivateTransactionTask::create(this));
143 143
144 m_database->transactionCreated(this); 144 m_database->transactionCreated(this);
145 } 145 }
146 146
147 IDBTransaction::IDBTransaction(ExecutionContext* executionContext, 147 IDBTransaction::IDBTransaction(ExecutionContext* executionContext,
148 int64_t id, 148 int64_t id,
149 IDBDatabase* db, 149 IDBDatabase* db,
150 IDBOpenDBRequest* openDBRequest, 150 IDBOpenDBRequest* openDBRequest,
151 const IDBDatabaseMetadata& oldMetadata) 151 const IDBDatabaseMetadata& oldMetadata)
152 : ContextClient(executionContext), 152 : ContextLifecycleObserver(executionContext),
153 m_id(id), 153 m_id(id),
154 m_database(db), 154 m_database(db),
155 m_openDBRequest(openDBRequest), 155 m_openDBRequest(openDBRequest),
156 m_mode(WebIDBTransactionModeVersionChange), 156 m_mode(WebIDBTransactionModeVersionChange),
157 m_state(Inactive), 157 m_state(Inactive),
158 m_oldDatabaseMetadata(oldMetadata) { 158 m_oldDatabaseMetadata(oldMetadata) {
159 DCHECK(m_database); 159 DCHECK(m_database);
160 DCHECK(m_openDBRequest); 160 DCHECK(m_openDBRequest);
161 DCHECK(m_scope.isEmpty()); 161 DCHECK(m_scope.isEmpty());
162 162
163 m_database->transactionCreated(this); 163 m_database->transactionCreated(this);
164 } 164 }
165 165
166 IDBTransaction::~IDBTransaction() { 166 IDBTransaction::~IDBTransaction() {
167 // Note: IDBTransaction is a ContextLifecycleObserver (rather than
168 // ContextClient) only in order to be able call upon getExecutionContext()
169 // during this destructor.
167 DCHECK(m_state == Finished || !getExecutionContext()); 170 DCHECK(m_state == Finished || !getExecutionContext());
168 DCHECK(m_requestList.isEmpty() || !getExecutionContext()); 171 DCHECK(m_requestList.isEmpty() || !getExecutionContext());
169 } 172 }
170 173
171 DEFINE_TRACE(IDBTransaction) { 174 DEFINE_TRACE(IDBTransaction) {
172 visitor->trace(m_database); 175 visitor->trace(m_database);
173 visitor->trace(m_openDBRequest); 176 visitor->trace(m_openDBRequest);
174 visitor->trace(m_error); 177 visitor->trace(m_error);
175 visitor->trace(m_requestList); 178 visitor->trace(m_requestList);
176 visitor->trace(m_objectStoreMap); 179 visitor->trace(m_objectStoreMap);
177 visitor->trace(m_oldStoreMetadata); 180 visitor->trace(m_oldStoreMetadata);
178 visitor->trace(m_deletedIndexes); 181 visitor->trace(m_deletedIndexes);
179 EventTargetWithInlineData::trace(visitor); 182 EventTargetWithInlineData::trace(visitor);
180 ContextClient::trace(visitor); 183 ContextLifecycleObserver::trace(visitor);
181 } 184 }
182 185
183 void IDBTransaction::setError(DOMException* error) { 186 void IDBTransaction::setError(DOMException* error) {
184 DCHECK_NE(m_state, Finished); 187 DCHECK_NE(m_state, Finished);
185 DCHECK(error); 188 DCHECK(error);
186 189
187 // The first error to be set is the true cause of the 190 // The first error to be set is the true cause of the
188 // transaction abort. 191 // transaction abort.
189 if (!m_error) 192 if (!m_error)
190 m_error = error; 193 m_error = error;
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 objectStoreNames->append(objectStoreName); 475 objectStoreNames->append(objectStoreName);
473 objectStoreNames->sort(); 476 objectStoreNames->sort();
474 return objectStoreNames; 477 return objectStoreNames;
475 } 478 }
476 479
477 const AtomicString& IDBTransaction::interfaceName() const { 480 const AtomicString& IDBTransaction::interfaceName() const {
478 return EventTargetNames::IDBTransaction; 481 return EventTargetNames::IDBTransaction;
479 } 482 }
480 483
481 ExecutionContext* IDBTransaction::getExecutionContext() const { 484 ExecutionContext* IDBTransaction::getExecutionContext() const {
482 return ContextClient::getExecutionContext(); 485 return ContextLifecycleObserver::getExecutionContext();
483 } 486 }
484 487
485 DispatchEventResult IDBTransaction::dispatchEventInternal(Event* event) { 488 DispatchEventResult IDBTransaction::dispatchEventInternal(Event* event) {
486 IDB_TRACE("IDBTransaction::dispatchEvent"); 489 IDB_TRACE("IDBTransaction::dispatchEvent");
487 if (!getExecutionContext()) { 490 if (!getExecutionContext()) {
488 m_state = Finished; 491 m_state = Finished;
489 return DispatchEventResult::CanceledBeforeDispatch; 492 return DispatchEventResult::CanceledBeforeDispatch;
490 } 493 }
491 DCHECK_NE(m_state, Finished); 494 DCHECK_NE(m_state, Finished);
492 DCHECK(m_hasPendingActivity); 495 DCHECK(m_hasPendingActivity);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 IDBObjectStore* objectStore = it.key; 598 IDBObjectStore* objectStore = it.key;
596 objectStore->clearIndexCache(); 599 objectStore->clearIndexCache();
597 } 600 }
598 m_oldStoreMetadata.clear(); 601 m_oldStoreMetadata.clear();
599 602
600 m_deletedIndexes.clear(); 603 m_deletedIndexes.clear();
601 m_deletedObjectStores.clear(); 604 m_deletedObjectStores.clear();
602 } 605 }
603 606
604 } // namespace blink 607 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/indexeddb/IDBTransaction.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698