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

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

Issue 2903133002: [IndexedDB] Adding uma for transaction aborts (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | tools/metrics/histograms/enums.xml » ('j') | tools/metrics/histograms/enums.xml » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
12 #include "base/stl_util.h" 13 #include "base/stl_util.h"
13 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
14 #include "base/threading/thread_task_runner_handle.h" 15 #include "base/threading/thread_task_runner_handle.h"
15 #include "content/browser/indexed_db/indexed_db_backing_store.h" 16 #include "content/browser/indexed_db/indexed_db_backing_store.h"
16 #include "content/browser/indexed_db/indexed_db_cursor.h" 17 #include "content/browser/indexed_db/indexed_db_cursor.h"
17 #include "content/browser/indexed_db/indexed_db_database.h" 18 #include "content/browser/indexed_db/indexed_db_database.h"
18 #include "content/browser/indexed_db/indexed_db_database_callbacks.h" 19 #include "content/browser/indexed_db/indexed_db_database_callbacks.h"
19 #include "content/browser/indexed_db/indexed_db_tracing.h" 20 #include "content/browser/indexed_db/indexed_db_tracing.h"
20 #include "content/browser/indexed_db/indexed_db_transaction_coordinator.h" 21 #include "content/browser/indexed_db/indexed_db_transaction_coordinator.h"
21 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseExc eption.h" 22 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseExc eption.h"
22 #include "third_party/leveldatabase/env_chromium.h" 23 #include "third_party/leveldatabase/env_chromium.h"
23 24
24 namespace content { 25 namespace content {
25 26
26 namespace { 27 namespace {
27 28
28 const int64_t kInactivityTimeoutPeriodSeconds = 60; 29 const int64_t kInactivityTimeoutPeriodSeconds = 60;
29 30
30 // Helper for posting a task to call IndexedDBTransaction::Commit when we know 31 // Helper for posting a task to call IndexedDBTransaction::Commit when we know
31 // the transaction had no requests and therefore the commit must succeed. 32 // the transaction had no requests and therefore the commit must succeed.
32 void CommitUnused(base::WeakPtr<IndexedDBTransaction> transaction) { 33 void CommitUnused(base::WeakPtr<IndexedDBTransaction> transaction) {
33 if (!transaction) 34 if (!transaction)
34 return; 35 return;
35 leveldb::Status status = transaction->Commit(); 36 leveldb::Status status = transaction->Commit();
36 DCHECK(status.ok()); 37 DCHECK(status.ok());
37 } 38 }
38 39
40 // Used for UMA metrics - do not change values.
41 enum UmaIDBException {
42 UmaIDBExceptionUnknownError = 0,
43 UmaIDBExceptionConstraintError,
jsbell 2017/05/25 17:08:58 Give all of these explicit values since they are u
dmurph 2017/05/25 17:33:08 Done.
44 UmaIDBExceptionDataError,
45 UmaIDBExceptionVersionError,
46 UmaIDBExceptionAbortError,
47 UmaIDBExceptionQuotaError,
48 UmaIDBExceptionTimeoutError,
49 UmaIDBExceptionExclusiveMaxValue
50 };
51
52 // Used for UMA metrics - do not change mappings.
53 UmaIDBException TranslateExceptionCodeToUmaEnum(uint16_t code) {
jsbell 2017/05/25 17:08:58 Could drop 'Translate' from the name here, but it'
dmurph 2017/05/25 17:33:08 Done.
54 switch (code) {
55 case blink::kWebIDBDatabaseExceptionUnknownError:
56 return UmaIDBExceptionUnknownError;
57 case blink::kWebIDBDatabaseExceptionConstraintError:
58 return UmaIDBExceptionConstraintError;
59 case blink::kWebIDBDatabaseExceptionDataError:
60 return UmaIDBExceptionDataError;
61 case blink::kWebIDBDatabaseExceptionVersionError:
62 return UmaIDBExceptionVersionError;
63 case blink::kWebIDBDatabaseExceptionAbortError:
64 return UmaIDBExceptionAbortError;
65 case blink::kWebIDBDatabaseExceptionQuotaError:
66 return UmaIDBExceptionQuotaError;
67 case blink::kWebIDBDatabaseExceptionTimeoutError:
68 return UmaIDBExceptionTimeoutError;
69 default:
70 NOTREACHED();
71 }
72 return UmaIDBExceptionUnknownError;
73 }
74
39 } // namespace 75 } // namespace
40 76
41 IndexedDBTransaction::TaskQueue::TaskQueue() {} 77 IndexedDBTransaction::TaskQueue::TaskQueue() {}
42 IndexedDBTransaction::TaskQueue::~TaskQueue() { clear(); } 78 IndexedDBTransaction::TaskQueue::~TaskQueue() { clear(); }
43 79
44 void IndexedDBTransaction::TaskQueue::clear() { 80 void IndexedDBTransaction::TaskQueue::clear() {
45 while (!queue_.empty()) 81 while (!queue_.empty())
46 queue_.pop(); 82 queue_.pop();
47 } 83 }
48 84
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 Abort(IndexedDBDatabaseError(blink::kWebIDBDatabaseExceptionUnknownError, 181 Abort(IndexedDBDatabaseError(blink::kWebIDBDatabaseExceptionUnknownError,
146 "Internal error (unknown cause)")); 182 "Internal error (unknown cause)"));
147 } 183 }
148 184
149 void IndexedDBTransaction::Abort(const IndexedDBDatabaseError& error) { 185 void IndexedDBTransaction::Abort(const IndexedDBDatabaseError& error) {
150 IDB_TRACE1("IndexedDBTransaction::Abort", "txn.id", id()); 186 IDB_TRACE1("IndexedDBTransaction::Abort", "txn.id", id());
151 DCHECK(!processing_event_queue_); 187 DCHECK(!processing_event_queue_);
152 if (state_ == FINISHED) 188 if (state_ == FINISHED)
153 return; 189 return;
154 190
191 UMA_HISTOGRAM_ENUMERATION("WebCore.IndexedDB.TransactionAbortReason",
192 TranslateExceptionCodeToUmaEnum(error.code()),
193 UmaIDBExceptionExclusiveMaxValue);
194
155 timeout_timer_.Stop(); 195 timeout_timer_.Stop();
156 196
157 state_ = FINISHED; 197 state_ = FINISHED;
158 should_process_queue_ = false; 198 should_process_queue_ = false;
159 199
160 if (backing_store_transaction_begun_) 200 if (backing_store_transaction_begun_)
161 transaction_->Rollback(); 201 transaction_->Rollback();
162 202
163 // Run the abort tasks, if any. 203 // Run the abort tasks, if any.
164 while (!abort_task_stack_.empty()) 204 while (!abort_task_stack_.empty())
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 560
521 ::indexed_db::mojom::ObserverChangesPtr* 561 ::indexed_db::mojom::ObserverChangesPtr*
522 IndexedDBTransaction::GetPendingChangesForConnection(int32_t connection_id) { 562 IndexedDBTransaction::GetPendingChangesForConnection(int32_t connection_id) {
523 auto it = connection_changes_map_.find(connection_id); 563 auto it = connection_changes_map_.find(connection_id);
524 if (it != connection_changes_map_.end()) 564 if (it != connection_changes_map_.end())
525 return &it->second; 565 return &it->second;
526 return nullptr; 566 return nullptr;
527 } 567 }
528 568
529 } // namespace content 569 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/enums.xml » ('j') | tools/metrics/histograms/enums.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698