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

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

Issue 2472213003: [IndexedDB] Refactoring to remove ref ptrs and host transaction ids. (Closed)
Patch Set: rebase Created 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_CALLBACKS_H_ 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_H_
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_H_ 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 13 matching lines...) Expand all
24 #include "url/origin.h" 24 #include "url/origin.h"
25 25
26 namespace content { 26 namespace content {
27 class IndexedDBBlobInfo; 27 class IndexedDBBlobInfo;
28 class IndexedDBConnection; 28 class IndexedDBConnection;
29 class IndexedDBCursor; 29 class IndexedDBCursor;
30 class IndexedDBDatabase; 30 class IndexedDBDatabase;
31 struct IndexedDBDataLossInfo; 31 struct IndexedDBDataLossInfo;
32 struct IndexedDBDatabaseMetadata; 32 struct IndexedDBDatabaseMetadata;
33 struct IndexedDBReturnValue; 33 struct IndexedDBReturnValue;
34 class IndexedDBTransaction;
34 struct IndexedDBValue; 35 struct IndexedDBValue;
35 36
36 class CONTENT_EXPORT IndexedDBCallbacks 37 class CONTENT_EXPORT IndexedDBCallbacks
37 : public base::RefCounted<IndexedDBCallbacks> { 38 : public base::RefCounted<IndexedDBCallbacks> {
38 public: 39 public:
39 IndexedDBCallbacks( 40 IndexedDBCallbacks(
40 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host, 41 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host,
41 const url::Origin& origin, 42 const url::Origin& origin,
42 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info); 43 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info);
43 44
44 virtual void OnError(const IndexedDBDatabaseError& error); 45 virtual void OnError(const IndexedDBDatabaseError& error);
45 46
46 // IndexedDBFactory::GetDatabaseNames 47 // IndexedDBFactory::GetDatabaseNames
47 virtual void OnSuccess(const std::vector<base::string16>& string); 48 virtual void OnSuccess(const std::vector<base::string16>& string);
48 49
49 // IndexedDBFactory::Open / DeleteDatabase 50 // IndexedDBFactory::Open / DeleteDatabase
50 virtual void OnBlocked(int64_t existing_version); 51 virtual void OnBlocked(int64_t existing_version);
51 52
52 // IndexedDBFactory::Open 53 // IndexedDBFactory::Open
53 virtual void OnUpgradeNeeded( 54 virtual void OnUpgradeNeeded(
54 int64_t old_version, 55 int64_t old_version,
55 std::unique_ptr<IndexedDBConnection> connection, 56 std::unique_ptr<IndexedDBConnection> connection,
57 IndexedDBTransaction* transaction,
56 const content::IndexedDBDatabaseMetadata& metadata, 58 const content::IndexedDBDatabaseMetadata& metadata,
57 const IndexedDBDataLossInfo& data_loss_info); 59 const IndexedDBDataLossInfo& data_loss_info);
58 virtual void OnSuccess(std::unique_ptr<IndexedDBConnection> connection, 60 virtual void OnSuccess(std::unique_ptr<IndexedDBConnection> connection,
59 const content::IndexedDBDatabaseMetadata& metadata); 61 const content::IndexedDBDatabaseMetadata& metadata);
60 62
61 // IndexedDBDatabase::OpenCursor 63 // IndexedDBDatabase::OpenCursor
62 virtual void OnSuccess(scoped_refptr<IndexedDBCursor> cursor, 64 virtual void OnSuccess(std::unique_ptr<IndexedDBCursor> cursor,
63 const IndexedDBKey& key, 65 const IndexedDBKey& key,
64 const IndexedDBKey& primary_key, 66 const IndexedDBKey& primary_key,
65 IndexedDBValue* value); 67 IndexedDBValue* value);
66 68
67 // IndexedDBCursor::Continue / Advance 69 // IndexedDBCursor::Continue / Advance
68 virtual void OnSuccess(const IndexedDBKey& key, 70 virtual void OnSuccess(const IndexedDBKey& key,
69 const IndexedDBKey& primary_key, 71 const IndexedDBKey& primary_key,
70 IndexedDBValue* value); 72 IndexedDBValue* value);
71 73
72 // IndexedDBCursor::PrefetchContinue 74 // IndexedDBCursor::PrefetchContinue
(...skipping 19 matching lines...) Expand all
92 94
93 // IndexedDBCursor::Continue / Advance (when complete) 95 // IndexedDBCursor::Continue / Advance (when complete)
94 virtual void OnSuccess(); 96 virtual void OnSuccess();
95 97
96 // Checks to see if the associated dispatcher host is still connected. If 98 // Checks to see if the associated dispatcher host is still connected. If
97 // not this request can be dropped. 99 // not this request can be dropped.
98 virtual bool IsValid() const; 100 virtual bool IsValid() const;
99 101
100 void SetConnectionOpenStartTime(const base::TimeTicks& start_time); 102 void SetConnectionOpenStartTime(const base::TimeTicks& start_time);
101 103
102 void set_host_transaction_id(int64_t host_transaction_id) {
103 host_transaction_id_ = host_transaction_id;
104 }
105
106 protected: 104 protected:
107 virtual ~IndexedDBCallbacks(); 105 virtual ~IndexedDBCallbacks();
108 106
109 private: 107 private:
110 void RegisterBlobsAndSend(const std::vector<IndexedDBBlobInfo>& blob_info, 108 void RegisterBlobsAndSend(const std::vector<IndexedDBBlobInfo>& blob_info,
111 const base::Closure& callback); 109 const base::Closure& callback);
112 110
113 friend class base::RefCounted<IndexedDBCallbacks>; 111 friend class base::RefCounted<IndexedDBCallbacks>;
114 112
115 class IOThreadHelper; 113 class IOThreadHelper;
116 114
117 // Originally from IndexedDBCallbacks: 115 // Originally from IndexedDBCallbacks:
118 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host_; 116 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host_;
119 117
120 // IndexedDBDatabase callbacks ------------------------ 118 // IndexedDBDatabase callbacks ------------------------
121 int64_t host_transaction_id_;
122 url::Origin origin_; 119 url::Origin origin_;
123 bool database_sent_ = false; 120 bool database_sent_ = false;
124 121
125 // Used to assert that OnSuccess is only called if there was no data loss. 122 // Used to assert that OnSuccess is only called if there was no data loss.
126 blink::WebIDBDataLoss data_loss_; 123 blink::WebIDBDataLoss data_loss_;
127 124
128 // The "blocked" event should be sent at most once per request. 125 // The "blocked" event should be sent at most once per request.
129 bool sent_blocked_; 126 bool sent_blocked_;
130 base::TimeTicks connection_open_start_time_; 127 base::TimeTicks connection_open_start_time_;
131 128
132 std::unique_ptr<IOThreadHelper, BrowserThread::DeleteOnIOThread> io_helper_; 129 std::unique_ptr<IOThreadHelper, BrowserThread::DeleteOnIOThread> io_helper_;
133 base::ThreadChecker thread_checker_; 130 base::ThreadChecker thread_checker_;
134 131
135 DISALLOW_COPY_AND_ASSIGN(IndexedDBCallbacks); 132 DISALLOW_COPY_AND_ASSIGN(IndexedDBCallbacks);
136 }; 133 };
137 134
138 } // namespace content 135 } // namespace content
139 136
140 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_H_ 137 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698