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

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

Issue 2370643004: Port messages sent by WebIDBFactoryImpl to Mojo. (Closed)
Patch Set: Address last nits and fix leaks in unit tests. Created 4 years, 2 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 24 matching lines...) Expand all
35 #include "core/dom/DOMException.h" 35 #include "core/dom/DOMException.h"
36 #include "core/dom/ExceptionCode.h" 36 #include "core/dom/ExceptionCode.h"
37 #include "core/dom/ExecutionContext.h" 37 #include "core/dom/ExecutionContext.h"
38 #include "core/events/EventQueue.h" 38 #include "core/events/EventQueue.h"
39 #include "modules/IndexedDBNames.h" 39 #include "modules/IndexedDBNames.h"
40 #include "modules/indexeddb/IDBCursorWithValue.h" 40 #include "modules/indexeddb/IDBCursorWithValue.h"
41 #include "modules/indexeddb/IDBDatabase.h" 41 #include "modules/indexeddb/IDBDatabase.h"
42 #include "modules/indexeddb/IDBEventDispatcher.h" 42 #include "modules/indexeddb/IDBEventDispatcher.h"
43 #include "modules/indexeddb/IDBTracing.h" 43 #include "modules/indexeddb/IDBTracing.h"
44 #include "modules/indexeddb/IDBValue.h" 44 #include "modules/indexeddb/IDBValue.h"
45 #include "modules/indexeddb/WebIDBCallbacksImpl.h"
45 #include "platform/SharedBuffer.h" 46 #include "platform/SharedBuffer.h"
46 #include "public/platform/WebBlobInfo.h" 47 #include "public/platform/WebBlobInfo.h"
47 #include <memory> 48 #include <memory>
48 49
49 using blink::WebIDBCursor; 50 using blink::WebIDBCursor;
50 51
51 namespace blink { 52 namespace blink {
52 53
53 IDBRequest* IDBRequest::create(ScriptState* scriptState, 54 IDBRequest* IDBRequest::create(ScriptState* scriptState,
54 IDBAny* source, 55 IDBAny* source,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 126
126 const String& IDBRequest::readyState() const { 127 const String& IDBRequest::readyState() const {
127 DCHECK(m_readyState == PENDING || m_readyState == DONE); 128 DCHECK(m_readyState == PENDING || m_readyState == DONE);
128 129
129 if (m_readyState == PENDING) 130 if (m_readyState == PENDING)
130 return IndexedDBNames::pending; 131 return IndexedDBNames::pending;
131 132
132 return IndexedDBNames::done; 133 return IndexedDBNames::done;
133 } 134 }
134 135
136 std::unique_ptr<WebIDBCallbacks> IDBRequest::createWebCallbacks() {
137 DCHECK(!m_webCallbacks);
138 std::unique_ptr<WebIDBCallbacks> callbacks =
139 WebIDBCallbacksImpl::create(this);
140 m_webCallbacks = callbacks.get();
141 return callbacks;
142 }
143
144 void IDBRequest::webCallbacksDestroyed() {
145 DCHECK(m_webCallbacks);
146 m_webCallbacks = nullptr;
147 }
148
135 void IDBRequest::abort() { 149 void IDBRequest::abort() {
136 DCHECK(!m_requestAborted); 150 DCHECK(!m_requestAborted);
137 if (m_contextStopped || !getExecutionContext()) 151 if (m_contextStopped || !getExecutionContext())
138 return; 152 return;
139 DCHECK(m_readyState == PENDING || m_readyState == DONE); 153 DCHECK(m_readyState == PENDING || m_readyState == DONE);
140 if (m_readyState == DONE) 154 if (m_readyState == DONE)
141 return; 155 return;
142 156
143 EventQueue* eventQueue = getExecutionContext()->getEventQueue(); 157 EventQueue* eventQueue = getExecutionContext()->getEventQueue();
144 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { 158 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) {
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 } 404 }
391 } 405 }
392 406
393 m_enqueuedEvents.clear(); 407 m_enqueuedEvents.clear();
394 if (m_source) 408 if (m_source)
395 m_source->contextWillBeDestroyed(); 409 m_source->contextWillBeDestroyed();
396 if (m_result) 410 if (m_result)
397 m_result->contextWillBeDestroyed(); 411 m_result->contextWillBeDestroyed();
398 if (m_pendingCursor) 412 if (m_pendingCursor)
399 m_pendingCursor->contextWillBeDestroyed(); 413 m_pendingCursor->contextWillBeDestroyed();
414 if (m_webCallbacks) {
415 m_webCallbacks->detach();
416 m_webCallbacks = nullptr;
417 }
400 } 418 }
401 419
402 const AtomicString& IDBRequest::interfaceName() const { 420 const AtomicString& IDBRequest::interfaceName() const {
403 return EventTargetNames::IDBRequest; 421 return EventTargetNames::IDBRequest;
404 } 422 }
405 423
406 ExecutionContext* IDBRequest::getExecutionContext() const { 424 ExecutionContext* IDBRequest::getExecutionContext() const {
407 return ActiveDOMObject::getExecutionContext(); 425 return ActiveDOMObject::getExecutionContext();
408 } 426 }
409 427
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 } 560 }
543 561
544 void IDBRequest::dequeueEvent(Event* event) { 562 void IDBRequest::dequeueEvent(Event* event) {
545 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { 563 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) {
546 if (m_enqueuedEvents[i].get() == event) 564 if (m_enqueuedEvents[i].get() == event)
547 m_enqueuedEvents.remove(i); 565 m_enqueuedEvents.remove(i);
548 } 566 }
549 } 567 }
550 568
551 } // namespace blink 569 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698