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

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

Issue 2601983002: [IndexedDB] Adding transaction and value support to observers (Closed)
Patch Set: Replying to comments, disallowed observing from versionchange txn Created 3 years, 11 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) 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 23 matching lines...) Expand all
34 #include "core/dom/ExecutionContext.h" 34 #include "core/dom/ExecutionContext.h"
35 #include "core/events/EventQueue.h" 35 #include "core/events/EventQueue.h"
36 #include "modules/IndexedDBNames.h" 36 #include "modules/IndexedDBNames.h"
37 #include "modules/indexeddb/IDBDatabase.h" 37 #include "modules/indexeddb/IDBDatabase.h"
38 #include "modules/indexeddb/IDBEventDispatcher.h" 38 #include "modules/indexeddb/IDBEventDispatcher.h"
39 #include "modules/indexeddb/IDBIndex.h" 39 #include "modules/indexeddb/IDBIndex.h"
40 #include "modules/indexeddb/IDBObjectStore.h" 40 #include "modules/indexeddb/IDBObjectStore.h"
41 #include "modules/indexeddb/IDBOpenDBRequest.h" 41 #include "modules/indexeddb/IDBOpenDBRequest.h"
42 #include "modules/indexeddb/IDBTracing.h" 42 #include "modules/indexeddb/IDBTracing.h"
43 #include "wtf/PtrUtil.h" 43 #include "wtf/PtrUtil.h"
44
44 #include <memory> 45 #include <memory>
45 46
46 using blink::WebIDBDatabase; 47 using blink::WebIDBDatabase;
47 48
48 namespace blink { 49 namespace blink {
49 50
51 IDBTransaction* IDBTransaction::createObserver(
52 ExecutionContext* executionContext,
53 int64_t id,
54 const HashSet<String>& scope,
55 IDBDatabase* db) {
56 DCHECK(!scope.isEmpty()) << "Observer transactions should operate on a "
pwnall 2017/01/10 01:41:11 how about using "must" instead of "should" just li
dmurph 2017/01/10 20:40:08 Done.
57 "well-defined set of stores";
58 IDBTransaction* transaction =
59 new IDBTransaction(executionContext, id, scope, db);
60 return transaction;
61 }
62
50 IDBTransaction* IDBTransaction::createNonVersionChange( 63 IDBTransaction* IDBTransaction::createNonVersionChange(
51 ScriptState* scriptState, 64 ScriptState* scriptState,
52 int64_t id, 65 int64_t id,
53 const HashSet<String>& scope, 66 const HashSet<String>& scope,
54 WebIDBTransactionMode mode, 67 WebIDBTransactionMode mode,
55 IDBDatabase* db) { 68 IDBDatabase* db) {
56 DCHECK_NE(mode, WebIDBTransactionModeVersionChange); 69 DCHECK_NE(mode, WebIDBTransactionModeVersionChange);
57 DCHECK(!scope.isEmpty()) << "Non-version transactions should operate on a " 70 DCHECK(!scope.isEmpty()) << "Non-version transactions should operate on a "
58 "well-defined set of stores"; 71 "well-defined set of stores";
59 return new IDBTransaction(scriptState, id, scope, mode, db); 72 return new IDBTransaction(scriptState, id, scope, mode, db);
(...skipping 25 matching lines...) Expand all
85 98
86 private: 99 private:
87 explicit DeactivateTransactionTask(IDBTransaction* transaction) 100 explicit DeactivateTransactionTask(IDBTransaction* transaction)
88 : m_transaction(transaction) {} 101 : m_transaction(transaction) {}
89 102
90 Persistent<IDBTransaction> m_transaction; 103 Persistent<IDBTransaction> m_transaction;
91 }; 104 };
92 105
93 } // namespace 106 } // namespace
94 107
108 IDBTransaction::IDBTransaction(ExecutionContext* executionContext,
109 int64_t id,
110 const HashSet<String>& scope,
111 IDBDatabase* db)
112 : ContextLifecycleObserver(executionContext),
113 m_id(id),
114 m_database(db),
115 m_mode(WebIDBTransactionModeReadOnly),
116 m_scope(scope),
117 m_state(Active) {
118 DCHECK(m_database);
119 DCHECK(!m_scope.isEmpty()) << "Observer transactions must operate "
120 "on a well-defined set of stores";
121
122 DCHECK_EQ(m_state, Active);
pwnall 2017/01/10 01:41:11 This seems a bit excessive, given that you're init
dmurph 2017/01/10 20:40:08 Done.
123 m_database->transactionCreated(this);
124 }
125
95 IDBTransaction::IDBTransaction(ScriptState* scriptState, 126 IDBTransaction::IDBTransaction(ScriptState* scriptState,
96 int64_t id, 127 int64_t id,
97 const HashSet<String>& scope, 128 const HashSet<String>& scope,
98 WebIDBTransactionMode mode, 129 WebIDBTransactionMode mode,
99 IDBDatabase* db) 130 IDBDatabase* db)
100 : ContextLifecycleObserver(scriptState->getExecutionContext()), 131 : ContextLifecycleObserver(scriptState->getExecutionContext()),
101 m_id(id), 132 m_id(id),
102 m_database(db), 133 m_database(db),
103 m_mode(mode), 134 m_mode(mode),
104 m_scope(scope) { 135 m_scope(scope) {
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 IDBObjectStore* objectStore = it.key; 599 IDBObjectStore* objectStore = it.key;
569 objectStore->clearIndexCache(); 600 objectStore->clearIndexCache();
570 } 601 }
571 m_oldStoreMetadata.clear(); 602 m_oldStoreMetadata.clear();
572 603
573 m_deletedIndexes.clear(); 604 m_deletedIndexes.clear();
574 m_deletedObjectStores.clear(); 605 m_deletedObjectStores.clear();
575 } 606 }
576 607
577 } // namespace blink 608 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698