OLD | NEW |
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 |
(...skipping 27 matching lines...) Expand all Loading... |
38 #include "modules/indexeddb/IDBIndex.h" | 38 #include "modules/indexeddb/IDBIndex.h" |
39 #include "modules/indexeddb/IDBKeyPath.h" | 39 #include "modules/indexeddb/IDBKeyPath.h" |
40 #include "modules/indexeddb/IDBTracing.h" | 40 #include "modules/indexeddb/IDBTracing.h" |
41 #include "modules/indexeddb/IDBVersionChangeEvent.h" | 41 #include "modules/indexeddb/IDBVersionChangeEvent.h" |
42 #include "modules/indexeddb/WebIDBDatabaseCallbacksImpl.h" | 42 #include "modules/indexeddb/WebIDBDatabaseCallbacksImpl.h" |
43 #include "platform/Histogram.h" | 43 #include "platform/Histogram.h" |
44 #include "public/platform/modules/indexeddb/WebIDBKeyPath.h" | 44 #include "public/platform/modules/indexeddb/WebIDBKeyPath.h" |
45 #include "public/platform/modules/indexeddb/WebIDBTypes.h" | 45 #include "public/platform/modules/indexeddb/WebIDBTypes.h" |
46 #include "wtf/Atomics.h" | 46 #include "wtf/Atomics.h" |
47 #include <limits> | 47 #include <limits> |
48 #include <memory> | |
49 | 48 |
50 using blink::WebIDBDatabase; | 49 using blink::WebIDBDatabase; |
51 | 50 |
52 namespace blink { | 51 namespace blink { |
53 | 52 |
54 const char IDBDatabase::indexDeletedErrorMessage[] = "The index or its object st
ore has been deleted."; | 53 const char IDBDatabase::indexDeletedErrorMessage[] = "The index or its object st
ore has been deleted."; |
55 const char IDBDatabase::isKeyCursorErrorMessage[] = "The cursor is a key cursor.
"; | 54 const char IDBDatabase::isKeyCursorErrorMessage[] = "The cursor is a key cursor.
"; |
56 const char IDBDatabase::noKeyOrKeyRangeErrorMessage[] = "No key or key range spe
cified."; | 55 const char IDBDatabase::noKeyOrKeyRangeErrorMessage[] = "No key or key range spe
cified."; |
57 const char IDBDatabase::noSuchIndexErrorMessage[] = "The specified index was not
found."; | 56 const char IDBDatabase::noSuchIndexErrorMessage[] = "The specified index was not
found."; |
58 const char IDBDatabase::noSuchObjectStoreErrorMessage[] = "The specified object
store was not found."; | 57 const char IDBDatabase::noSuchObjectStoreErrorMessage[] = "The specified object
store was not found."; |
59 const char IDBDatabase::noValueErrorMessage[] = "The cursor is being iterated or
has iterated past its end."; | 58 const char IDBDatabase::noValueErrorMessage[] = "The cursor is being iterated or
has iterated past its end."; |
60 const char IDBDatabase::notValidKeyErrorMessage[] = "The parameter is not a vali
d key."; | 59 const char IDBDatabase::notValidKeyErrorMessage[] = "The parameter is not a vali
d key."; |
61 const char IDBDatabase::notVersionChangeTransactionErrorMessage[] = "The databas
e is not running a version change transaction."; | 60 const char IDBDatabase::notVersionChangeTransactionErrorMessage[] = "The databas
e is not running a version change transaction."; |
62 const char IDBDatabase::objectStoreDeletedErrorMessage[] = "The object store has
been deleted."; | 61 const char IDBDatabase::objectStoreDeletedErrorMessage[] = "The object store has
been deleted."; |
63 const char IDBDatabase::requestNotFinishedErrorMessage[] = "The request has not
finished."; | 62 const char IDBDatabase::requestNotFinishedErrorMessage[] = "The request has not
finished."; |
64 const char IDBDatabase::sourceDeletedErrorMessage[] = "The cursor's source or ef
fective object store has been deleted."; | 63 const char IDBDatabase::sourceDeletedErrorMessage[] = "The cursor's source or ef
fective object store has been deleted."; |
65 const char IDBDatabase::transactionInactiveErrorMessage[] = "The transaction is
not active."; | 64 const char IDBDatabase::transactionInactiveErrorMessage[] = "The transaction is
not active."; |
66 const char IDBDatabase::transactionFinishedErrorMessage[] = "The transaction has
finished."; | 65 const char IDBDatabase::transactionFinishedErrorMessage[] = "The transaction has
finished."; |
67 const char IDBDatabase::transactionReadOnlyErrorMessage[] = "The transaction is
read-only."; | 66 const char IDBDatabase::transactionReadOnlyErrorMessage[] = "The transaction is
read-only."; |
68 const char IDBDatabase::databaseClosedErrorMessage[] = "The database connection
is closed."; | 67 const char IDBDatabase::databaseClosedErrorMessage[] = "The database connection
is closed."; |
69 | 68 |
70 IDBDatabase* IDBDatabase::create(ExecutionContext* context, std::unique_ptr<WebI
DBDatabase> database, IDBDatabaseCallbacks* callbacks) | 69 IDBDatabase* IDBDatabase::create(ExecutionContext* context, PassOwnPtr<WebIDBDat
abase> database, IDBDatabaseCallbacks* callbacks) |
71 { | 70 { |
72 IDBDatabase* idbDatabase = new IDBDatabase(context, std::move(database), cal
lbacks); | 71 IDBDatabase* idbDatabase = new IDBDatabase(context, std::move(database), cal
lbacks); |
73 idbDatabase->suspendIfNeeded(); | 72 idbDatabase->suspendIfNeeded(); |
74 return idbDatabase; | 73 return idbDatabase; |
75 } | 74 } |
76 | 75 |
77 IDBDatabase::IDBDatabase(ExecutionContext* context, std::unique_ptr<WebIDBDataba
se> backend, IDBDatabaseCallbacks* callbacks) | 76 IDBDatabase::IDBDatabase(ExecutionContext* context, PassOwnPtr<WebIDBDatabase> b
ackend, IDBDatabaseCallbacks* callbacks) |
78 : ActiveScriptWrappable(this) | 77 : ActiveScriptWrappable(this) |
79 , ActiveDOMObject(context) | 78 , ActiveDOMObject(context) |
80 , m_backend(std::move(backend)) | 79 , m_backend(std::move(backend)) |
81 , m_databaseCallbacks(callbacks) | 80 , m_databaseCallbacks(callbacks) |
82 { | 81 { |
83 m_databaseCallbacks->connect(this); | 82 m_databaseCallbacks->connect(this); |
84 } | 83 } |
85 | 84 |
86 IDBDatabase::~IDBDatabase() | 85 IDBDatabase::~IDBDatabase() |
87 { | 86 { |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 } | 304 } |
306 objectStoreIds.append(objectStoreId); | 305 objectStoreIds.append(objectStoreId); |
307 } | 306 } |
308 | 307 |
309 if (!m_backend) { | 308 if (!m_backend) { |
310 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 309 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
311 return nullptr; | 310 return nullptr; |
312 } | 311 } |
313 | 312 |
314 int64_t transactionId = nextTransactionId(); | 313 int64_t transactionId = nextTransactionId(); |
315 m_backend->createTransaction(transactionId, WebIDBDatabaseCallbacksImpl::cre
ate(m_databaseCallbacks).release(), objectStoreIds, mode); | 314 m_backend->createTransaction(transactionId, WebIDBDatabaseCallbacksImpl::cre
ate(m_databaseCallbacks).leakPtr(), objectStoreIds, mode); |
316 | 315 |
317 return IDBTransaction::create(scriptState, transactionId, scope, mode, this)
; | 316 return IDBTransaction::create(scriptState, transactionId, scope, mode, this)
; |
318 } | 317 } |
319 | 318 |
320 void IDBDatabase::forceClose() | 319 void IDBDatabase::forceClose() |
321 { | 320 { |
322 for (const auto& it : m_transactions) | 321 for (const auto& it : m_transactions) |
323 it.value->abort(IGNORE_EXCEPTION); | 322 it.value->abort(IGNORE_EXCEPTION); |
324 this->close(); | 323 this->close(); |
325 enqueueEvent(Event::create(EventTypeNames::close)); | 324 enqueueEvent(Event::create(EventTypeNames::close)); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 return ActiveDOMObject::getExecutionContext(); | 446 return ActiveDOMObject::getExecutionContext(); |
448 } | 447 } |
449 | 448 |
450 void IDBDatabase::recordApiCallsHistogram(IndexedDatabaseMethods method) | 449 void IDBDatabase::recordApiCallsHistogram(IndexedDatabaseMethods method) |
451 { | 450 { |
452 DEFINE_THREAD_SAFE_STATIC_LOCAL(EnumerationHistogram, apiCallsHistogram, new
EnumerationHistogram("WebCore.IndexedDB.FrontEndAPICalls", IDBMethodsMax)); | 451 DEFINE_THREAD_SAFE_STATIC_LOCAL(EnumerationHistogram, apiCallsHistogram, new
EnumerationHistogram("WebCore.IndexedDB.FrontEndAPICalls", IDBMethodsMax)); |
453 apiCallsHistogram.count(method); | 452 apiCallsHistogram.count(method); |
454 } | 453 } |
455 | 454 |
456 } // namespace blink | 455 } // namespace blink |
OLD | NEW |