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