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

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

Issue 2890023003: [IndexedDB] Adding async tracing for renderer calls. (Closed)
Patch Set: fixed blink tests Created 3 years, 6 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 13 matching lines...) Expand all
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #ifndef IDBRequest_h 29 #ifndef IDBRequest_h
30 #define IDBRequest_h 30 #define IDBRequest_h
31 31
32 #include <memory> 32 #include <memory>
33 33
34 #include "base/macros.h"
34 #include "bindings/core/v8/ScriptValue.h" 35 #include "bindings/core/v8/ScriptValue.h"
35 #include "core/dom/DOMStringList.h" 36 #include "core/dom/DOMStringList.h"
36 #include "core/dom/SuspendableObject.h" 37 #include "core/dom/SuspendableObject.h"
37 #include "core/events/EventListener.h" 38 #include "core/events/EventListener.h"
38 #include "core/events/EventTarget.h" 39 #include "core/events/EventTarget.h"
39 #include "modules/EventModules.h" 40 #include "modules/EventModules.h"
40 #include "modules/ModulesExport.h" 41 #include "modules/ModulesExport.h"
41 #include "modules/indexeddb/IDBAny.h" 42 #include "modules/indexeddb/IDBAny.h"
42 #include "modules/indexeddb/IDBTransaction.h" 43 #include "modules/indexeddb/IDBTransaction.h"
43 #include "modules/indexeddb/IndexedDB.h" 44 #include "modules/indexeddb/IndexedDB.h"
44 #include "platform/bindings/ActiveScriptWrappable.h" 45 #include "platform/bindings/ActiveScriptWrappable.h"
45 #include "platform/bindings/ScriptState.h" 46 #include "platform/bindings/ScriptState.h"
46 #include "platform/blob/BlobData.h" 47 #include "platform/blob/BlobData.h"
47 #include "platform/heap/Handle.h" 48 #include "platform/heap/Handle.h"
48 #include "platform/wtf/HashMap.h" 49 #include "platform/wtf/HashMap.h"
49 #include "platform/wtf/RefPtr.h" 50 #include "platform/wtf/RefPtr.h"
51 #include "platform/wtf/Time.h"
50 #include "public/platform/WebBlobInfo.h" 52 #include "public/platform/WebBlobInfo.h"
51 #include "public/platform/modules/indexeddb/WebIDBCursor.h" 53 #include "public/platform/modules/indexeddb/WebIDBCursor.h"
52 #include "public/platform/modules/indexeddb/WebIDBTypes.h" 54 #include "public/platform/modules/indexeddb/WebIDBTypes.h"
53 55
54 namespace blink { 56 namespace blink {
55 57
56 class DOMException; 58 class DOMException;
57 class ExceptionState; 59 class ExceptionState;
58 class IDBCursor; 60 class IDBCursor;
59 struct IDBDatabaseMetadata; 61 struct IDBDatabaseMetadata;
60 class IDBValue; 62 class IDBValue;
61 63
62 class MODULES_EXPORT IDBRequest : public EventTargetWithInlineData, 64 class MODULES_EXPORT IDBRequest : public EventTargetWithInlineData,
63 public ActiveScriptWrappable<IDBRequest>, 65 public ActiveScriptWrappable<IDBRequest>,
64 public SuspendableObject { 66 public SuspendableObject {
65 DEFINE_WRAPPERTYPEINFO(); 67 DEFINE_WRAPPERTYPEINFO();
66 USING_GARBAGE_COLLECTED_MIXIN(IDBRequest); 68 USING_GARBAGE_COLLECTED_MIXIN(IDBRequest);
67 69
68 public: 70 public:
69 static IDBRequest* Create(ScriptState*, IDBAny* source, IDBTransaction*); 71 // Records async tracing, starting on contruction and ending on destruction or
72 // a call to |RecordAndReset()|.
73 class AsyncTraceState {
74 public:
75 AsyncTraceState() {}
76 AsyncTraceState(const char* tracing_name, void*);
77 ~AsyncTraceState();
78 AsyncTraceState(AsyncTraceState&& other) {
79 this->tracing_name_ = other.tracing_name_;
80 this->id_ = other.id_;
81 other.tracing_name_ = nullptr;
82 }
83 AsyncTraceState& operator=(AsyncTraceState&& rhs) {
84 this->tracing_name_ = rhs.tracing_name_;
85 this->id_ = rhs.id_;
86 rhs.tracing_name_ = nullptr;
87 return *this;
88 }
89
90 bool is_valid() const { return tracing_name_; }
91 void RecordAndReset();
92
93 private:
94 const char* tracing_name_ = nullptr;
95 void* id_;
96
97 DISALLOW_COPY_AND_ASSIGN(AsyncTraceState);
98 };
99
100 static IDBRequest* Create(ScriptState*,
101 IDBAny* source,
102 IDBTransaction*,
103 AsyncTraceState);
70 ~IDBRequest() override; 104 ~IDBRequest() override;
71 DECLARE_VIRTUAL_TRACE(); 105 DECLARE_VIRTUAL_TRACE();
72 106
73 v8::Isolate* GetIsolate() const { return isolate_; } 107 v8::Isolate* GetIsolate() const { return isolate_; }
74 ScriptValue result(ScriptState*, ExceptionState&); 108 ScriptValue result(ScriptState*, ExceptionState&);
75 DOMException* error(ExceptionState&) const; 109 DOMException* error(ExceptionState&) const;
76 ScriptValue source(ScriptState*) const; 110 ScriptValue source(ScriptState*) const;
77 IDBTransaction* transaction() const { return transaction_.Get(); } 111 IDBTransaction* transaction() const { return transaction_.Get(); }
78 112
79 bool isResultDirty() const { return result_dirty_; } 113 bool isResultDirty() const { return result_dirty_; }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 #if DCHECK_IS_ON() 245 #if DCHECK_IS_ON()
212 inline bool TransactionHasQueuedResults() const { 246 inline bool TransactionHasQueuedResults() const {
213 return transaction_ && transaction_->HasQueuedResults(); 247 return transaction_ && transaction_->HasQueuedResults();
214 } 248 }
215 #endif // DCHECK_IS_ON() 249 #endif // DCHECK_IS_ON()
216 250
217 #if DCHECK_IS_ON() 251 #if DCHECK_IS_ON()
218 inline IDBRequestQueueItem* QueueItem() const { return queue_item_; } 252 inline IDBRequestQueueItem* QueueItem() const { return queue_item_; }
219 #endif // DCHECK_IS_ON() 253 #endif // DCHECK_IS_ON()
220 254
255 void AssignNewMetrics(AsyncTraceState metrics) {
256 DCHECK(!metrics_.is_valid());
257 metrics_ = std::move(metrics);
258 }
259
221 protected: 260 protected:
222 IDBRequest(ScriptState*, IDBAny* source, IDBTransaction*); 261 IDBRequest(ScriptState*, IDBAny* source, IDBTransaction*, AsyncTraceState);
223 void EnqueueEvent(Event*); 262 void EnqueueEvent(Event*);
224 void DequeueEvent(Event*); 263 void DequeueEvent(Event*);
225 virtual bool ShouldEnqueueEvent() const; 264 virtual bool ShouldEnqueueEvent() const;
226 void EnqueueResultInternal(IDBAny*); 265 void EnqueueResultInternal(IDBAny*);
227 void SetResult(IDBAny*); 266 void SetResult(IDBAny*);
228 267
229 // Overridden by IDBOpenDBRequest. 268 // Overridden by IDBOpenDBRequest.
230 virtual void EnqueueResponse(int64_t); 269 virtual void EnqueueResponse(int64_t);
231 270
232 // EventTarget 271 // EventTarget
(...skipping 25 matching lines...) Expand all
258 void EnqueueResponse(IDBKey*); 297 void EnqueueResponse(IDBKey*);
259 void EnqueueResponse(std::unique_ptr<WebIDBCursor>, 298 void EnqueueResponse(std::unique_ptr<WebIDBCursor>,
260 IDBKey*, 299 IDBKey*,
261 IDBKey* primary_key, 300 IDBKey* primary_key,
262 RefPtr<IDBValue>&&); 301 RefPtr<IDBValue>&&);
263 void EnqueueResponse(IDBKey*, IDBKey* primary_key, RefPtr<IDBValue>&&); 302 void EnqueueResponse(IDBKey*, IDBKey* primary_key, RefPtr<IDBValue>&&);
264 void EnqueueResponse(RefPtr<IDBValue>&&); 303 void EnqueueResponse(RefPtr<IDBValue>&&);
265 void EnqueueResponse(const Vector<RefPtr<IDBValue>>&); 304 void EnqueueResponse(const Vector<RefPtr<IDBValue>>&);
266 void EnqueueResponse(); 305 void EnqueueResponse();
267 306
307 void ClearPutOperationBlobs() { transit_blob_handles_.clear(); }
308
268 Member<IDBAny> source_; 309 Member<IDBAny> source_;
269 Member<IDBAny> result_; 310 Member<IDBAny> result_;
270 Member<DOMException> error_; 311 Member<DOMException> error_;
271 312
313 AsyncTraceState metrics_;
314
272 bool has_pending_activity_ = true; 315 bool has_pending_activity_ = true;
273 HeapVector<Member<Event>> enqueued_events_; 316 HeapVector<Member<Event>> enqueued_events_;
274 317
275 // Only used if the result type will be a cursor. 318 // Only used if the result type will be a cursor.
276 IndexedDB::CursorType cursor_type_ = IndexedDB::kCursorKeyAndValue; 319 IndexedDB::CursorType cursor_type_ = IndexedDB::kCursorKeyAndValue;
277 WebIDBCursorDirection cursor_direction_ = kWebIDBCursorDirectionNext; 320 WebIDBCursorDirection cursor_direction_ = kWebIDBCursorDirectionNext;
278 // When a cursor is continued/advanced, |result_| is cleared and 321 // When a cursor is continued/advanced, |result_| is cleared and
279 // |pendingCursor_| holds it. 322 // |pendingCursor_| holds it.
280 Member<IDBCursor> pending_cursor_; 323 Member<IDBCursor> pending_cursor_;
281 // New state is not applied to the cursor object until the event is 324 // New state is not applied to the cursor object until the event is
(...skipping 21 matching lines...) Expand all
303 // Non-null while this request is queued behind other requests that are still 346 // Non-null while this request is queued behind other requests that are still
304 // getting post-processed. 347 // getting post-processed.
305 // 348 //
306 // The IDBRequestQueueItem is owned by the result queue in IDBTransaction. 349 // The IDBRequestQueueItem is owned by the result queue in IDBTransaction.
307 IDBRequestQueueItem* queue_item_ = nullptr; 350 IDBRequestQueueItem* queue_item_ = nullptr;
308 }; 351 };
309 352
310 } // namespace blink 353 } // namespace blink
311 354
312 #endif // IDBRequest_h 355 #endif // IDBRequest_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698