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

Side by Side Diff: third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp

Issue 2915863003: [Not for review] Add traces for crbug.com/726626
Patch Set: 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/fetch/BodyStreamBuffer.h" 5 #include "modules/fetch/BodyStreamBuffer.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "core/dom/DOMArrayBuffer.h" 9 #include "core/dom/DOMArrayBuffer.h"
10 #include "core/dom/DOMTypedArray.h" 10 #include "core/dom/DOMTypedArray.h"
11 #include "core/dom/ExceptionCode.h" 11 #include "core/dom/ExceptionCode.h"
12 #include "core/dom/ExecutionContext.h" 12 #include "core/dom/ExecutionContext.h"
13 #include "core/streams/ReadableStreamController.h" 13 #include "core/streams/ReadableStreamController.h"
14 #include "core/streams/ReadableStreamOperations.h" 14 #include "core/streams/ReadableStreamOperations.h"
15 #include "modules/fetch/Body.h" 15 #include "modules/fetch/Body.h"
16 #include "modules/fetch/ReadableStreamBytesConsumer.h" 16 #include "modules/fetch/ReadableStreamBytesConsumer.h"
17 #include "platform/bindings/ScriptState.h" 17 #include "platform/bindings/ScriptState.h"
18 #include "platform/bindings/V8PrivateProperty.h" 18 #include "platform/bindings/V8PrivateProperty.h"
19 #include "platform/bindings/V8ThrowException.h" 19 #include "platform/bindings/V8ThrowException.h"
20 #include "platform/blob/BlobData.h" 20 #include "platform/blob/BlobData.h"
21 #include "platform/instrumentation/tracing/TraceEvent.h"
21 #include "platform/network/EncodedFormData.h" 22 #include "platform/network/EncodedFormData.h"
22 23
23 namespace blink { 24 namespace blink {
24 25
25 class BodyStreamBuffer::LoaderClient final 26 class BodyStreamBuffer::LoaderClient final
26 : public GarbageCollectedFinalized<LoaderClient>, 27 : public GarbageCollectedFinalized<LoaderClient>,
27 public ContextLifecycleObserver, 28 public ContextLifecycleObserver,
28 public FetchDataLoader::Client { 29 public FetchDataLoader::Client {
29 WTF_MAKE_NONCOPYABLE(LoaderClient); 30 WTF_MAKE_NONCOPYABLE(LoaderClient);
30 USING_GARBAGE_COLLECTED_MIXIN(LoaderClient); 31 USING_GARBAGE_COLLECTED_MIXIN(LoaderClient);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 Member<BodyStreamBuffer> buffer_; 87 Member<BodyStreamBuffer> buffer_;
87 Member<FetchDataLoader::Client> client_; 88 Member<FetchDataLoader::Client> client_;
88 }; 89 };
89 90
90 BodyStreamBuffer::BodyStreamBuffer(ScriptState* script_state, 91 BodyStreamBuffer::BodyStreamBuffer(ScriptState* script_state,
91 BytesConsumer* consumer) 92 BytesConsumer* consumer)
92 : UnderlyingSourceBase(script_state), 93 : UnderlyingSourceBase(script_state),
93 script_state_(script_state), 94 script_state_(script_state),
94 consumer_(consumer), 95 consumer_(consumer),
95 made_from_readable_stream_(false) { 96 made_from_readable_stream_(false) {
97 TRACE_EVENT0("ServiceWorker", "BodyStreamBuffer::BodyStreamBuffer");
96 v8::Local<v8::Value> body_value = ToV8(this, script_state); 98 v8::Local<v8::Value> body_value = ToV8(this, script_state);
97 DCHECK(!body_value.IsEmpty()); 99 DCHECK(!body_value.IsEmpty());
98 DCHECK(body_value->IsObject()); 100 DCHECK(body_value->IsObject());
99 v8::Local<v8::Object> body = body_value.As<v8::Object>(); 101 v8::Local<v8::Object> body = body_value.As<v8::Object>();
100 102
101 ScriptValue readable_stream = ReadableStreamOperations::CreateReadableStream( 103 ScriptValue readable_stream;
102 script_state, this, 104 {
103 ReadableStreamOperations::CreateCountQueuingStrategy(script_state, 0)); 105 TRACE_EVENT0("ServiceWorker",
106 "BodyStreamBuffer::BodyStreamBuffer CreateReadableStream");
107 readable_stream = ReadableStreamOperations::CreateReadableStream(
108 script_state, this,
109 ReadableStreamOperations::CreateCountQueuingStrategy(script_state, 0));
110 }
104 DCHECK(!readable_stream.IsEmpty()); 111 DCHECK(!readable_stream.IsEmpty());
105 V8PrivateProperty::GetInternalBodyStream(script_state->GetIsolate()) 112 {
106 .Set(body, readable_stream.V8Value()); 113 TRACE_EVENT0("ServiceWorker",
114 "BodyStreamBuffer::BodyStreamBuffer GetInternalBodyStream");
115 V8PrivateProperty::GetInternalBodyStream(script_state->GetIsolate())
116 .Set(body, readable_stream.V8Value());
117 }
107 consumer_->SetClient(this); 118 consumer_->SetClient(this);
108 OnStateChange(); 119 OnStateChange();
109 } 120 }
110 121
111 BodyStreamBuffer::BodyStreamBuffer(ScriptState* script_state, 122 BodyStreamBuffer::BodyStreamBuffer(ScriptState* script_state,
112 ScriptValue stream) 123 ScriptValue stream)
113 : UnderlyingSourceBase(script_state), 124 : UnderlyingSourceBase(script_state),
114 script_state_(script_state), 125 script_state_(script_state),
115 made_from_readable_stream_(true) { 126 made_from_readable_stream_(true) {
116 DCHECK(ReadableStreamOperations::IsReadableStream(script_state, stream)); 127 DCHECK(ReadableStreamOperations::IsReadableStream(script_state, stream));
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 } 405 }
395 if (is_errored) 406 if (is_errored)
396 return BytesConsumer::CreateErrored(BytesConsumer::Error("error")); 407 return BytesConsumer::CreateErrored(BytesConsumer::Error("error"));
397 408
398 DCHECK(consumer); 409 DCHECK(consumer);
399 consumer->ClearClient(); 410 consumer->ClearClient();
400 return consumer; 411 return consumer;
401 } 412 }
402 413
403 } // namespace blink 414 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698