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

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

Issue 2890023003: [IndexedDB] Adding async tracing for renderer calls. (Closed)
Patch Set: test fix Created 3 years, 7 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"
50 #include "platform/wtf/Time.h"
49 #include "public/platform/WebBlobInfo.h" 51 #include "public/platform/WebBlobInfo.h"
50 #include "public/platform/modules/indexeddb/WebIDBCursor.h" 52 #include "public/platform/modules/indexeddb/WebIDBCursor.h"
51 #include "public/platform/modules/indexeddb/WebIDBTypes.h" 53 #include "public/platform/modules/indexeddb/WebIDBTypes.h"
52 54
53 namespace blink { 55 namespace blink {
54 56
55 class DOMException; 57 class DOMException;
56 class ExceptionState; 58 class ExceptionState;
57 class IDBCursor; 59 class IDBCursor;
58 struct IDBDatabaseMetadata; 60 struct IDBDatabaseMetadata;
59 class IDBValue; 61 class IDBValue;
60 62
61 class MODULES_EXPORT IDBRequest : public EventTargetWithInlineData, 63 class MODULES_EXPORT IDBRequest : public EventTargetWithInlineData,
62 public ActiveScriptWrappable<IDBRequest>, 64 public ActiveScriptWrappable<IDBRequest>,
63 public SuspendableObject { 65 public SuspendableObject {
64 DEFINE_WRAPPERTYPEINFO(); 66 DEFINE_WRAPPERTYPEINFO();
65 USING_GARBAGE_COLLECTED_MIXIN(IDBRequest); 67 USING_GARBAGE_COLLECTED_MIXIN(IDBRequest);
66 68
67 public: 69 public:
68 static IDBRequest* Create(ScriptState*, IDBAny* source, IDBTransaction*); 70 // Records async tracing, starting on contruction and ending on destruction or
71 // a to |RecordAndReset()|.
pwnall 2017/05/25 23:04:25 a call to?
dmurph 2017/05/31 19:26:25 Done.
72 class AsyncTraceState {
73 public:
74 AsyncTraceState();
75 AsyncTraceState(const char* tracing_name, void*);
76 ~AsyncTraceState();
77 AsyncTraceState(AsyncTraceState&&);
78 IDBRequest::AsyncTraceState& operator=(IDBRequest::AsyncTraceState&&);
79
80 bool is_valid() const { return tracing_name_; }
81 void RecordAndReset();
82
83 private:
84 const char* tracing_name_ = nullptr;
85 void* id_;
86
87 DISALLOW_COPY_AND_ASSIGN(AsyncTraceState);
88 };
89
90 static IDBRequest* Create(ScriptState*,
91 IDBAny* source,
92 IDBTransaction*,
93 AsyncTraceState);
69 ~IDBRequest() override; 94 ~IDBRequest() override;
70 DECLARE_VIRTUAL_TRACE(); 95 DECLARE_VIRTUAL_TRACE();
71 96
72 v8::Isolate* GetIsolate() const { return isolate_; } 97 v8::Isolate* GetIsolate() const { return isolate_; }
73 ScriptValue result(ScriptState*, ExceptionState&); 98 ScriptValue result(ScriptState*, ExceptionState&);
74 DOMException* error(ExceptionState&) const; 99 DOMException* error(ExceptionState&) const;
75 ScriptValue source(ScriptState*) const; 100 ScriptValue source(ScriptState*) const;
76 IDBTransaction* transaction() const { return transaction_.Get(); } 101 IDBTransaction* transaction() const { return transaction_.Get(); }
77 102
78 bool isResultDirty() const { return result_dirty_; } 103 bool isResultDirty() const { return result_dirty_; }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 // the upcoming "success" or "error"). 171 // the upcoming "success" or "error").
147 void TransactionDidFinishAndDispatch(); 172 void TransactionDidFinishAndDispatch();
148 173
149 IDBCursor* GetResultCursor() const; 174 IDBCursor* GetResultCursor() const;
150 175
151 void StorePutOperationBlobs( 176 void StorePutOperationBlobs(
152 HashMap<String, RefPtr<BlobDataHandle>> blob_handles) { 177 HashMap<String, RefPtr<BlobDataHandle>> blob_handles) {
153 transit_blob_handles_ = std::move(blob_handles); 178 transit_blob_handles_ = std::move(blob_handles);
154 } 179 }
155 180
181 void AssignNewMetrics(AsyncTraceState metrics) {
182 DCHECK(!metrics_.is_valid());
183 metrics_ = std::move(metrics);
184 }
185
156 protected: 186 protected:
157 IDBRequest(ScriptState*, IDBAny* source, IDBTransaction*); 187 IDBRequest(ScriptState*, IDBAny* source, IDBTransaction*, AsyncTraceState);
158 void EnqueueEvent(Event*); 188 void EnqueueEvent(Event*);
159 void DequeueEvent(Event*); 189 void DequeueEvent(Event*);
160 virtual bool ShouldEnqueueEvent() const; 190 virtual bool ShouldEnqueueEvent() const;
161 void EnqueueResultInternal(IDBAny*); 191 void EnqueueResultInternal(IDBAny*);
162 void SetResult(IDBAny*); 192 void SetResult(IDBAny*);
163 193
164 // EventTarget 194 // EventTarget
165 DispatchEventResult DispatchEventInternal(Event*) override; 195 DispatchEventResult DispatchEventInternal(Event*) override;
166 196
167 Member<IDBTransaction> transaction_; 197 Member<IDBTransaction> transaction_;
(...skipping 11 matching lines...) Expand all
179 PassRefPtr<IDBValue>); 209 PassRefPtr<IDBValue>);
180 void AckReceivedBlobs(const IDBValue*); 210 void AckReceivedBlobs(const IDBValue*);
181 void AckReceivedBlobs(const Vector<RefPtr<IDBValue>>&); 211 void AckReceivedBlobs(const Vector<RefPtr<IDBValue>>&);
182 212
183 void ClearPutOperationBlobs() { transit_blob_handles_.clear(); } 213 void ClearPutOperationBlobs() { transit_blob_handles_.clear(); }
184 214
185 Member<IDBAny> source_; 215 Member<IDBAny> source_;
186 Member<IDBAny> result_; 216 Member<IDBAny> result_;
187 Member<DOMException> error_; 217 Member<DOMException> error_;
188 218
219 AsyncTraceState metrics_;
220
189 bool has_pending_activity_ = true; 221 bool has_pending_activity_ = true;
190 HeapVector<Member<Event>> enqueued_events_; 222 HeapVector<Member<Event>> enqueued_events_;
191 223
192 // Only used if the result type will be a cursor. 224 // Only used if the result type will be a cursor.
193 IndexedDB::CursorType cursor_type_ = IndexedDB::kCursorKeyAndValue; 225 IndexedDB::CursorType cursor_type_ = IndexedDB::kCursorKeyAndValue;
194 WebIDBCursorDirection cursor_direction_ = kWebIDBCursorDirectionNext; 226 WebIDBCursorDirection cursor_direction_ = kWebIDBCursorDirectionNext;
195 // When a cursor is continued/advanced, |result_| is cleared and 227 // When a cursor is continued/advanced, |result_| is cleared and
196 // |pendingCursor_| holds it. 228 // |pendingCursor_| holds it.
197 Member<IDBCursor> pending_cursor_; 229 Member<IDBCursor> pending_cursor_;
198 // New state is not applied to the cursor object until the event is 230 // New state is not applied to the cursor object until the event is
(...skipping 15 matching lines...) Expand all
214 bool did_throw_in_event_handler_ = false; 246 bool did_throw_in_event_handler_ = false;
215 247
216 // Pointer back to the WebIDBCallbacks that holds a persistent reference to 248 // Pointer back to the WebIDBCallbacks that holds a persistent reference to
217 // this object. 249 // this object.
218 WebIDBCallbacks* web_callbacks_ = nullptr; 250 WebIDBCallbacks* web_callbacks_ = nullptr;
219 }; 251 };
220 252
221 } // namespace blink 253 } // namespace blink
222 254
223 #endif // IDBRequest_h 255 #endif // IDBRequest_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698