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

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: rebased & working 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_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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 IndexedDBDispatcherHost(int ipc_process_id, 44 IndexedDBDispatcherHost(int ipc_process_id,
45 net::URLRequestContextGetter* request_context_getter, 45 net::URLRequestContextGetter* request_context_getter,
46 IndexedDBContextImpl* indexed_db_context, 46 IndexedDBContextImpl* indexed_db_context,
47 ChromeBlobStorageContext* blob_storage_context); 47 ChromeBlobStorageContext* blob_storage_context);
48 48
49 // BrowserMessageFilter implementation. 49 // BrowserMessageFilter implementation.
50 void OnChannelClosing() override; 50 void OnChannelClosing() override;
51 void OnDestruct() const override; 51 void OnDestruct() const override;
52 bool OnMessageReceived(const IPC::Message& message) override; 52 bool OnMessageReceived(const IPC::Message& message) override;
53 53
54 void FinishTransaction(int64_t host_transaction_id, bool committed); 54 void NotifyTransactionCommitted(const url::Origin& transaction_origin);
55 55
56 // A shortcut for accessing our context. 56 // A shortcut for accessing our context.
57 IndexedDBContextImpl* context() const { return indexed_db_context_.get(); } 57 IndexedDBContextImpl* context() const { return indexed_db_context_.get(); }
58 storage::BlobStorageContext* blob_storage_context() const { 58 storage::BlobStorageContext* blob_storage_context() const {
59 return blob_storage_context_->context(); 59 return blob_storage_context_->context();
60 } 60 }
61 int ipc_process_id() const { return ipc_process_id_; } 61 int ipc_process_id() const { return ipc_process_id_; }
62 62
63 bool RegisterTransactionId(int64_t host_transaction_id,
64 const url::Origin& origin);
65 bool GetTransactionSize(int64_t host_transaction_id,
66 int64_t* transaction_size);
67 void AddToTransaction(int64_t host_transaction_id, int64_t value_length);
68
69 // These are called to map a 32-bit front-end (renderer-specific) transaction
70 // id to and from a back-end ("host") transaction id that encodes the process
71 // id in the high 32 bits. The mapping is host-specific and ids are validated.
72 int64_t HostTransactionId(int64_t transaction_id);
73 int64_t RendererTransactionId(int64_t host_transaction_id);
74
75 // These are called to decode a host transaction ID, for diagnostic purposes.
76 static uint32_t TransactionIdToRendererTransactionId(
77 int64_t host_transaction_id);
78 static uint32_t TransactionIdToProcessId(int64_t host_transaction_id);
79
80 std::string HoldBlobData(const IndexedDBBlobInfo& blob_info); 63 std::string HoldBlobData(const IndexedDBBlobInfo& blob_info);
81 void DropBlobData(const std::string& uuid); 64 void DropBlobData(const std::string& uuid);
82 65
83 // True if the channel is closing/closed and outstanding requests 66 // True if the channel is closing/closed and outstanding requests
84 // can be abandoned. Only access on IndexedDB thread. 67 // can be abandoned. Only access on IndexedDB thread.
85 bool IsOpen() const; 68 bool IsOpen() const;
86 69
87 private: 70 private:
88 // Friends to enable OnDestruct() delegation. 71 // Friends to enable OnDestruct() delegation.
89 friend class BrowserThread; 72 friend class BrowserThread;
90 friend class base::DeleteHelper<IndexedDBDispatcherHost>; 73 friend class base::DeleteHelper<IndexedDBDispatcherHost>;
91 74
92 // Used in nested classes.
93 typedef std::map<int64_t, int64_t> TransactionIDToSizeMap;
94 typedef std::map<int64_t, url::Origin> TransactionIDToOriginMap;
95
96 ~IndexedDBDispatcherHost() override; 75 ~IndexedDBDispatcherHost() override;
97 76
98 // indexed_db::mojom::Factory implementation: 77 // indexed_db::mojom::Factory implementation:
99 void GetDatabaseNames( 78 void GetDatabaseNames(
100 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info, 79 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info,
101 const url::Origin& origin) override; 80 const url::Origin& origin) override;
102 void Open(::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info, 81 void Open(::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info,
103 ::indexed_db::mojom::DatabaseCallbacksAssociatedPtrInfo 82 ::indexed_db::mojom::DatabaseCallbacksAssociatedPtrInfo
104 database_callbacks_info, 83 database_callbacks_info,
105 const url::Origin& origin, 84 const url::Origin& origin,
(...skipping 26 matching lines...) Expand all
132 111
133 // Maps blob uuid to a pair (handle, ref count). Entry is added and/or count 112 // Maps blob uuid to a pair (handle, ref count). Entry is added and/or count
134 // is incremented in HoldBlobData(), and count is decremented and/or entry 113 // is incremented in HoldBlobData(), and count is decremented and/or entry
135 // removed in DropBlobData(). 114 // removed in DropBlobData().
136 std::map<std::string, 115 std::map<std::string,
137 std::pair<std::unique_ptr<storage::BlobDataHandle>, int>> 116 std::pair<std::unique_ptr<storage::BlobDataHandle>, int>>
138 blob_data_handle_map_; 117 blob_data_handle_map_;
139 118
140 // Only access on IndexedDB thread. 119 // Only access on IndexedDB thread.
141 bool is_open_ = true; 120 bool is_open_ = true;
142 TransactionIDToSizeMap transaction_size_map_;
143 TransactionIDToOriginMap transaction_origin_map_;
144 121
145 // Used to set file permissions for blob storage. 122 // Used to set file permissions for blob storage.
146 int ipc_process_id_; 123 int ipc_process_id_;
147 124
148 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost); 125 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost);
149 }; 126 };
150 127
151 } // namespace content 128 } // namespace content
152 129
153 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DISPATCHER_HOST_H_ 130 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DISPATCHER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698