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

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

Issue 2062203004: IDBObserver: Lifetime Management: Adding Observer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding Observer 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 (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 12 matching lines...) Expand all
23 #include "storage/browser/quota/quota_manager.h" 23 #include "storage/browser/quota/quota_manager.h"
24 #include "storage/common/quota/quota_status_code.h" 24 #include "storage/common/quota/quota_status_code.h"
25 #include "url/gurl.h" 25 #include "url/gurl.h"
26 26
27 struct IndexedDBDatabaseMetadata; 27 struct IndexedDBDatabaseMetadata;
28 struct IndexedDBHostMsg_DatabaseCount_Params; 28 struct IndexedDBHostMsg_DatabaseCount_Params;
29 struct IndexedDBHostMsg_DatabaseCreateIndex_Params; 29 struct IndexedDBHostMsg_DatabaseCreateIndex_Params;
30 struct IndexedDBHostMsg_DatabaseCreateObjectStore_Params; 30 struct IndexedDBHostMsg_DatabaseCreateObjectStore_Params;
31 struct IndexedDBHostMsg_DatabaseCreateTransaction_Params; 31 struct IndexedDBHostMsg_DatabaseCreateTransaction_Params;
32 struct IndexedDBHostMsg_DatabaseDeleteRange_Params; 32 struct IndexedDBHostMsg_DatabaseDeleteRange_Params;
33 struct IndexedDBHostMsg_DatabaseObserve_Params;
33 struct IndexedDBHostMsg_DatabaseGet_Params; 34 struct IndexedDBHostMsg_DatabaseGet_Params;
34 struct IndexedDBHostMsg_DatabaseGetAll_Params; 35 struct IndexedDBHostMsg_DatabaseGetAll_Params;
35 struct IndexedDBHostMsg_DatabaseOpenCursor_Params; 36 struct IndexedDBHostMsg_DatabaseOpenCursor_Params;
36 struct IndexedDBHostMsg_DatabasePut_Params; 37 struct IndexedDBHostMsg_DatabasePut_Params;
37 struct IndexedDBHostMsg_DatabaseSetIndexKeys_Params; 38 struct IndexedDBHostMsg_DatabaseSetIndexKeys_Params;
38 struct IndexedDBHostMsg_FactoryDeleteDatabase_Params; 39 struct IndexedDBHostMsg_FactoryDeleteDatabase_Params;
39 struct IndexedDBHostMsg_FactoryGetDatabaseNames_Params; 40 struct IndexedDBHostMsg_FactoryGetDatabaseNames_Params;
40 struct IndexedDBHostMsg_FactoryOpen_Params; 41 struct IndexedDBHostMsg_FactoryOpen_Params;
41 42
42 namespace url { 43 namespace url {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // id to and from a back-end ("host") transaction id that encodes the process 102 // id to and from a back-end ("host") transaction id that encodes the process
102 // id in the high 32 bits. The mapping is host-specific and ids are validated. 103 // id in the high 32 bits. The mapping is host-specific and ids are validated.
103 int64_t HostTransactionId(int64_t transaction_id); 104 int64_t HostTransactionId(int64_t transaction_id);
104 int64_t RendererTransactionId(int64_t host_transaction_id); 105 int64_t RendererTransactionId(int64_t host_transaction_id);
105 106
106 // These are called to decode a host transaction ID, for diagnostic purposes. 107 // These are called to decode a host transaction ID, for diagnostic purposes.
107 static uint32_t TransactionIdToRendererTransactionId( 108 static uint32_t TransactionIdToRendererTransactionId(
108 int64_t host_transaction_id); 109 int64_t host_transaction_id);
109 static uint32_t TransactionIdToProcessId(int64_t host_transaction_id); 110 static uint32_t TransactionIdToProcessId(int64_t host_transaction_id);
110 111
112 // These are called to map a 32-bit front-end (renderer-specific) observer
113 // id to and from a back-end ("host") observer id that encodes the process
114 // id in the high 32 bits. The mapping is host-specific and ids are validated.
115 int64_t HostObserverId(int64_t observer_id);
dmurph 2016/06/15 12:49:43 Why do we need these? Can we just store the ipc_th
palakj1 2016/06/16 07:05:40 I see your point. Keeping connection_id and observ
dmurph 2016/06/16 07:30:33 Ah, so the thread id is always int32_t, huh. Sure,
116 int64_t RendererObserverId(int64_t host_observer_id);
117
111 std::string HoldBlobData(const IndexedDBBlobInfo& blob_info); 118 std::string HoldBlobData(const IndexedDBBlobInfo& blob_info);
112 119
113 private: 120 private:
114 // Friends to enable OnDestruct() delegation. 121 // Friends to enable OnDestruct() delegation.
115 friend class BrowserThread; 122 friend class BrowserThread;
116 friend class base::DeleteHelper<IndexedDBDispatcherHost>; 123 friend class base::DeleteHelper<IndexedDBDispatcherHost>;
117 124
118 // Used in nested classes. 125 // Used in nested classes.
119 typedef std::map<std::string, std::pair<storage::BlobDataHandle*, int>> 126 typedef std::map<std::string, std::pair<storage::BlobDataHandle*, int>>
120 BlobDataHandleMap; 127 BlobDataHandleMap;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params); 174 const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params);
168 void OnDeleteObjectStore(int32_t ipc_database_id, 175 void OnDeleteObjectStore(int32_t ipc_database_id,
169 int64_t transaction_id, 176 int64_t transaction_id,
170 int64_t object_store_id); 177 int64_t object_store_id);
171 void OnCreateTransaction( 178 void OnCreateTransaction(
172 const IndexedDBHostMsg_DatabaseCreateTransaction_Params&); 179 const IndexedDBHostMsg_DatabaseCreateTransaction_Params&);
173 void OnClose(int32_t ipc_database_id); 180 void OnClose(int32_t ipc_database_id);
174 void OnVersionChangeIgnored(int32_t ipc_database_id); 181 void OnVersionChangeIgnored(int32_t ipc_database_id);
175 void OnDestroyed(int32_t ipc_database_id); 182 void OnDestroyed(int32_t ipc_database_id);
176 183
184 void OnObserve(const IndexedDBHostMsg_DatabaseObserve_Params& params);
177 void OnGet(const IndexedDBHostMsg_DatabaseGet_Params& params); 185 void OnGet(const IndexedDBHostMsg_DatabaseGet_Params& params);
178 void OnGetAll(const IndexedDBHostMsg_DatabaseGetAll_Params& params); 186 void OnGetAll(const IndexedDBHostMsg_DatabaseGetAll_Params& params);
179 // OnPutWrapper starts on the IO thread so that it can grab BlobDataHandles 187 // OnPutWrapper starts on the IO thread so that it can grab BlobDataHandles
180 // before posting to the IDB TaskRunner for the rest of the job. 188 // before posting to the IDB TaskRunner for the rest of the job.
181 void OnPutWrapper(const IndexedDBHostMsg_DatabasePut_Params& params); 189 void OnPutWrapper(const IndexedDBHostMsg_DatabasePut_Params& params);
182 void OnPut(const IndexedDBHostMsg_DatabasePut_Params& params, 190 void OnPut(const IndexedDBHostMsg_DatabasePut_Params& params,
183 std::vector<storage::BlobDataHandle*> handles); 191 std::vector<storage::BlobDataHandle*> handles);
184 void OnSetIndexKeys( 192 void OnSetIndexKeys(
185 const IndexedDBHostMsg_DatabaseSetIndexKeys_Params& params); 193 const IndexedDBHostMsg_DatabaseSetIndexKeys_Params& params);
186 void OnSetIndexesReady(int32_t ipc_database_id, 194 void OnSetIndexesReady(int32_t ipc_database_id,
(...skipping 23 matching lines...) Expand all
210 storage::QuotaStatusCode status, 218 storage::QuotaStatusCode status,
211 int64_t usage, 219 int64_t usage,
212 int64_t quota); 220 int64_t quota);
213 221
214 IndexedDBDispatcherHost* parent_; 222 IndexedDBDispatcherHost* parent_;
215 IDMap<IndexedDBConnection, IDMapOwnPointer> map_; 223 IDMap<IndexedDBConnection, IDMapOwnPointer> map_;
216 WebIDBObjectIDToOriginMap database_origin_map_; 224 WebIDBObjectIDToOriginMap database_origin_map_;
217 TransactionIDToSizeMap transaction_size_map_; 225 TransactionIDToSizeMap transaction_size_map_;
218 TransactionIDToOriginMap transaction_origin_map_; 226 TransactionIDToOriginMap transaction_origin_map_;
219 TransactionIDToDatabaseIDMap transaction_database_map_; 227 TransactionIDToDatabaseIDMap transaction_database_map_;
228 std::vector<int64_t> observers_;
220 229
221 // Weak pointers are used when an asynchronous quota request is made, in 230 // Weak pointers are used when an asynchronous quota request is made, in
222 // case the dispatcher is torn down before the response returns. 231 // case the dispatcher is torn down before the response returns.
223 base::WeakPtrFactory<DatabaseDispatcherHost> weak_factory_; 232 base::WeakPtrFactory<DatabaseDispatcherHost> weak_factory_;
224 233
225 private: 234 private:
226 DISALLOW_COPY_AND_ASSIGN(DatabaseDispatcherHost); 235 DISALLOW_COPY_AND_ASSIGN(DatabaseDispatcherHost);
227 }; 236 };
228 237
229 class CursorDispatcherHost { 238 class CursorDispatcherHost {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; 301 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
293 net::URLRequestContext* request_context_; 302 net::URLRequestContext* request_context_;
294 scoped_refptr<IndexedDBContextImpl> indexed_db_context_; 303 scoped_refptr<IndexedDBContextImpl> indexed_db_context_;
295 scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; 304 scoped_refptr<ChromeBlobStorageContext> blob_storage_context_;
296 305
297 BlobDataHandleMap blob_data_handle_map_; 306 BlobDataHandleMap blob_data_handle_map_;
298 307
299 // Only access on IndexedDB thread. 308 // Only access on IndexedDB thread.
300 std::unique_ptr<DatabaseDispatcherHost> database_dispatcher_host_; 309 std::unique_ptr<DatabaseDispatcherHost> database_dispatcher_host_;
301 std::unique_ptr<CursorDispatcherHost> cursor_dispatcher_host_; 310 std::unique_ptr<CursorDispatcherHost> cursor_dispatcher_host_;
302
303 // Used to set file permissions for blob storage. 311 // Used to set file permissions for blob storage.
304 int ipc_process_id_; 312 int ipc_process_id_;
305 313
306 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost); 314 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost);
307 }; 315 };
308 316
309 } // namespace content 317 } // namespace content
310 318
311 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DISPATCHER_HOST_H_ 319 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DISPATCHER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698