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

Side by Side Diff: content/child/indexed_db/indexed_db_dispatcher.h

Issue 2062203004: IDBObserver: Lifetime Management: Adding Observer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Post dmurph review Created 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_ 5 #ifndef CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_
6 #define CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_ 6 #define CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 18 matching lines...) Expand all
29 29
30 struct IndexedDBDatabaseMetadata; 30 struct IndexedDBDatabaseMetadata;
31 struct IndexedDBMsg_CallbacksSuccessCursorContinue_Params; 31 struct IndexedDBMsg_CallbacksSuccessCursorContinue_Params;
32 struct IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params; 32 struct IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params;
33 struct IndexedDBMsg_CallbacksSuccessIDBCursor_Params; 33 struct IndexedDBMsg_CallbacksSuccessIDBCursor_Params;
34 struct IndexedDBMsg_CallbacksSuccessArray_Params; 34 struct IndexedDBMsg_CallbacksSuccessArray_Params;
35 struct IndexedDBMsg_CallbacksSuccessValue_Params; 35 struct IndexedDBMsg_CallbacksSuccessValue_Params;
36 struct IndexedDBMsg_CallbacksUpgradeNeeded_Params; 36 struct IndexedDBMsg_CallbacksUpgradeNeeded_Params;
37 37
38 namespace blink { 38 namespace blink {
39 class IDBObserver;
39 class WebData; 40 class WebData;
40 } 41 }
41 42
42 namespace content { 43 namespace content {
43 class IndexedDBKey; 44 class IndexedDBKey;
44 class IndexedDBKeyPath; 45 class IndexedDBKeyPath;
45 class IndexedDBKeyRange; 46 class IndexedDBKeyRange;
46 class WebIDBCursorImpl; 47 class WebIDBCursorImpl;
47 class WebIDBDatabaseImpl; 48 class WebIDBDatabaseImpl;
48 class ThreadSafeSender; 49 class ThreadSafeSender;
(...skipping 18 matching lines...) Expand all
67 void WillStopCurrentWorkerThread() override; 68 void WillStopCurrentWorkerThread() override;
68 69
69 static blink::WebIDBMetadata ConvertMetadata( 70 static blink::WebIDBMetadata ConvertMetadata(
70 const IndexedDBDatabaseMetadata& idb_metadata); 71 const IndexedDBDatabaseMetadata& idb_metadata);
71 72
72 void OnMessageReceived(const IPC::Message& msg); 73 void OnMessageReceived(const IPC::Message& msg);
73 74
74 // This method is virtual so it can be overridden in unit tests. 75 // This method is virtual so it can be overridden in unit tests.
75 virtual bool Send(IPC::Message* msg); 76 virtual bool Send(IPC::Message* msg);
76 77
78 int32_t AddIDBObserver(int32_t ipc_database_id,
79 int64_t transaction_id,
80 blink::IDBObserver* observer);
81 std::vector<int32_t> RemoveIDBObserver(int32_t ipc_database_id,
82 blink::IDBObserver* observer);
83
77 void RequestIDBFactoryGetDatabaseNames(blink::WebIDBCallbacks* callbacks, 84 void RequestIDBFactoryGetDatabaseNames(blink::WebIDBCallbacks* callbacks,
78 const url::Origin& origin); 85 const url::Origin& origin);
79 86
80 void RequestIDBFactoryOpen(const base::string16& name, 87 void RequestIDBFactoryOpen(const base::string16& name,
81 int64_t version, 88 int64_t version,
82 int64_t transaction_id, 89 int64_t transaction_id,
83 blink::WebIDBCallbacks* callbacks, 90 blink::WebIDBCallbacks* callbacks,
84 blink::WebIDBDatabaseCallbacks* database_callbacks, 91 blink::WebIDBDatabaseCallbacks* database_callbacks,
85 const url::Origin& origin); 92 const url::Origin& origin);
86 93
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 void ResetCursorPrefetchCaches(int64_t transaction_id, 258 void ResetCursorPrefetchCaches(int64_t transaction_id,
252 int32_t ipc_exception_cursor_id); 259 int32_t ipc_exception_cursor_id);
253 260
254 scoped_refptr<ThreadSafeSender> thread_safe_sender_; 261 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
255 262
256 // Maximum size (in bytes) of value/key pair allowed for put requests. Any 263 // Maximum size (in bytes) of value/key pair allowed for put requests. Any
257 // requests larger than this size will be rejected. 264 // requests larger than this size will be rejected.
258 // Used by unit tests to exercise behavior without allocating huge chunks 265 // Used by unit tests to exercise behavior without allocating huge chunks
259 // of memory. 266 // of memory.
260 size_t max_put_value_size_ = kMaxIDBMessageSizeInBytes; 267 size_t max_put_value_size_ = kMaxIDBMessageSizeInBytes;
261
262 // Careful! WebIDBCallbacks wraps non-threadsafe data types. It must be 268 // Careful! WebIDBCallbacks wraps non-threadsafe data types. It must be
263 // destroyed and used on the same thread it was created on. 269 // destroyed and used on the same thread it was created on.
264 IDMap<blink::WebIDBCallbacks, IDMapOwnPointer> pending_callbacks_; 270 IDMap<blink::WebIDBCallbacks, IDMapOwnPointer> pending_callbacks_;
265 IDMap<blink::WebIDBDatabaseCallbacks, IDMapOwnPointer> 271 IDMap<blink::WebIDBDatabaseCallbacks, IDMapOwnPointer>
266 pending_database_callbacks_; 272 pending_database_callbacks_;
273 // TODO(palakj): observers_ should be IDMap<RefPtr<blink::IDBObserver>,
274 // IDMapOwnPointer> observers_.
267 275
268 // Maps the ipc_callback_id from an open cursor request to the request's 276 // Maps the ipc_callback_id from an open cursor request to the request's
269 // transaction_id. Used to assign the transaction_id to the WebIDBCursorImpl 277 // transaction_id. Used to assign the transaction_id to the WebIDBCursorImpl
270 // when it is created. 278 // when it is created.
271 std::map<int32_t, int64_t> cursor_transaction_ids_; 279 std::map<int32_t, int64_t> cursor_transaction_ids_;
272 280
273 // Map from cursor id to WebIDBCursorImpl. 281 // Map from cursor id to WebIDBCursorImpl.
274 std::map<int32_t, WebIDBCursorImpl*> cursors_; 282 std::map<int32_t, WebIDBCursorImpl*> cursors_;
275
276 std::map<int32_t, WebIDBDatabaseImpl*> databases_; 283 std::map<int32_t, WebIDBDatabaseImpl*> databases_;
284 std::map<int32_t, blink::IDBObserver*> observers_;
277 285
278 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcher); 286 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcher);
279 }; 287 };
280 288
281 } // namespace content 289 } // namespace content
282 290
283 #endif // CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_ 291 #endif // CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698