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

Unified 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: comments & rebase 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/indexed_db/indexed_db_dispatcher_host.h
diff --git a/content/browser/indexed_db/indexed_db_dispatcher_host.h b/content/browser/indexed_db/indexed_db_dispatcher_host.h
index 5a77838ad928238be4d754ebf61e5715fe54d7aa..f112b711f923927aa6e43bb7268bfb6fb43efcd6 100644
--- a/content/browser/indexed_db/indexed_db_dispatcher_host.h
+++ b/content/browser/indexed_db/indexed_db_dispatcher_host.h
@@ -82,7 +82,7 @@ class IndexedDBDispatcherHost
const IPC::Message& message) override;
bool OnMessageReceived(const IPC::Message& message) override;
- void FinishTransaction(int64_t host_transaction_id, bool committed);
+ void FinishTransaction(const url::Origin& transaction_origin, bool committed);
// A shortcut for accessing our context.
IndexedDBContextImpl* context() const { return indexed_db_context_.get(); }
@@ -92,26 +92,12 @@ class IndexedDBDispatcherHost
// IndexedDBCallbacks call these methods to add the results into the
// applicable map. See below for more details.
- int32_t Add(IndexedDBCursor* cursor);
- int32_t Add(IndexedDBConnection* connection,
+ int32_t Add(std::unique_ptr<IndexedDBCursor> cursor);
+ int32_t Add(std::unique_ptr<IndexedDBConnection> connection,
const url::Origin& origin);
- void RegisterTransactionId(int64_t host_transaction_id,
- const url::Origin& origin);
-
IndexedDBCursor* GetCursorFromId(int32_t ipc_cursor_id);
- // These are called to map a 32-bit front-end (renderer-specific) transaction
- // id to and from a back-end ("host") transaction id that encodes the process
- // id in the high 32 bits. The mapping is host-specific and ids are validated.
- int64_t HostTransactionId(int64_t transaction_id);
- int64_t RendererTransactionId(int64_t host_transaction_id);
-
- // These are called to decode a host transaction ID, for diagnostic purposes.
- static uint32_t TransactionIdToRendererTransactionId(
- int64_t host_transaction_id);
- static uint32_t TransactionIdToProcessId(int64_t host_transaction_id);
-
std::string HoldBlobData(const IndexedDBBlobInfo& blob_info);
// True if the channel is closing/closed and outstanding requests
@@ -124,43 +110,8 @@ class IndexedDBDispatcherHost
friend class base::DeleteHelper<IndexedDBDispatcherHost>;
// Used in nested classes.
- typedef std::map<int64_t, int64_t> TransactionIDToDatabaseIDMap;
- typedef std::map<int64_t, uint64_t> TransactionIDToSizeMap;
- typedef std::map<int64_t, url::Origin> TransactionIDToOriginMap;
typedef std::map<int32_t, url::Origin> WebIDBObjectIDToOriginMap;
- // IDMap for RefCounted types
- template <typename RefCountedType>
- class RefIDMap {
- public:
- typedef int32_t KeyType;
-
- RefIDMap() {}
- ~RefIDMap() {}
-
- KeyType Add(RefCountedType* data) {
- return map_.Add(new scoped_refptr<RefCountedType>(data));
- }
-
- RefCountedType* Lookup(KeyType id) {
- scoped_refptr<RefCountedType>* ptr = map_.Lookup(id);
- if (ptr == NULL)
- return NULL;
- return ptr->get();
- }
-
- void Remove(KeyType id) { map_.Remove(id); }
-
- void set_check_on_null_data(bool value) {
- map_.set_check_on_null_data(value);
- }
-
- private:
- IDMap<scoped_refptr<RefCountedType>, IDMapOwnPointer> map_;
-
- DISALLOW_COPY_AND_ASSIGN(RefIDMap);
- };
-
class DatabaseDispatcherHost {
public:
explicit DatabaseDispatcherHost(IndexedDBDispatcherHost* parent);
@@ -233,9 +184,6 @@ class IndexedDBDispatcherHost
IndexedDBDispatcherHost* parent_;
IDMap<IndexedDBConnection, IDMapOwnPointer> map_;
WebIDBObjectIDToOriginMap database_origin_map_;
- TransactionIDToSizeMap transaction_size_map_;
- TransactionIDToOriginMap transaction_origin_map_;
- TransactionIDToDatabaseIDMap transaction_database_map_;
// Weak pointers are used when an asynchronous quota request is made, in
// case the dispatcher is torn down before the response returns.
@@ -271,7 +219,7 @@ class IndexedDBDispatcherHost
void OnDestroyed(int32_t ipc_cursor_id);
IndexedDBDispatcherHost* parent_;
- RefIDMap<IndexedDBCursor> map_;
+ IDMap<IndexedDBCursor, IDMapOwnPointer> map_;
private:
DISALLOW_COPY_AND_ASSIGN(CursorDispatcherHost);
@@ -283,9 +231,6 @@ class IndexedDBDispatcherHost
template <class ReturnType>
ReturnType* GetOrTerminateProcess(IDMap<ReturnType, IDMapOwnPointer>* map,
int32_t ipc_return_object_id);
- template <class ReturnType>
- ReturnType* GetOrTerminateProcess(RefIDMap<ReturnType>* map,
- int32_t ipc_return_object_id);
template <typename MapType>
void DestroyObject(MapType* map, int32_t ipc_object_id);

Powered by Google App Engine
This is Rietveld 408576698