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

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

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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/Body.h" 5 #include "modules/fetch/Body.h"
6 6
7 #include "bindings/core/v8/ScriptPromiseResolver.h" 7 #include "bindings/core/v8/ScriptPromiseResolver.h"
8 #include "bindings/core/v8/ScriptState.h" 8 #include "bindings/core/v8/ScriptState.h"
9 #include "bindings/core/v8/V8ArrayBuffer.h" 9 #include "bindings/core/v8/V8ArrayBuffer.h"
10 #include "bindings/core/v8/V8ThrowException.h" 10 #include "bindings/core/v8/V8ThrowException.h"
11 #include "core/dom/DOMArrayBuffer.h" 11 #include "core/dom/DOMArrayBuffer.h"
12 #include "core/dom/DOMTypedArray.h" 12 #include "core/dom/DOMTypedArray.h"
13 #include "core/fileapi/Blob.h" 13 #include "core/fileapi/Blob.h"
14 #include "core/frame/UseCounter.h" 14 #include "core/frame/UseCounter.h"
15 #include "modules/fetch/BodyStreamBuffer.h" 15 #include "modules/fetch/BodyStreamBuffer.h"
16 #include "modules/fetch/FetchDataLoader.h" 16 #include "modules/fetch/FetchDataLoader.h"
17 #include "public/platform/WebDataConsumerHandle.h" 17 #include "public/platform/WebDataConsumerHandle.h"
18 #include "wtf/OwnPtr.h"
18 #include "wtf/PassRefPtr.h" 19 #include "wtf/PassRefPtr.h"
19 #include "wtf/RefPtr.h" 20 #include "wtf/RefPtr.h"
20 #include <memory>
21 21
22 namespace blink { 22 namespace blink {
23 23
24 namespace { 24 namespace {
25 25
26 class BodyConsumerBase : public GarbageCollectedFinalized<BodyConsumerBase>, pub lic FetchDataLoader::Client { 26 class BodyConsumerBase : public GarbageCollectedFinalized<BodyConsumerBase>, pub lic FetchDataLoader::Client {
27 WTF_MAKE_NONCOPYABLE(BodyConsumerBase); 27 WTF_MAKE_NONCOPYABLE(BodyConsumerBase);
28 USING_GARBAGE_COLLECTED_MIXIN(BodyConsumerBase); 28 USING_GARBAGE_COLLECTED_MIXIN(BodyConsumerBase);
29 public: 29 public:
30 explicit BodyConsumerBase(ScriptPromiseResolver* resolver) : m_resolver(reso lver) {} 30 explicit BodyConsumerBase(ScriptPromiseResolver* resolver) : m_resolver(reso lver) {}
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 134
135 // See above comment. 135 // See above comment.
136 if (!scriptState->getExecutionContext()) 136 if (!scriptState->getExecutionContext())
137 return ScriptPromise(); 137 return ScriptPromise();
138 138
139 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 139 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
140 promise = resolver->promise(); 140 promise = resolver->promise();
141 if (bodyBuffer()) { 141 if (bodyBuffer()) {
142 bodyBuffer()->startLoading(FetchDataLoader::createLoaderAsBlobHandle(mim eType()), new BodyBlobConsumer(resolver)); 142 bodyBuffer()->startLoading(FetchDataLoader::createLoaderAsBlobHandle(mim eType()), new BodyBlobConsumer(resolver));
143 } else { 143 } else {
144 std::unique_ptr<BlobData> blobData = BlobData::create(); 144 OwnPtr<BlobData> blobData = BlobData::create();
145 blobData->setContentType(mimeType()); 145 blobData->setContentType(mimeType());
146 resolver->resolve(Blob::create(BlobDataHandle::create(std::move(blobData ), 0))); 146 resolver->resolve(Blob::create(BlobDataHandle::create(std::move(blobData ), 0)));
147 } 147 }
148 return promise; 148 return promise;
149 149
150 } 150 }
151 151
152 ScriptPromise Body::json(ScriptState* scriptState) 152 ScriptPromise Body::json(ScriptState* scriptState)
153 { 153 {
154 ScriptPromise promise = rejectInvalidConsumption(scriptState); 154 ScriptPromise promise = rejectInvalidConsumption(scriptState);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 Body::Body(ExecutionContext* context) : ActiveScriptWrappable(this) , ContextLif ecycleObserver(context) {} 221 Body::Body(ExecutionContext* context) : ActiveScriptWrappable(this) , ContextLif ecycleObserver(context) {}
222 222
223 ScriptPromise Body::rejectInvalidConsumption(ScriptState* scriptState) 223 ScriptPromise Body::rejectInvalidConsumption(ScriptState* scriptState)
224 { 224 {
225 if (isBodyLocked() || bodyUsed()) 225 if (isBodyLocked() || bodyUsed())
226 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr ror(scriptState->isolate(), "Already read")); 226 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr ror(scriptState->isolate(), "Already read"));
227 return ScriptPromise(); 227 return ScriptPromise();
228 } 228 }
229 229
230 } // namespace blink 230 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698