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

Side by Side Diff: third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.cpp

Issue 2676403003: IndexedDB: Add histograms for key type (Closed)
Patch Set: Created 3 years, 10 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 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the 11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution. 12 * documentation and/or other materials provided with the distribution.
13 * 13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "modules/indexeddb/IDBObjectStore.h" 26 #include "modules/indexeddb/IDBObjectStore.h"
27 27
28 #include <v8.h>
cmumford 2017/02/07 20:10:37 I think it was correct to move <memory> up here, b
jsbell 2017/02/07 21:58:24 D'oh - it should be further down at any rate. htt
29
30 #include <memory>
31
28 #include "bindings/core/v8/ExceptionState.h" 32 #include "bindings/core/v8/ExceptionState.h"
29 #include "bindings/core/v8/ScriptState.h" 33 #include "bindings/core/v8/ScriptState.h"
30 #include "bindings/core/v8/SerializedScriptValueFactory.h" 34 #include "bindings/core/v8/SerializedScriptValueFactory.h"
31 #include "bindings/modules/v8/ToV8ForModules.h" 35 #include "bindings/modules/v8/ToV8ForModules.h"
32 #include "bindings/modules/v8/V8BindingForModules.h" 36 #include "bindings/modules/v8/V8BindingForModules.h"
33 #include "core/dom/DOMStringList.h" 37 #include "core/dom/DOMStringList.h"
34 #include "core/dom/ExceptionCode.h" 38 #include "core/dom/ExceptionCode.h"
35 #include "core/dom/ExecutionContext.h" 39 #include "core/dom/ExecutionContext.h"
36 #include "modules/indexeddb/IDBAny.h" 40 #include "modules/indexeddb/IDBAny.h"
37 #include "modules/indexeddb/IDBCursorWithValue.h" 41 #include "modules/indexeddb/IDBCursorWithValue.h"
38 #include "modules/indexeddb/IDBDatabase.h" 42 #include "modules/indexeddb/IDBDatabase.h"
39 #include "modules/indexeddb/IDBKeyPath.h" 43 #include "modules/indexeddb/IDBKeyPath.h"
40 #include "modules/indexeddb/IDBTracing.h" 44 #include "modules/indexeddb/IDBTracing.h"
45 #include "platform/Histogram.h"
41 #include "platform/SharedBuffer.h" 46 #include "platform/SharedBuffer.h"
42 #include "public/platform/WebBlobInfo.h" 47 #include "public/platform/WebBlobInfo.h"
43 #include "public/platform/WebData.h" 48 #include "public/platform/WebData.h"
44 #include "public/platform/WebVector.h" 49 #include "public/platform/WebVector.h"
45 #include "public/platform/modules/indexeddb/WebIDBKey.h" 50 #include "public/platform/modules/indexeddb/WebIDBKey.h"
46 #include "public/platform/modules/indexeddb/WebIDBKeyRange.h" 51 #include "public/platform/modules/indexeddb/WebIDBKeyRange.h"
47 #include <memory>
48 #include <v8.h>
49 52
50 using blink::WebBlobInfo; 53 using blink::WebBlobInfo;
51 using blink::WebIDBCallbacks; 54 using blink::WebIDBCallbacks;
52 using blink::WebIDBCursor; 55 using blink::WebIDBCursor;
53 using blink::WebIDBDatabase; 56 using blink::WebIDBDatabase;
54 using blink::WebVector; 57 using blink::WebVector;
55 58
56 namespace blink { 59 namespace blink {
57 60
58 namespace { 61 namespace {
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 } 443 }
441 444
442 if (!usesInLineKeys && !hasKeyGenerator && !key) { 445 if (!usesInLineKeys && !hasKeyGenerator && !key) {
443 exceptionState.throwDOMException(DataError, 446 exceptionState.throwDOMException(DataError,
444 "The object store uses out-of-line keys " 447 "The object store uses out-of-line keys "
445 "and has no key generator and the key " 448 "and has no key generator and the key "
446 "parameter was not provided."); 449 "parameter was not provided.");
447 return nullptr; 450 return nullptr;
448 } 451 }
449 if (usesInLineKeys) { 452 if (usesInLineKeys) {
450 if (clone.isEmpty()) 453 if (clone.isEmpty()) {
451 clone = 454 clone =
452 deserializeScriptValue(scriptState, serializedValue.get(), &blobInfo); 455 deserializeScriptValue(scriptState, serializedValue.get(), &blobInfo);
456 }
453 IDBKey* keyPathKey = ScriptValue::to<IDBKey*>(scriptState->isolate(), clone, 457 IDBKey* keyPathKey = ScriptValue::to<IDBKey*>(scriptState->isolate(), clone,
454 exceptionState, keyPath); 458 exceptionState, keyPath);
455 if (exceptionState.hadException()) 459 if (exceptionState.hadException())
456 return nullptr; 460 return nullptr;
457 if (keyPathKey && !keyPathKey->isValid()) { 461 if (keyPathKey && !keyPathKey->isValid()) {
458 exceptionState.throwDOMException(DataError, 462 exceptionState.throwDOMException(DataError,
459 "Evaluating the object store's key path " 463 "Evaluating the object store's key path "
460 "yielded a value that is not a valid " 464 "yielded a value that is not a valid "
461 "key."); 465 "key.");
462 return nullptr; 466 return nullptr;
(...skipping 20 matching lines...) Expand all
483 IDBDatabase::notValidKeyErrorMessage); 487 IDBDatabase::notValidKeyErrorMessage);
484 return nullptr; 488 return nullptr;
485 } 489 }
486 490
487 if (!backendDB()) { 491 if (!backendDB()) {
488 exceptionState.throwDOMException(InvalidStateError, 492 exceptionState.throwDOMException(InvalidStateError,
489 IDBDatabase::databaseClosedErrorMessage); 493 IDBDatabase::databaseClosedErrorMessage);
490 return nullptr; 494 return nullptr;
491 } 495 }
492 496
497 if (key && usesInLineKeys) {
498 DEFINE_THREAD_SAFE_STATIC_LOCAL(
499 EnumerationHistogram, keyTypeHistogram,
500 new EnumerationHistogram("WebCore.IndexedDB.ObjectStoreRecord.KeyType",
501 static_cast<int>(IDBKey::TypeEnumMax)));
502 keyTypeHistogram.count(static_cast<int>(key->getType()));
503 }
504
493 Vector<int64_t> indexIds; 505 Vector<int64_t> indexIds;
494 HeapVector<IndexKeys> indexKeys; 506 HeapVector<IndexKeys> indexKeys;
495 for (const auto& it : metadata().indexes) { 507 for (const auto& it : metadata().indexes) {
496 if (clone.isEmpty()) 508 if (clone.isEmpty()) {
497 clone = 509 clone =
498 deserializeScriptValue(scriptState, serializedValue.get(), &blobInfo); 510 deserializeScriptValue(scriptState, serializedValue.get(), &blobInfo);
511 }
499 IndexKeys keys; 512 IndexKeys keys;
500 generateIndexKeysForValue(scriptState->isolate(), *it.value, clone, &keys); 513 generateIndexKeysForValue(scriptState->isolate(), *it.value, clone, &keys);
501 indexIds.push_back(it.key); 514 indexIds.push_back(it.key);
502 indexKeys.push_back(keys); 515 indexKeys.push_back(keys);
503 } 516 }
504 517
505 IDBRequest* request = 518 IDBRequest* request =
506 IDBRequest::create(scriptState, source, m_transaction.get()); 519 IDBRequest::create(scriptState, source, m_transaction.get());
507 Vector<char> wireBytes; 520 Vector<char> wireBytes;
508 serializedValue->toWireBytes(wireBytes); 521 serializedValue->toWireBytes(wireBytes);
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 } 1101 }
1089 } 1102 }
1090 return IDBIndexMetadata::InvalidId; 1103 return IDBIndexMetadata::InvalidId;
1091 } 1104 }
1092 1105
1093 WebIDBDatabase* IDBObjectStore::backendDB() const { 1106 WebIDBDatabase* IDBObjectStore::backendDB() const {
1094 return m_transaction->backendDB(); 1107 return m_transaction->backendDB();
1095 } 1108 }
1096 1109
1097 } // namespace blink 1110 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698