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

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

Issue 1773813007: blink: Rename modules/ method to prefix with get when they collide. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clash-modules: rebase-fixes Created 4 years, 9 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
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 { 53 {
54 IDBRequest* request = new IDBRequest(scriptState, source, transaction); 54 IDBRequest* request = new IDBRequest(scriptState, source, transaction);
55 request->suspendIfNeeded(); 55 request->suspendIfNeeded();
56 // Requests associated with IDBFactory (open/deleteDatabase/getDatabaseNames ) are not associated with transactions. 56 // Requests associated with IDBFactory (open/deleteDatabase/getDatabaseNames ) are not associated with transactions.
57 if (transaction) 57 if (transaction)
58 transaction->registerRequest(request); 58 transaction->registerRequest(request);
59 return request; 59 return request;
60 } 60 }
61 61
62 IDBRequest::IDBRequest(ScriptState* scriptState, IDBAny* source, IDBTransaction* transaction) 62 IDBRequest::IDBRequest(ScriptState* scriptState, IDBAny* source, IDBTransaction* transaction)
63 : ActiveDOMObject(scriptState->executionContext()) 63 : ActiveDOMObject(scriptState->getExecutionContext())
64 , m_transaction(transaction) 64 , m_transaction(transaction)
65 , m_scriptState(scriptState) 65 , m_scriptState(scriptState)
66 , m_source(source) 66 , m_source(source)
67 { 67 {
68 } 68 }
69 69
70 IDBRequest::~IDBRequest() 70 IDBRequest::~IDBRequest()
71 { 71 {
72 ASSERT(m_readyState == DONE || m_readyState == EarlyDeath || !executionConte xt()); 72 ASSERT(m_readyState == DONE || m_readyState == EarlyDeath || !getExecutionCo ntext());
73 } 73 }
74 74
75 DEFINE_TRACE(IDBRequest) 75 DEFINE_TRACE(IDBRequest)
76 { 76 {
77 visitor->trace(m_transaction); 77 visitor->trace(m_transaction);
78 visitor->trace(m_source); 78 visitor->trace(m_source);
79 visitor->trace(m_result); 79 visitor->trace(m_result);
80 visitor->trace(m_error); 80 visitor->trace(m_error);
81 visitor->trace(m_enqueuedEvents); 81 visitor->trace(m_enqueuedEvents);
82 visitor->trace(m_pendingCursor); 82 visitor->trace(m_pendingCursor);
83 visitor->trace(m_cursorKey); 83 visitor->trace(m_cursorKey);
84 visitor->trace(m_cursorPrimaryKey); 84 visitor->trace(m_cursorPrimaryKey);
85 RefCountedGarbageCollectedEventTargetWithInlineData<IDBRequest>::trace(visit or); 85 RefCountedGarbageCollectedEventTargetWithInlineData<IDBRequest>::trace(visit or);
86 ActiveDOMObject::trace(visitor); 86 ActiveDOMObject::trace(visitor);
87 } 87 }
88 88
89 ScriptValue IDBRequest::result(ExceptionState& exceptionState) 89 ScriptValue IDBRequest::result(ExceptionState& exceptionState)
90 { 90 {
91 if (m_readyState != DONE) { 91 if (m_readyState != DONE) {
92 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::request NotFinishedErrorMessage); 92 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::request NotFinishedErrorMessage);
93 return ScriptValue(); 93 return ScriptValue();
94 } 94 }
95 if (m_contextStopped || !executionContext()) 95 if (m_contextStopped || !getExecutionContext())
96 return ScriptValue(); 96 return ScriptValue();
97 m_resultDirty = false; 97 m_resultDirty = false;
98 ScriptValue value = ScriptValue::from(m_scriptState.get(), m_result); 98 ScriptValue value = ScriptValue::from(m_scriptState.get(), m_result);
99 return value; 99 return value;
100 } 100 }
101 101
102 DOMException* IDBRequest::error(ExceptionState& exceptionState) const 102 DOMException* IDBRequest::error(ExceptionState& exceptionState) const
103 { 103 {
104 if (m_readyState != DONE) { 104 if (m_readyState != DONE) {
105 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::request NotFinishedErrorMessage); 105 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::request NotFinishedErrorMessage);
106 return nullptr; 106 return nullptr;
107 } 107 }
108 return m_error; 108 return m_error;
109 } 109 }
110 110
111 ScriptValue IDBRequest::source() const 111 ScriptValue IDBRequest::source() const
112 { 112 {
113 if (m_contextStopped || !executionContext()) 113 if (m_contextStopped || !getExecutionContext())
114 return ScriptValue(); 114 return ScriptValue();
115 115
116 return ScriptValue::from(m_scriptState.get(), m_source); 116 return ScriptValue::from(m_scriptState.get(), m_source);
117 } 117 }
118 118
119 const String& IDBRequest::readyState() const 119 const String& IDBRequest::readyState() const
120 { 120 {
121 ASSERT(m_readyState == PENDING || m_readyState == DONE); 121 ASSERT(m_readyState == PENDING || m_readyState == DONE);
122 122
123 if (m_readyState == PENDING) 123 if (m_readyState == PENDING)
124 return IndexedDBNames::pending; 124 return IndexedDBNames::pending;
125 125
126 return IndexedDBNames::done; 126 return IndexedDBNames::done;
127 } 127 }
128 128
129 void IDBRequest::abort() 129 void IDBRequest::abort()
130 { 130 {
131 ASSERT(!m_requestAborted); 131 ASSERT(!m_requestAborted);
132 if (m_contextStopped || !executionContext()) 132 if (m_contextStopped || !getExecutionContext())
133 return; 133 return;
134 ASSERT(m_readyState == PENDING || m_readyState == DONE); 134 ASSERT(m_readyState == PENDING || m_readyState == DONE);
135 if (m_readyState == DONE) 135 if (m_readyState == DONE)
136 return; 136 return;
137 137
138 EventQueue* eventQueue = executionContext()->eventQueue(); 138 EventQueue* eventQueue = getExecutionContext()->getEventQueue();
139 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { 139 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) {
140 bool removed = eventQueue->cancelEvent(m_enqueuedEvents[i].get()); 140 bool removed = eventQueue->cancelEvent(m_enqueuedEvents[i].get());
141 ASSERT_UNUSED(removed, removed); 141 ASSERT_UNUSED(removed, removed);
142 } 142 }
143 m_enqueuedEvents.clear(); 143 m_enqueuedEvents.clear();
144 144
145 m_error.clear(); 145 m_error.clear();
146 m_result.clear(); 146 m_result.clear();
147 onError(DOMException::create(AbortError, "The transaction was aborted, so th e request cannot be fulfilled.")); 147 onError(DOMException::create(AbortError, "The transaction was aborted, so th e request cannot be fulfilled."));
148 m_requestAborted = true; 148 m_requestAborted = true;
149 } 149 }
150 150
151 void IDBRequest::setCursorDetails(IndexedDB::CursorType cursorType, WebIDBCursor Direction direction) 151 void IDBRequest::setCursorDetails(IndexedDB::CursorType cursorType, WebIDBCursor Direction direction)
152 { 152 {
153 ASSERT(m_readyState == PENDING); 153 ASSERT(m_readyState == PENDING);
154 ASSERT(!m_pendingCursor); 154 ASSERT(!m_pendingCursor);
155 m_cursorType = cursorType; 155 m_cursorType = cursorType;
156 m_cursorDirection = direction; 156 m_cursorDirection = direction;
157 } 157 }
158 158
159 void IDBRequest::setPendingCursor(IDBCursor* cursor) 159 void IDBRequest::setPendingCursor(IDBCursor* cursor)
160 { 160 {
161 ASSERT(m_readyState == DONE); 161 ASSERT(m_readyState == DONE);
162 ASSERT(executionContext()); 162 ASSERT(getExecutionContext());
163 ASSERT(m_transaction); 163 ASSERT(m_transaction);
164 ASSERT(!m_pendingCursor); 164 ASSERT(!m_pendingCursor);
165 ASSERT(cursor == getResultCursor()); 165 ASSERT(cursor == getResultCursor());
166 166
167 m_hasPendingActivity = true; 167 m_hasPendingActivity = true;
168 m_pendingCursor = cursor; 168 m_pendingCursor = cursor;
169 setResult(nullptr); 169 setResult(nullptr);
170 m_readyState = PENDING; 170 m_readyState = PENDING;
171 m_error.clear(); 171 m_error.clear();
172 m_transaction->registerRequest(this); 172 m_transaction->registerRequest(this);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 } 204 }
205 205
206 void IDBRequest::ackReceivedBlobs(const Vector<RefPtr<IDBValue>>& values) 206 void IDBRequest::ackReceivedBlobs(const Vector<RefPtr<IDBValue>>& values)
207 { 207 {
208 for (size_t i = 0; i < values.size(); ++i) 208 for (size_t i = 0; i < values.size(); ++i)
209 ackReceivedBlobs(values[i].get()); 209 ackReceivedBlobs(values[i].get());
210 } 210 }
211 211
212 bool IDBRequest::shouldEnqueueEvent() const 212 bool IDBRequest::shouldEnqueueEvent() const
213 { 213 {
214 if (m_contextStopped || !executionContext()) 214 if (m_contextStopped || !getExecutionContext())
215 return false; 215 return false;
216 ASSERT(m_readyState == PENDING || m_readyState == DONE); 216 ASSERT(m_readyState == PENDING || m_readyState == DONE);
217 if (m_requestAborted) 217 if (m_requestAborted)
218 return false; 218 return false;
219 ASSERT(m_readyState == PENDING); 219 ASSERT(m_readyState == PENDING);
220 ASSERT(!m_error && !m_result); 220 ASSERT(!m_error && !m_result);
221 return true; 221 return true;
222 } 222 }
223 223
224 void IDBRequest::onError(DOMException* error) 224 void IDBRequest::onError(DOMException* error)
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 m_result->contextWillBeDestroyed(); 398 m_result->contextWillBeDestroyed();
399 if (m_pendingCursor) 399 if (m_pendingCursor)
400 m_pendingCursor->contextWillBeDestroyed(); 400 m_pendingCursor->contextWillBeDestroyed();
401 } 401 }
402 402
403 const AtomicString& IDBRequest::interfaceName() const 403 const AtomicString& IDBRequest::interfaceName() const
404 { 404 {
405 return EventTargetNames::IDBRequest; 405 return EventTargetNames::IDBRequest;
406 } 406 }
407 407
408 ExecutionContext* IDBRequest::executionContext() const 408 ExecutionContext* IDBRequest::getExecutionContext() const
409 { 409 {
410 return ActiveDOMObject::executionContext(); 410 return ActiveDOMObject::getExecutionContext();
411 } 411 }
412 412
413 DispatchEventResult IDBRequest::dispatchEventInternal(PassRefPtrWillBeRawPtr<Eve nt> event) 413 DispatchEventResult IDBRequest::dispatchEventInternal(PassRefPtrWillBeRawPtr<Eve nt> event)
414 { 414 {
415 IDB_TRACE("IDBRequest::dispatchEvent"); 415 IDB_TRACE("IDBRequest::dispatchEvent");
416 if (m_contextStopped || !executionContext()) 416 if (m_contextStopped || !getExecutionContext())
417 return DispatchEventResult::CanceledBeforeDispatch; 417 return DispatchEventResult::CanceledBeforeDispatch;
418 ASSERT(m_readyState == PENDING); 418 ASSERT(m_readyState == PENDING);
419 ASSERT(m_hasPendingActivity); 419 ASSERT(m_hasPendingActivity);
420 ASSERT(m_enqueuedEvents.size()); 420 ASSERT(m_enqueuedEvents.size());
421 ASSERT(event->target() == this); 421 ASSERT(event->target() == this);
422 422
423 ScriptState::Scope scope(m_scriptState.get()); 423 ScriptState::Scope scope(m_scriptState.get());
424 424
425 if (event->type() != EventTypeNames::blocked) 425 if (event->type() != EventTypeNames::blocked)
426 m_readyState = DONE; 426 m_readyState = DONE;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 m_transaction->abort(IGNORE_EXCEPTION); 493 m_transaction->abort(IGNORE_EXCEPTION);
494 } 494 }
495 } 495 }
496 496
497 void IDBRequest::transactionDidFinishAndDispatch() 497 void IDBRequest::transactionDidFinishAndDispatch()
498 { 498 {
499 ASSERT(m_transaction); 499 ASSERT(m_transaction);
500 ASSERT(m_transaction->isVersionChange()); 500 ASSERT(m_transaction->isVersionChange());
501 ASSERT(m_didFireUpgradeNeededEvent); 501 ASSERT(m_didFireUpgradeNeededEvent);
502 ASSERT(m_readyState == DONE); 502 ASSERT(m_readyState == DONE);
503 ASSERT(executionContext()); 503 ASSERT(getExecutionContext());
504 m_transaction.clear(); 504 m_transaction.clear();
505 505
506 if (m_contextStopped) 506 if (m_contextStopped)
507 return; 507 return;
508 508
509 m_readyState = PENDING; 509 m_readyState = PENDING;
510 } 510 }
511 511
512 void IDBRequest::enqueueEvent(PassRefPtrWillBeRawPtr<Event> event) 512 void IDBRequest::enqueueEvent(PassRefPtrWillBeRawPtr<Event> event)
513 { 513 {
514 ASSERT(m_readyState == PENDING || m_readyState == DONE); 514 ASSERT(m_readyState == PENDING || m_readyState == DONE);
515 515
516 if (m_contextStopped || !executionContext()) 516 if (m_contextStopped || !getExecutionContext())
517 return; 517 return;
518 518
519 ASSERT_WITH_MESSAGE(m_readyState == PENDING || m_didFireUpgradeNeededEvent, "When queueing event %s, m_readyState was %d", event->type().utf8().data(), m_re adyState); 519 ASSERT_WITH_MESSAGE(m_readyState == PENDING || m_didFireUpgradeNeededEvent, "When queueing event %s, m_readyState was %d", event->type().utf8().data(), m_re adyState);
520 520
521 EventQueue* eventQueue = executionContext()->eventQueue(); 521 EventQueue* eventQueue = getExecutionContext()->getEventQueue();
522 event->setTarget(this); 522 event->setTarget(this);
523 523
524 // Keep track of enqueued events in case we need to abort prior to dispatch, 524 // Keep track of enqueued events in case we need to abort prior to dispatch,
525 // in which case these must be cancelled. If the events not dispatched for 525 // in which case these must be cancelled. If the events not dispatched for
526 // other reasons they must be removed from this list via dequeueEvent(). 526 // other reasons they must be removed from this list via dequeueEvent().
527 if (eventQueue->enqueueEvent(event.get())) 527 if (eventQueue->enqueueEvent(event.get()))
528 m_enqueuedEvents.append(event); 528 m_enqueuedEvents.append(event);
529 } 529 }
530 530
531 void IDBRequest::dequeueEvent(Event* event) 531 void IDBRequest::dequeueEvent(Event* event)
532 { 532 {
533 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { 533 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) {
534 if (m_enqueuedEvents[i].get() == event) 534 if (m_enqueuedEvents[i].get() == event)
535 m_enqueuedEvents.remove(i); 535 m_enqueuedEvents.remove(i);
536 } 536 }
537 } 537 }
538 538
539 } // namespace blink 539 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698