| OLD | NEW |
| 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/Response.h" | 5 #include "modules/fetch/Response.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 "bindings/core/v8/ScriptState.h" | 9 #include "bindings/core/v8/ScriptState.h" |
| 10 #include "bindings/core/v8/V8BindingForTesting.h" | 10 #include "bindings/core/v8/V8BindingForTesting.h" |
| 11 #include "core/dom/Document.h" | 11 #include "core/dom/Document.h" |
| 12 #include "core/dom/ExecutionContext.h" |
| 12 #include "core/frame/Frame.h" | 13 #include "core/frame/Frame.h" |
| 13 #include "core/testing/DummyPageHolder.h" | 14 #include "core/testing/DummyPageHolder.h" |
| 14 #include "modules/fetch/BodyStreamBuffer.h" | 15 #include "modules/fetch/BodyStreamBuffer.h" |
| 15 #include "modules/fetch/BytesConsumer.h" | 16 #include "modules/fetch/BytesConsumer.h" |
| 16 #include "modules/fetch/BytesConsumerTestUtil.h" | 17 #include "modules/fetch/BytesConsumerTestUtil.h" |
| 17 #include "modules/fetch/DataConsumerHandleTestUtil.h" | 18 #include "modules/fetch/DataConsumerHandleTestUtil.h" |
| 18 #include "modules/fetch/FetchResponseData.h" | 19 #include "modules/fetch/FetchResponseData.h" |
| 19 #include "platform/blob/BlobData.h" | 20 #include "platform/blob/BlobData.h" |
| 20 #include "platform/testing/UnitTestHelpers.h" | 21 #include "platform/testing/UnitTestHelpers.h" |
| 21 #include "platform/wtf/PtrUtil.h" | 22 #include "platform/wtf/PtrUtil.h" |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 FetchDataLoader::CreateLoaderAsString(), client1); | 212 FetchDataLoader::CreateLoaderAsString(), client1); |
| 212 cloned_response->InternalBodyBuffer()->StartLoading( | 213 cloned_response->InternalBodyBuffer()->StartLoading( |
| 213 FetchDataLoader::CreateLoaderAsString(), client2); | 214 FetchDataLoader::CreateLoaderAsString(), client2); |
| 214 blink::testing::RunPendingTasks(); | 215 blink::testing::RunPendingTasks(); |
| 215 } | 216 } |
| 216 | 217 |
| 217 BodyStreamBuffer* CreateHelloWorldBuffer(ScriptState* script_state) { | 218 BodyStreamBuffer* CreateHelloWorldBuffer(ScriptState* script_state) { |
| 218 using Command = BytesConsumerTestUtil::Command; | 219 using Command = BytesConsumerTestUtil::Command; |
| 219 BytesConsumerTestUtil::ReplayingBytesConsumer* src = | 220 BytesConsumerTestUtil::ReplayingBytesConsumer* src = |
| 220 new BytesConsumerTestUtil::ReplayingBytesConsumer( | 221 new BytesConsumerTestUtil::ReplayingBytesConsumer( |
| 221 script_state->GetExecutionContext()); | 222 ExecutionContext::From(script_state)); |
| 222 src->Add(Command(Command::kData, "Hello, ")); | 223 src->Add(Command(Command::kData, "Hello, ")); |
| 223 src->Add(Command(Command::kData, "world")); | 224 src->Add(Command(Command::kData, "world")); |
| 224 src->Add(Command(Command::kDone)); | 225 src->Add(Command(Command::kDone)); |
| 225 return new BodyStreamBuffer(script_state, src); | 226 return new BodyStreamBuffer(script_state, src); |
| 226 } | 227 } |
| 227 | 228 |
| 228 TEST(ServiceWorkerResponseTest, BodyStreamBufferCloneDefault) { | 229 TEST(ServiceWorkerResponseTest, BodyStreamBufferCloneDefault) { |
| 229 V8TestingScope scope; | 230 V8TestingScope scope; |
| 230 BodyStreamBuffer* buffer = CreateHelloWorldBuffer(scope.GetScriptState()); | 231 BodyStreamBuffer* buffer = CreateHelloWorldBuffer(scope.GetScriptState()); |
| 231 FetchResponseData* fetch_response_data = | 232 FetchResponseData* fetch_response_data = |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 | 311 |
| 311 response->InternalBodyBuffer()->StartLoading( | 312 response->InternalBodyBuffer()->StartLoading( |
| 312 FetchDataLoader::CreateLoaderAsString(), client1); | 313 FetchDataLoader::CreateLoaderAsString(), client1); |
| 313 cloned_response->InternalBodyBuffer()->StartLoading( | 314 cloned_response->InternalBodyBuffer()->StartLoading( |
| 314 FetchDataLoader::CreateLoaderAsString(), client2); | 315 FetchDataLoader::CreateLoaderAsString(), client2); |
| 315 blink::testing::RunPendingTasks(); | 316 blink::testing::RunPendingTasks(); |
| 316 } | 317 } |
| 317 | 318 |
| 318 } // namespace | 319 } // namespace |
| 319 } // namespace blink | 320 } // namespace blink |
| OLD | NEW |