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

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: Handle the rest of Josh's feedback. 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 // 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 "content/browser/indexed_db/indexed_db_backing_store.h" 16 #include "content/browser/indexed_db/indexed_db_backing_store.h"
17 #include "content/browser/indexed_db/indexed_db_database.h" 17 #include "content/browser/indexed_db/indexed_db_database.h"
18 #include "content/browser/indexed_db/indexed_db_database_error.h" 18 #include "content/browser/indexed_db/indexed_db_database_error.h"
19 19
20 namespace content { 20 namespace content {
21 21
22 class BlobWriteCallbackImpl;
22 class IndexedDBCursor; 23 class IndexedDBCursor;
23 class IndexedDBDatabaseCallbacks; 24 class IndexedDBDatabaseCallbacks;
24 25
25 class IndexedDBTransaction : public base::RefCounted<IndexedDBTransaction> { 26 class IndexedDBTransaction : public base::RefCounted<IndexedDBTransaction> {
26 public: 27 public:
27 typedef base::Callback<void(IndexedDBTransaction*)> Operation; 28 typedef base::Callback<void(IndexedDBTransaction*)> Operation;
28 29
29 IndexedDBTransaction(int64 id, 30 IndexedDBTransaction(int64 id,
30 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks, 31 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks,
31 const std::set<int64>& object_store_ids, 32 const std::set<int64>& object_store_ids,
(...skipping 24 matching lines...) Expand all
56 } 57 }
57 IndexedDBBackingStore::Transaction* BackingStoreTransaction() { 58 IndexedDBBackingStore::Transaction* BackingStoreTransaction() {
58 return &transaction_; 59 return &transaction_;
59 } 60 }
60 int64 id() const { return id_; } 61 int64 id() const { return id_; }
61 62
62 IndexedDBDatabase* database() const { return database_; } 63 IndexedDBDatabase* database() const { return database_; }
63 IndexedDBDatabaseCallbacks* connection() const { return callbacks_; } 64 IndexedDBDatabaseCallbacks* connection() const { return callbacks_; }
64 65
65 enum State { 66 enum State {
66 CREATED, // Created, but not yet started by coordinator. 67 CREATED, // Created, but not yet started by coordinator.
67 STARTED, // Started by the coordinator. 68 STARTED, // Started by the coordinator.
68 FINISHED, // Either aborted or committed. 69 COMMITTING, // In the process of committing, possibly waiting for blobs
70 // to be written.
71 FINISHED, // Either aborted or committed.
69 }; 72 };
70 73
71 State state() const { return state_; } 74 State state() const { return state_; }
72 75
73 struct Diagnostics { 76 struct Diagnostics {
74 base::Time creation_time; 77 base::Time creation_time;
75 base::Time start_time; 78 base::Time start_time;
76 int tasks_scheduled; 79 int tasks_scheduled;
77 int tasks_completed; 80 int tasks_completed;
78 }; 81 };
79 82
80 const Diagnostics& diagnostics() const { return diagnostics_; } 83 const Diagnostics& diagnostics() const { return diagnostics_; }
81 84
82 private: 85 private:
86 friend class BlobWriteCallbackImpl;
87
88 // TODO(ericu): Report this on the internals page.
89 bool IsStatePastRunning() const {
jsbell 2013/12/20 00:44:20 Nit: The "Running" terminology is dropped (to try
ericu 2014/02/20 00:50:29 Done.
90 return state_ == COMMITTING || state_ == FINISHED;
91 }
83 friend class base::RefCounted<IndexedDBTransaction>; 92 friend class base::RefCounted<IndexedDBTransaction>;
84 virtual ~IndexedDBTransaction(); 93 virtual ~IndexedDBTransaction();
85 94
86 void RunTasksIfStarted(); 95 void RunTasksIfStarted();
87 96
88 bool IsTaskQueueEmpty() const; 97 bool IsTaskQueueEmpty() const;
89 bool HasPendingTasks() const; 98 bool HasPendingTasks() const;
90 99
100 void BlobWriteComplete(bool success);
91 void ProcessTaskQueue(); 101 void ProcessTaskQueue();
92 void CloseOpenCursors(); 102 void CloseOpenCursors();
103 void CommitPhaseTwo();
93 104
94 const int64 id_; 105 const int64 id_;
95 const std::set<int64> object_store_ids_; 106 const std::set<int64> object_store_ids_;
96 const indexed_db::TransactionMode mode_; 107 const indexed_db::TransactionMode mode_;
97 108
98 bool used_; 109 bool used_;
99 State state_; 110 State state_;
100 bool commit_pending_; 111 bool commit_pending_;
112 bool blob_write_success_;
jsbell 2013/12/20 00:44:20 This looks like it's unused now?
ericu 2014/02/20 00:50:29 Done.
101 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks_; 113 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks_;
102 scoped_refptr<IndexedDBDatabase> database_; 114 scoped_refptr<IndexedDBDatabase> database_;
103 115
104 class TaskQueue { 116 class TaskQueue {
105 public: 117 public:
106 TaskQueue(); 118 TaskQueue();
107 ~TaskQueue(); 119 ~TaskQueue();
108 bool empty() const { return queue_.empty(); } 120 bool empty() const { return queue_.empty(); }
109 void push(Operation task) { queue_.push(task); } 121 void push(Operation task) { queue_.push(task); }
110 Operation pop(); 122 Operation pop();
(...skipping 26 matching lines...) Expand all
137 bool should_process_queue_; 149 bool should_process_queue_;
138 int pending_preemptive_events_; 150 int pending_preemptive_events_;
139 151
140 std::set<IndexedDBCursor*> open_cursors_; 152 std::set<IndexedDBCursor*> open_cursors_;
141 Diagnostics diagnostics_; 153 Diagnostics diagnostics_;
142 }; 154 };
143 155
144 } // namespace content 156 } // namespace content
145 157
146 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_H_ 158 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_TRANSACTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698