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 "bindings/core/v8/Dictionary.h" | 7 #include "bindings/core/v8/Dictionary.h" |
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/V8ArrayBuffer.h" | 10 #include "bindings/core/v8/V8ArrayBuffer.h" |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 | 426 |
427 void Response::installBody() | 427 void Response::installBody() |
428 { | 428 { |
429 if (!internalBodyBuffer()) | 429 if (!internalBodyBuffer()) |
430 return; | 430 return; |
431 refreshBody(internalBodyBuffer()->scriptState()); | 431 refreshBody(internalBodyBuffer()->scriptState()); |
432 } | 432 } |
433 | 433 |
434 void Response::refreshBody(ScriptState* scriptState) | 434 void Response::refreshBody(ScriptState* scriptState) |
435 { | 435 { |
436 ScriptState::Scope scope(scriptState); | |
437 v8::Local<v8::Value> bodyBuffer = toV8(internalBodyBuffer(), scriptState); | 436 v8::Local<v8::Value> bodyBuffer = toV8(internalBodyBuffer(), scriptState); |
438 v8::Local<v8::Value> response = toV8(this, scriptState); | 437 v8::Local<v8::Value> response = toV8(this, scriptState); |
439 if (response.IsEmpty()) { | 438 if (response.IsEmpty()) { |
440 // |toV8| can return an empty handle when the worker is terminating. | 439 // |toV8| can return an empty handle when the worker is terminating. |
441 // We don't want the renderer to crash in such cases. | 440 // We don't want the renderer to crash in such cases. |
442 // TODO(yhirano): Delete this block after the graceful shutdown | 441 // TODO(yhirano): Delete this block after the graceful shutdown |
443 // mechanism is introduced. | 442 // mechanism is introduced. |
444 return; | 443 return; |
445 } | 444 } |
446 DCHECK(response->IsObject()); | 445 DCHECK(response->IsObject()); |
447 V8HiddenValue::setHiddenValue(scriptState, response.As<v8::Object>(), V8Hidd
enValue::internalBodyBuffer(scriptState->isolate()), bodyBuffer); | 446 V8HiddenValue::setHiddenValue(scriptState, response.As<v8::Object>(), V8Hidd
enValue::internalBodyBuffer(scriptState->isolate()), bodyBuffer); |
448 } | 447 } |
449 | 448 |
450 DEFINE_TRACE(Response) | 449 DEFINE_TRACE(Response) |
451 { | 450 { |
452 Body::trace(visitor); | 451 Body::trace(visitor); |
453 visitor->trace(m_response); | 452 visitor->trace(m_response); |
454 visitor->trace(m_headers); | 453 visitor->trace(m_headers); |
455 } | 454 } |
456 | 455 |
457 } // namespace blink | 456 } // namespace blink |
OLD | NEW |