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

Side by Side Diff: content/browser/indexed_db/indexed_db_transaction.cc

Issue 1504033007: Move Indexed DB from dedicated thread to task scheduler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@timer
Patch Set: Tweak traits Created 3 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #include "content/browser/indexed_db/indexed_db_transaction.h" 5 #include "content/browser/indexed_db/indexed_db_transaction.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/metrics/histogram_macros.h" 11 #include "base/metrics/histogram_macros.h"
12 #include "base/single_thread_task_runner.h"
13 #include "base/stl_util.h" 12 #include "base/stl_util.h"
14 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
15 #include "base/threading/thread_task_runner_handle.h" 14 #include "base/threading/sequenced_task_runner_handle.h"
16 #include "content/browser/indexed_db/indexed_db_backing_store.h" 15 #include "content/browser/indexed_db/indexed_db_backing_store.h"
17 #include "content/browser/indexed_db/indexed_db_cursor.h" 16 #include "content/browser/indexed_db/indexed_db_cursor.h"
18 #include "content/browser/indexed_db/indexed_db_database.h" 17 #include "content/browser/indexed_db/indexed_db_database.h"
19 #include "content/browser/indexed_db/indexed_db_database_callbacks.h" 18 #include "content/browser/indexed_db/indexed_db_database_callbacks.h"
20 #include "content/browser/indexed_db/indexed_db_tracing.h" 19 #include "content/browser/indexed_db/indexed_db_tracing.h"
21 #include "content/browser/indexed_db/indexed_db_transaction_coordinator.h" 20 #include "content/browser/indexed_db/indexed_db_transaction_coordinator.h"
22 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseExc eption.h" 21 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseExc eption.h"
23 #include "third_party/leveldatabase/env_chromium.h" 22 #include "third_party/leveldatabase/env_chromium.h"
24 23
25 namespace content { 24 namespace content {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 164
166 // Not started by the coordinator yet. 165 // Not started by the coordinator yet.
167 if (state_ != STARTED) 166 if (state_ != STARTED)
168 return; 167 return;
169 168
170 // A task is already posted. 169 // A task is already posted.
171 if (should_process_queue_) 170 if (should_process_queue_)
172 return; 171 return;
173 172
174 should_process_queue_ = true; 173 should_process_queue_ = true;
175 base::ThreadTaskRunnerHandle::Get()->PostTask( 174 base::SequencedTaskRunnerHandle::Get()->PostTask(
176 FROM_HERE, base::Bind(&IndexedDBTransaction::ProcessTaskQueue, 175 FROM_HERE, base::Bind(&IndexedDBTransaction::ProcessTaskQueue,
177 ptr_factory_.GetWeakPtr())); 176 ptr_factory_.GetWeakPtr()));
178 } 177 }
179 178
180 void IndexedDBTransaction::Abort(const IndexedDBDatabaseError& error) { 179 void IndexedDBTransaction::Abort(const IndexedDBDatabaseError& error) {
181 IDB_TRACE1("IndexedDBTransaction::Abort", "txn.id", id()); 180 IDB_TRACE1("IndexedDBTransaction::Abort", "txn.id", id());
182 DCHECK(!processing_event_queue_); 181 DCHECK(!processing_event_queue_);
183 if (state_ == FINISHED) 182 if (state_ == FINISHED)
184 return; 183 return;
185 184
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 // TransactionCoordinator has started this transaction. 246 // TransactionCoordinator has started this transaction.
248 DCHECK_EQ(CREATED, state_); 247 DCHECK_EQ(CREATED, state_);
249 state_ = STARTED; 248 state_ = STARTED;
250 diagnostics_.start_time = base::Time::Now(); 249 diagnostics_.start_time = base::Time::Now();
251 250
252 if (!used_) { 251 if (!used_) {
253 if (commit_pending_) { 252 if (commit_pending_) {
254 // The transaction has never had requests issued against it, but the 253 // The transaction has never had requests issued against it, but the
255 // front-end previously requested a commit; do the commit now, but not 254 // front-end previously requested a commit; do the commit now, but not
256 // re-entrantly as that may renter the coordinator. 255 // re-entrantly as that may renter the coordinator.
257 base::ThreadTaskRunnerHandle::Get()->PostTask( 256 base::SequencedTaskRunnerHandle::Get()->PostTask(
258 FROM_HERE, base::Bind(&CommitUnused, ptr_factory_.GetWeakPtr())); 257 FROM_HERE, base::Bind(&CommitUnused, ptr_factory_.GetWeakPtr()));
259 } 258 }
260 return; 259 return;
261 } 260 }
262 261
263 RunTasksIfStarted(); 262 RunTasksIfStarted();
264 } 263 }
265 264
266 void IndexedDBTransaction::GrabSnapshotThenStart() { 265 void IndexedDBTransaction::GrabSnapshotThenStart() {
267 DCHECK(!backing_store_transaction_begun_); 266 DCHECK(!backing_store_transaction_begun_);
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 580
582 ::indexed_db::mojom::ObserverChangesPtr* 581 ::indexed_db::mojom::ObserverChangesPtr*
583 IndexedDBTransaction::GetPendingChangesForConnection(int32_t connection_id) { 582 IndexedDBTransaction::GetPendingChangesForConnection(int32_t connection_id) {
584 auto it = connection_changes_map_.find(connection_id); 583 auto it = connection_changes_map_.find(connection_id);
585 if (it != connection_changes_map_.end()) 584 if (it != connection_changes_map_.end())
586 return &it->second; 585 return &it->second;
587 return nullptr; 586 return nullptr;
588 } 587 }
589 588
590 } // namespace content 589 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_dispatcher_host.cc ('k') | content/browser/storage_partition_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698