Chromium Code Reviews| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 return transaction; | 52 return transaction; |
| 53 } | 53 } |
| 54 | 54 |
| 55 IDBTransaction* IDBTransaction::create(ScriptState* scriptState, int64_t id, IDB Database* db, IDBOpenDBRequest* openDBRequest, const IDBDatabaseMetadata& previo usMetadata) | 55 IDBTransaction* IDBTransaction::create(ScriptState* scriptState, int64_t id, IDB Database* db, IDBOpenDBRequest* openDBRequest, const IDBDatabaseMetadata& previo usMetadata) |
| 56 { | 56 { |
| 57 IDBTransaction* transaction = new IDBTransaction(scriptState, id, Vector<Str ing>(), WebIDBTransactionModeVersionChange, db, openDBRequest, previousMetadata) ; | 57 IDBTransaction* transaction = new IDBTransaction(scriptState, id, Vector<Str ing>(), WebIDBTransactionModeVersionChange, db, openDBRequest, previousMetadata) ; |
| 58 transaction->suspendIfNeeded(); | 58 transaction->suspendIfNeeded(); |
| 59 return transaction; | 59 return transaction; |
| 60 } | 60 } |
| 61 | 61 |
| 62 namespace { | |
| 63 | |
| 64 class DeactivateTransactionTask : public V8PerIsolateData::EndOfScopeTask { | |
| 65 public: | |
| 66 static PassOwnPtr<DeactivateTransactionTask> create(IDBTransaction* transact ion) | |
| 67 { | |
| 68 return adoptPtr(new DeactivateTransactionTask(transaction)); | |
| 69 } | |
| 70 | |
| 71 void Run() override | |
| 72 { | |
| 73 m_transaction->setActive(false); | |
| 74 m_transaction.clear(); | |
| 75 } | |
| 76 | |
| 77 private: | |
| 78 DeactivateTransactionTask(IDBTransaction* transaction) | |
|
haraken
2014/11/11 01:09:15
Add explicit.
jsbell
2014/11/11 17:38:26
Done.
| |
| 79 : m_transaction(transaction) { } | |
| 80 | |
| 81 Persistent<IDBTransaction> m_transaction; | |
| 82 }; | |
| 83 | |
| 84 } // namespace | |
| 85 | |
| 62 IDBTransaction::IDBTransaction(ScriptState* scriptState, int64_t id, const Vecto r<String>& objectStoreNames, WebIDBTransactionMode mode, IDBDatabase* db, IDBOpe nDBRequest* openDBRequest, const IDBDatabaseMetadata& previousMetadata) | 86 IDBTransaction::IDBTransaction(ScriptState* scriptState, int64_t id, const Vecto r<String>& objectStoreNames, WebIDBTransactionMode mode, IDBDatabase* db, IDBOpe nDBRequest* openDBRequest, const IDBDatabaseMetadata& previousMetadata) |
| 63 : ActiveDOMObject(scriptState->executionContext()) | 87 : ActiveDOMObject(scriptState->executionContext()) |
| 64 , m_id(id) | 88 , m_id(id) |
| 65 , m_database(db) | 89 , m_database(db) |
| 66 , m_objectStoreNames(objectStoreNames) | 90 , m_objectStoreNames(objectStoreNames) |
| 67 , m_openDBRequest(openDBRequest) | 91 , m_openDBRequest(openDBRequest) |
| 68 , m_mode(mode) | 92 , m_mode(mode) |
| 69 , m_state(Active) | 93 , m_state(Active) |
| 70 , m_hasPendingActivity(true) | 94 , m_hasPendingActivity(true) |
| 71 , m_contextStopped(false) | 95 , m_contextStopped(false) |
| 72 , m_previousMetadata(previousMetadata) | 96 , m_previousMetadata(previousMetadata) |
| 73 { | 97 { |
| 74 if (mode == WebIDBTransactionModeVersionChange) { | 98 if (mode == WebIDBTransactionModeVersionChange) { |
| 75 // Not active until the callback. | 99 // Not active until the callback. |
| 76 m_state = Inactive; | 100 m_state = Inactive; |
| 77 } | 101 } |
| 78 | 102 |
| 79 if (m_state == Active) | 103 if (m_state == Active) |
| 80 V8PerIsolateData::from(scriptState->isolate())->ensureIDBPendingTransact ionMonitor()->addNewTransaction(*this); | 104 V8PerIsolateData::from(scriptState->isolate())->addEndOfScopeTask(Deacti vateTransactionTask::create(this)); |
| 81 m_database->transactionCreated(this); | 105 m_database->transactionCreated(this); |
| 82 } | 106 } |
| 83 | 107 |
| 84 IDBTransaction::~IDBTransaction() | 108 IDBTransaction::~IDBTransaction() |
| 85 { | 109 { |
| 86 ASSERT(m_state == Finished || m_contextStopped); | 110 ASSERT(m_state == Finished || m_contextStopped); |
| 87 ASSERT(m_requestList.isEmpty() || m_contextStopped); | 111 ASSERT(m_requestList.isEmpty() || m_contextStopped); |
| 88 } | 112 } |
| 89 | 113 |
| 90 void IDBTransaction::trace(Visitor* visitor) | 114 void IDBTransaction::trace(Visitor* visitor) |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 370 event->setTarget(this); | 394 event->setTarget(this); |
| 371 eventQueue->enqueueEvent(event); | 395 eventQueue->enqueueEvent(event); |
| 372 } | 396 } |
| 373 | 397 |
| 374 WebIDBDatabase* IDBTransaction::backendDB() const | 398 WebIDBDatabase* IDBTransaction::backendDB() const |
| 375 { | 399 { |
| 376 return m_database->backend(); | 400 return m_database->backend(); |
| 377 } | 401 } |
| 378 | 402 |
| 379 } // namespace blink | 403 } // namespace blink |
| OLD | NEW |