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

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

Issue 2472213003: [IndexedDB] Refactoring to remove ref ptrs and host transaction ids. (Closed)
Patch Set: updated unittests Created 4 years, 1 month 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_DISPATCHER_HOST_H_ 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DISPATCHER_HOST_H_
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DISPATCHER_HOST_H_ 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DISPATCHER_HOST_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 static IndexedDBMsg_Observation ConvertObservation( 80 static IndexedDBMsg_Observation ConvertObservation(
81 const IndexedDBObservation* observation); 81 const IndexedDBObservation* observation);
82 82
83 // BrowserMessageFilter implementation. 83 // BrowserMessageFilter implementation.
84 void OnChannelClosing() override; 84 void OnChannelClosing() override;
85 void OnDestruct() const override; 85 void OnDestruct() const override;
86 base::TaskRunner* OverrideTaskRunnerForMessage( 86 base::TaskRunner* OverrideTaskRunnerForMessage(
87 const IPC::Message& message) override; 87 const IPC::Message& message) override;
88 bool OnMessageReceived(const IPC::Message& message) override; 88 bool OnMessageReceived(const IPC::Message& message) override;
89 89
90 void FinishTransaction(int64_t host_transaction_id, bool committed); 90 void FinishTransaction(url::Origin transaction_origin, bool committed);
cmumford 2016/11/04 23:33:12 It looks like the Transaction from which this orig
dmurph 2016/11/07 20:05:23 Done.
91 91
92 // A shortcut for accessing our context. 92 // A shortcut for accessing our context.
93 IndexedDBContextImpl* context() const { return indexed_db_context_.get(); } 93 IndexedDBContextImpl* context() const { return indexed_db_context_.get(); }
94 storage::BlobStorageContext* blob_storage_context() const { 94 storage::BlobStorageContext* blob_storage_context() const {
95 return blob_storage_context_->context(); 95 return blob_storage_context_->context();
96 } 96 }
97 97
98 // IndexedDBCallbacks call these methods to add the results into the 98 // IndexedDBCallbacks call these methods to add the results into the
99 // applicable map. See below for more details. 99 // applicable map. See below for more details.
100 int32_t Add(IndexedDBCursor* cursor); 100 int32_t Add(std::unique_ptr<IndexedDBCursor> cursor);
101 int32_t Add(IndexedDBConnection* connection, 101 int32_t Add(IndexedDBConnection* connection,
102 const url::Origin& origin); 102 const url::Origin& origin);
103 103
104 void RegisterTransactionId(int64_t host_transaction_id,
105 const url::Origin& origin);
106
107 IndexedDBCursor* GetCursorFromId(int32_t ipc_cursor_id); 104 IndexedDBCursor* GetCursorFromId(int32_t ipc_cursor_id);
108 105
109 // These are called to map a 32-bit front-end (renderer-specific) transaction
110 // id to and from a back-end ("host") transaction id that encodes the process
111 // id in the high 32 bits. The mapping is host-specific and ids are validated.
112 int64_t HostTransactionId(int64_t transaction_id);
113 int64_t RendererTransactionId(int64_t host_transaction_id);
114
115 // These are called to decode a host transaction ID, for diagnostic purposes.
116 static uint32_t TransactionIdToRendererTransactionId(
117 int64_t host_transaction_id);
118 static uint32_t TransactionIdToProcessId(int64_t host_transaction_id);
119
120 std::string HoldBlobData(const IndexedDBBlobInfo& blob_info); 106 std::string HoldBlobData(const IndexedDBBlobInfo& blob_info);
121 107
122 // True if the channel is closing/closed and outstanding requests 108 // True if the channel is closing/closed and outstanding requests
123 // can be abandoned. Only access on IndexedDB thread. 109 // can be abandoned. Only access on IndexedDB thread.
124 bool IsOpen() const; 110 bool IsOpen() const;
125 111
126 private: 112 private:
127 // Friends to enable OnDestruct() delegation. 113 // Friends to enable OnDestruct() delegation.
128 friend class BrowserThread; 114 friend class BrowserThread;
129 friend class base::DeleteHelper<IndexedDBDispatcherHost>; 115 friend class base::DeleteHelper<IndexedDBDispatcherHost>;
130 116
131 // Used in nested classes. 117 // Used in nested classes.
132 typedef std::map<int64_t, int64_t> TransactionIDToDatabaseIDMap;
133 typedef std::map<int64_t, uint64_t> TransactionIDToSizeMap;
134 typedef std::map<int64_t, url::Origin> TransactionIDToOriginMap;
135 typedef std::map<int32_t, url::Origin> WebIDBObjectIDToOriginMap; 118 typedef std::map<int32_t, url::Origin> WebIDBObjectIDToOriginMap;
136 119
137 // IDMap for RefCounted types 120 // IDMap for RefCounted types
138 template <typename RefCountedType> 121 template <typename RefCountedType>
139 class RefIDMap { 122 class RefIDMap {
140 public: 123 public:
141 typedef int32_t KeyType; 124 typedef int32_t KeyType;
142 125
143 RefIDMap() {} 126 RefIDMap() {}
144 ~RefIDMap() {} 127 ~RefIDMap() {}
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 void OnCommit(int32_t ipc_database_id, int64_t transaction_id); 214 void OnCommit(int32_t ipc_database_id, int64_t transaction_id);
232 void OnGotUsageAndQuotaForCommit(int32_t ipc_database_id, 215 void OnGotUsageAndQuotaForCommit(int32_t ipc_database_id,
233 int64_t transaction_id, 216 int64_t transaction_id,
234 storage::QuotaStatusCode status, 217 storage::QuotaStatusCode status,
235 int64_t usage, 218 int64_t usage,
236 int64_t quota); 219 int64_t quota);
237 220
238 IndexedDBDispatcherHost* parent_; 221 IndexedDBDispatcherHost* parent_;
239 IDMap<IndexedDBConnection, IDMapOwnPointer> map_; 222 IDMap<IndexedDBConnection, IDMapOwnPointer> map_;
240 WebIDBObjectIDToOriginMap database_origin_map_; 223 WebIDBObjectIDToOriginMap database_origin_map_;
241 TransactionIDToSizeMap transaction_size_map_;
242 TransactionIDToOriginMap transaction_origin_map_;
243 TransactionIDToDatabaseIDMap transaction_database_map_;
244 224
245 // Weak pointers are used when an asynchronous quota request is made, in 225 // Weak pointers are used when an asynchronous quota request is made, in
246 // case the dispatcher is torn down before the response returns. 226 // case the dispatcher is torn down before the response returns.
247 base::WeakPtrFactory<DatabaseDispatcherHost> weak_factory_; 227 base::WeakPtrFactory<DatabaseDispatcherHost> weak_factory_;
248 228
249 private: 229 private:
250 DISALLOW_COPY_AND_ASSIGN(DatabaseDispatcherHost); 230 DISALLOW_COPY_AND_ASSIGN(DatabaseDispatcherHost);
251 }; 231 };
252 232
253 class CursorDispatcherHost { 233 class CursorDispatcherHost {
(...skipping 15 matching lines...) Expand all
269 void OnPrefetch(int32_t ipc_cursor_id, 249 void OnPrefetch(int32_t ipc_cursor_id,
270 int32_t ipc_thread_id, 250 int32_t ipc_thread_id,
271 int32_t ipc_callbacks_id, 251 int32_t ipc_callbacks_id,
272 int n); 252 int n);
273 void OnPrefetchReset(int32_t ipc_cursor_id, 253 void OnPrefetchReset(int32_t ipc_cursor_id,
274 int used_prefetches, 254 int used_prefetches,
275 int unused_prefetches); 255 int unused_prefetches);
276 void OnDestroyed(int32_t ipc_cursor_id); 256 void OnDestroyed(int32_t ipc_cursor_id);
277 257
278 IndexedDBDispatcherHost* parent_; 258 IndexedDBDispatcherHost* parent_;
279 RefIDMap<IndexedDBCursor> map_; 259 IDMap<IndexedDBCursor, IDMapOwnPointer> map_;
280 260
281 private: 261 private:
282 DISALLOW_COPY_AND_ASSIGN(CursorDispatcherHost); 262 DISALLOW_COPY_AND_ASSIGN(CursorDispatcherHost);
283 }; 263 };
284 264
285 ~IndexedDBDispatcherHost() override; 265 ~IndexedDBDispatcherHost() override;
286 266
287 // Helper templates. 267 // Helper templates.
288 template <class ReturnType> 268 template <class ReturnType>
289 ReturnType* GetOrTerminateProcess(IDMap<ReturnType, IDMapOwnPointer>* map, 269 ReturnType* GetOrTerminateProcess(IDMap<ReturnType, IDMapOwnPointer>* map,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 333
354 // Used to set file permissions for blob storage. 334 // Used to set file permissions for blob storage.
355 int ipc_process_id_; 335 int ipc_process_id_;
356 336
357 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost); 337 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost);
358 }; 338 };
359 339
360 } // namespace content 340 } // namespace content
361 341
362 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DISPATCHER_HOST_H_ 342 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DISPATCHER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698