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

Side by Side Diff: content/browser/indexed_db/indexed_db_transaction.h

Issue 18023022: Blob support for IDB [Chromium] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged out--bot failed due to staleness. Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_H_ 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_H_
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_H_ 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <set> 9 #include <set>
10 #include <stack> 10 #include <stack>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
17 #include "content/browser/indexed_db/indexed_db_backing_store.h" 17 #include "content/browser/indexed_db/indexed_db_backing_store.h"
18 #include "content/browser/indexed_db/indexed_db_database.h" 18 #include "content/browser/indexed_db/indexed_db_database.h"
19 #include "content/browser/indexed_db/indexed_db_database_error.h" 19 #include "content/browser/indexed_db/indexed_db_database_error.h"
20 20
21 namespace content { 21 namespace content {
22 22
23 class BlobWriteCallbackImpl;
23 class IndexedDBCursor; 24 class IndexedDBCursor;
24 class IndexedDBDatabaseCallbacks; 25 class IndexedDBDatabaseCallbacks;
25 26
26 class CONTENT_EXPORT IndexedDBTransaction 27 class CONTENT_EXPORT IndexedDBTransaction
27 : public NON_EXPORTED_BASE(base::RefCounted<IndexedDBTransaction>) { 28 : public NON_EXPORTED_BASE(base::RefCounted<IndexedDBTransaction>) {
28 public: 29 public:
29 typedef base::Callback<void(IndexedDBTransaction*)> Operation; 30 typedef base::Callback<void(IndexedDBTransaction*)> Operation;
30 31
31 IndexedDBTransaction( 32 IndexedDBTransaction(
32 int64 id, 33 int64 id,
(...skipping 27 matching lines...) Expand all
60 } 61 }
61 IndexedDBBackingStore::Transaction* BackingStoreTransaction() { 62 IndexedDBBackingStore::Transaction* BackingStoreTransaction() {
62 return transaction_.get(); 63 return transaction_.get();
63 } 64 }
64 int64 id() const { return id_; } 65 int64 id() const { return id_; }
65 66
66 IndexedDBDatabase* database() const { return database_; } 67 IndexedDBDatabase* database() const { return database_; }
67 IndexedDBDatabaseCallbacks* connection() const { return callbacks_; } 68 IndexedDBDatabaseCallbacks* connection() const { return callbacks_; }
68 69
69 enum State { 70 enum State {
70 CREATED, // Created, but not yet started by coordinator. 71 CREATED, // Created, but not yet started by coordinator.
71 STARTED, // Started by the coordinator. 72 STARTED, // Started by the coordinator.
72 FINISHED, // Either aborted or committed. 73 COMMITTING, // In the process of committing, possibly waiting for blobs
74 // to be written.
75 FINISHED, // Either aborted or committed.
73 }; 76 };
74 77
75 State state() const { return state_; } 78 State state() const { return state_; }
76 bool IsTimeoutTimerRunning() const { return timeout_timer_.IsRunning(); } 79 bool IsTimeoutTimerRunning() const { return timeout_timer_.IsRunning(); }
77 80
78 struct Diagnostics { 81 struct Diagnostics {
79 base::Time creation_time; 82 base::Time creation_time;
80 base::Time start_time; 83 base::Time start_time;
81 int tasks_scheduled; 84 int tasks_scheduled;
82 int tasks_completed; 85 int tasks_completed;
83 }; 86 };
84 87
85 const Diagnostics& diagnostics() const { return diagnostics_; } 88 const Diagnostics& diagnostics() const { return diagnostics_; }
86 89
87 private: 90 private:
91 friend class BlobWriteCallbackImpl;
92
88 FRIEND_TEST_ALL_PREFIXES(IndexedDBTransactionTestMode, AbortPreemptive); 93 FRIEND_TEST_ALL_PREFIXES(IndexedDBTransactionTestMode, AbortPreemptive);
89 FRIEND_TEST_ALL_PREFIXES(IndexedDBTransactionTest, Timeout); 94 FRIEND_TEST_ALL_PREFIXES(IndexedDBTransactionTest, Timeout);
90 FRIEND_TEST_ALL_PREFIXES(IndexedDBTransactionTest, 95 FRIEND_TEST_ALL_PREFIXES(IndexedDBTransactionTest,
91 SchedulePreemptiveTask); 96 SchedulePreemptiveTask);
92 FRIEND_TEST_ALL_PREFIXES(IndexedDBTransactionTestMode, 97 FRIEND_TEST_ALL_PREFIXES(IndexedDBTransactionTestMode,
93 ScheduleNormalTask); 98 ScheduleNormalTask);
94 99
95 friend class base::RefCounted<IndexedDBTransaction>; 100 friend class base::RefCounted<IndexedDBTransaction>;
96 virtual ~IndexedDBTransaction(); 101 virtual ~IndexedDBTransaction();
97 102
98 void RunTasksIfStarted(); 103 void RunTasksIfStarted();
99 104
100 bool IsTaskQueueEmpty() const; 105 bool IsTaskQueueEmpty() const;
101 bool HasPendingTasks() const; 106 bool HasPendingTasks() const;
102 107
108 void BlobWriteComplete(bool success);
103 void ProcessTaskQueue(); 109 void ProcessTaskQueue();
104 void CloseOpenCursors(); 110 void CloseOpenCursors();
111 void CommitPhaseTwo();
105 void Timeout(); 112 void Timeout();
106 113
107 const int64 id_; 114 const int64 id_;
108 const std::set<int64> object_store_ids_; 115 const std::set<int64> object_store_ids_;
109 const indexed_db::TransactionMode mode_; 116 const indexed_db::TransactionMode mode_;
110 117
111 bool used_; 118 bool used_;
112 State state_; 119 State state_;
113 bool commit_pending_; 120 bool commit_pending_;
114 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks_; 121 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks_;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 // requests are processed before the timer fires, assume the script is 163 // requests are processed before the timer fires, assume the script is
157 // unresponsive and abort to unblock the transaction queue. 164 // unresponsive and abort to unblock the transaction queue.
158 base::OneShotTimer<IndexedDBTransaction> timeout_timer_; 165 base::OneShotTimer<IndexedDBTransaction> timeout_timer_;
159 166
160 Diagnostics diagnostics_; 167 Diagnostics diagnostics_;
161 }; 168 };
162 169
163 } // namespace content 170 } // namespace content
164 171
165 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_H_ 172 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_H_
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_leveldb_coding.h ('k') | content/browser/indexed_db/indexed_db_transaction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698