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

Unified Diff: content/browser/indexed_db/indexed_db_dispatcher_host.cc

Issue 2472213003: [IndexedDB] Refactoring to remove ref ptrs and host transaction ids. (Closed)
Patch Set: rebase 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/indexed_db/indexed_db_dispatcher_host.cc
diff --git a/content/browser/indexed_db/indexed_db_dispatcher_host.cc b/content/browser/indexed_db/indexed_db_dispatcher_host.cc
index 7461b76efbedd12fd141a8902cfc12654f854c87..6ebacc28ed747effe83d210648ac15f724b8b5f7 100644
--- a/content/browser/indexed_db/indexed_db_dispatcher_host.cc
+++ b/content/browser/indexed_db/indexed_db_dispatcher_host.cc
@@ -20,6 +20,7 @@
#include "content/browser/indexed_db/indexed_db_context_impl.h"
#include "content/browser/indexed_db/indexed_db_database_callbacks.h"
#include "content/browser/indexed_db/indexed_db_pending_connection.h"
+#include "content/browser/indexed_db/indexed_db_transaction.h"
cmumford 2016/12/01 19:14:51 indexed_db_transaction.h not needed.
dmurph 2016/12/01 21:12:23 Done.
#include "content/browser/indexed_db/indexed_db_value.h"
#include "content/browser/renderer_host/render_message_filter.h"
#include "content/common/indexed_db/indexed_db_messages.h"
@@ -100,61 +101,6 @@ bool IndexedDBDispatcherHost::OnMessageReceived(const IPC::Message& message) {
return false;
}
-bool IndexedDBDispatcherHost::RegisterTransactionId(int64_t host_transaction_id,
- const url::Origin& origin) {
- if (base::ContainsKey(transaction_size_map_, host_transaction_id))
- return false;
- transaction_size_map_[host_transaction_id] = 0;
- transaction_origin_map_[host_transaction_id] = origin;
- return true;
-}
-
-bool IndexedDBDispatcherHost::GetTransactionSize(int64_t host_transaction_id,
- int64_t* transaction_size) {
- const auto it = transaction_size_map_.find(host_transaction_id);
- if (it == transaction_size_map_.end())
- return false;
- *transaction_size = it->second;
- return true;
-}
-
-void IndexedDBDispatcherHost::AddToTransaction(int64_t host_transaction_id,
- int64_t value_length) {
- transaction_size_map_[host_transaction_id] += value_length;
-}
-
-int64_t IndexedDBDispatcherHost::HostTransactionId(int64_t transaction_id) {
- // Inject the renderer process id into the transaction id, to
- // uniquely identify this transaction, and effectively bind it to
- // the renderer that initiated it. The lower 32 bits of
- // transaction_id are guaranteed to be unique within that renderer.
- base::ProcessId pid = peer_pid();
- DCHECK(!(transaction_id >> 32)) << "Transaction ids can only be 32 bits";
- static_assert(sizeof(base::ProcessId) <= sizeof(int32_t),
- "Process ID must fit in 32 bits");
-
- return transaction_id | (static_cast<uint64_t>(pid) << 32);
-}
-
-int64_t IndexedDBDispatcherHost::RendererTransactionId(
- int64_t host_transaction_id) {
- DCHECK(host_transaction_id >> 32 == peer_pid())
- << "Invalid renderer target for transaction id";
- return host_transaction_id & 0xffffffff;
-}
-
-// static
-uint32_t IndexedDBDispatcherHost::TransactionIdToRendererTransactionId(
- int64_t host_transaction_id) {
- return host_transaction_id & 0xffffffff;
-}
-
-// static
-uint32_t IndexedDBDispatcherHost::TransactionIdToProcessId(
- int64_t host_transaction_id) {
- return (host_transaction_id >> 32) & 0xffffffff;
-}
-
std::string IndexedDBDispatcherHost::HoldBlobData(
const IndexedDBBlobInfo& blob_info) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
@@ -286,15 +232,12 @@ void IndexedDBDispatcherHost::OpenOnIDBThread(
base::TimeTicks begin_time = base::TimeTicks::Now();
base::FilePath indexed_db_path = indexed_db_context_->data_path();
- int64_t host_transaction_id = HostTransactionId(transaction_id);
-
// TODO(dgrogan): Don't let a non-existing database be opened (and therefore
// created) if this origin is already over quota.
callbacks->SetConnectionOpenStartTime(begin_time);
- callbacks->set_host_transaction_id(host_transaction_id);
std::unique_ptr<IndexedDBPendingConnection> connection =
base::MakeUnique<IndexedDBPendingConnection>(
- callbacks, database_callbacks, ipc_process_id_, host_transaction_id,
+ callbacks, database_callbacks, ipc_process_id_, transaction_id,
version);
DCHECK(request_context_getter_);
context()->GetIDBFactory()->Open(name, std::move(connection),
@@ -314,15 +257,4 @@ void IndexedDBDispatcherHost::DeleteDatabaseOnIDBThread(
name, request_context_getter_, callbacks, origin, indexed_db_path);
}
-void IndexedDBDispatcherHost::FinishTransaction(int64_t host_transaction_id,
- bool committed) {
- DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread());
- if (committed) {
- context()->TransactionComplete(
- transaction_origin_map_[host_transaction_id]);
- }
- transaction_origin_map_.erase(host_transaction_id);
- transaction_size_map_.erase(host_transaction_id);
-}
-
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698