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

Side by Side Diff: Source/modules/indexeddb/IDBTransactionBackendImpl.h

Issue 78053006: [oilpan] Move IDBDatabase, IDBDatabaseCallbacks, IDBDatabaseBackendInterface and other related clas… (Closed) Base URL: svn://svn.chromium.org/blink/branches/oilpan
Patch Set: Created 7 years 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 | Annotate | Revision Log
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 24 matching lines...) Expand all
35 #include "wtf/RefPtr.h" 35 #include "wtf/RefPtr.h"
36 36
37 namespace WebCore { 37 namespace WebCore {
38 38
39 class IDBDatabaseBackendImpl; 39 class IDBDatabaseBackendImpl;
40 class IDBCursorBackendImpl; 40 class IDBCursorBackendImpl;
41 class IDBDatabaseCallbacks; 41 class IDBDatabaseCallbacks;
42 42
43 class IDBTransactionBackendImpl : public RefCounted<IDBTransactionBackendImpl> { 43 class IDBTransactionBackendImpl : public RefCounted<IDBTransactionBackendImpl> {
44 public: 44 public:
45 static PassRefPtr<IDBTransactionBackendImpl> create(int64_t transactionId, P assRefPtr<IDBDatabaseCallbacks>, const Vector<int64_t>&, IndexedDB::TransactionM ode, IDBDatabaseBackendImpl*); 45 static PassRefPtr<IDBTransactionBackendImpl> create(int64_t transactionId, I DBDatabaseCallbacks*, const Vector<int64_t>&, IndexedDB::TransactionMode, IDBDat abaseBackendImpl*);
46 virtual ~IDBTransactionBackendImpl(); 46 virtual ~IDBTransactionBackendImpl();
47 47
48 virtual void abort(); 48 virtual void abort();
49 void commit(); 49 void commit();
50 50
51 class Operation { 51 class Operation {
52 public: 52 public:
53 virtual ~Operation() { } 53 virtual ~Operation() { }
54 virtual void perform(IDBTransactionBackendImpl*) = 0; 54 virtual void perform(IDBTransactionBackendImpl*) = 0;
55 }; 55 };
56 56
57 void abort(PassRefPtr<IDBDatabaseError>); 57 void abort(PassRefPtr<IDBDatabaseError>);
58 void run(); 58 void run();
59 IndexedDB::TransactionMode mode() const { return m_mode; } 59 IndexedDB::TransactionMode mode() const { return m_mode; }
60 const HashSet<int64_t>& scope() const { return m_objectStoreIds; } 60 const HashSet<int64_t>& scope() const { return m_objectStoreIds; }
61 void scheduleTask(PassOwnPtr<Operation> task, PassOwnPtr<Operation> abortTas k = nullptr) { scheduleTask(IDBDatabaseBackendInterface::NormalTask, task, abort Task); } 61 void scheduleTask(PassOwnPtr<Operation> task, PassOwnPtr<Operation> abortTas k = nullptr) { scheduleTask(IDBDatabaseBackendInterface::NormalTask, task, abort Task); }
62 void scheduleTask(IDBDatabaseBackendInterface::TaskType, PassOwnPtr<Operatio n>, PassOwnPtr<Operation> abortTask = nullptr); 62 void scheduleTask(IDBDatabaseBackendInterface::TaskType, PassOwnPtr<Operatio n>, PassOwnPtr<Operation> abortTask = nullptr);
63 void registerOpenCursor(IDBCursorBackendImpl*); 63 void registerOpenCursor(IDBCursorBackendImpl*);
64 void unregisterOpenCursor(IDBCursorBackendImpl*); 64 void unregisterOpenCursor(IDBCursorBackendImpl*);
65 void addPreemptiveEvent() { m_pendingPreemptiveEvents++; } 65 void addPreemptiveEvent() { m_pendingPreemptiveEvents++; }
66 void didCompletePreemptiveEvent() { m_pendingPreemptiveEvents--; ASSERT(m_pe ndingPreemptiveEvents >= 0); } 66 void didCompletePreemptiveEvent() { m_pendingPreemptiveEvents--; ASSERT(m_pe ndingPreemptiveEvents >= 0); }
67 IDBBackingStore::Transaction* backingStoreTransaction() { return &m_transact ion; } 67 IDBBackingStore::Transaction* backingStoreTransaction() { return &m_transact ion; }
68 int64_t id() const { return m_id; } 68 int64_t id() const { return m_id; }
69 69
70 IDBDatabaseBackendImpl* database() const { return m_database.get(); } 70 IDBDatabaseBackendImpl* database() const { return m_database.raw(); }
71 IDBDatabaseCallbacks* connection() const { return m_callbacks.get(); } 71 IDBDatabaseCallbacks* connection() const { return m_callbacks.raw(); }
72 72
73 private: 73 private:
74 IDBTransactionBackendImpl(int64_t id, PassRefPtr<IDBDatabaseCallbacks>, cons t HashSet<int64_t>& objectStoreIds, IndexedDB::TransactionMode, IDBDatabaseBacke ndImpl*); 74 IDBTransactionBackendImpl(int64_t id, IDBDatabaseCallbacks*, const HashSet<i nt64_t>& objectStoreIds, IndexedDB::TransactionMode, IDBDatabaseBackendImpl*);
75 75
76 enum State { 76 enum State {
77 Unused, // Created, but no tasks yet. 77 Unused, // Created, but no tasks yet.
78 StartPending, // Enqueued tasks, but backing store transaction not yet s tarted. 78 StartPending, // Enqueued tasks, but backing store transaction not yet s tarted.
79 Running, // Backing store transaction started but not yet finished. 79 Running, // Backing store transaction started but not yet finished.
80 Finished, // Either aborted or committed. 80 Finished, // Either aborted or committed.
81 }; 81 };
82 82
83 void start(); 83 void start();
84 84
85 bool isTaskQueueEmpty() const; 85 bool isTaskQueueEmpty() const;
86 bool hasPendingTasks() const; 86 bool hasPendingTasks() const;
87 87
88 void taskTimerFired(Timer<IDBTransactionBackendImpl>*); 88 void taskTimerFired(Timer<IDBTransactionBackendImpl>*);
89 void closeOpenCursors(); 89 void closeOpenCursors();
90 90
91 const int64_t m_id; 91 const int64_t m_id;
92 const HashSet<int64_t> m_objectStoreIds; 92 const HashSet<int64_t> m_objectStoreIds;
93 const IndexedDB::TransactionMode m_mode; 93 const IndexedDB::TransactionMode m_mode;
94 94
95 State m_state; 95 State m_state;
96 bool m_commitPending; 96 bool m_commitPending;
97 RefPtr<IDBDatabaseCallbacks> m_callbacks; 97 Persistent<IDBDatabaseCallbacks> m_callbacks;
98 RefPtr<IDBDatabaseBackendImpl> m_database; 98 Persistent<IDBDatabaseBackendImpl> m_database;
99 99
100 typedef Deque<OwnPtr<Operation> > TaskQueue; 100 typedef Deque<OwnPtr<Operation> > TaskQueue;
101 TaskQueue m_taskQueue; 101 TaskQueue m_taskQueue;
102 TaskQueue m_preemptiveTaskQueue; 102 TaskQueue m_preemptiveTaskQueue;
103 TaskQueue m_abortTaskQueue; 103 TaskQueue m_abortTaskQueue;
104 104
105 IDBBackingStore::Transaction m_transaction; 105 IDBBackingStore::Transaction m_transaction;
106 106
107 // FIXME: delete the timer once we have threads instead. 107 // FIXME: delete the timer once we have threads instead.
108 Timer<IDBTransactionBackendImpl> m_taskTimer; 108 Timer<IDBTransactionBackendImpl> m_taskTimer;
109 int m_pendingPreemptiveEvents; 109 int m_pendingPreemptiveEvents;
110 110
111 HashSet<IDBCursorBackendImpl*> m_openCursors; 111 HashSet<IDBCursorBackendImpl*> m_openCursors;
112 }; 112 };
113 113
114 } // namespace WebCore 114 } // namespace WebCore
115 115
116 #endif // IDBTransactionBackendImpl_h 116 #endif // IDBTransactionBackendImpl_h
OLDNEW
« no previous file with comments | « Source/modules/indexeddb/IDBTransaction.cpp ('k') | Source/modules/indexeddb/IDBTransactionBackendImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698