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

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

Issue 2595543003: Rename toV8(...) function in Blink to ToV8(...). (Closed)
Patch Set: Rebasing... Created 3 years, 11 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/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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 new BodyStreamBuffer(scriptState, new FormDataBytesConsumer(string)); 180 new BodyStreamBuffer(scriptState, new FormDataBytesConsumer(string));
181 contentType = "text/plain;charset=UTF-8"; 181 contentType = "text/plain;charset=UTF-8";
182 } 182 }
183 Response* response = 183 Response* response =
184 create(scriptState, bodyBuffer, contentType, 184 create(scriptState, bodyBuffer, contentType,
185 ResponseInit(init, exceptionState), exceptionState); 185 ResponseInit(init, exceptionState), exceptionState);
186 if (!exceptionState.hadException() && !reader.isEmpty()) { 186 if (!exceptionState.hadException() && !reader.isEmpty()) {
187 // Add a hidden reference so that the weak persistent in the 187 // Add a hidden reference so that the weak persistent in the
188 // ReadableStreamBytesConsumer will be valid as long as the 188 // ReadableStreamBytesConsumer will be valid as long as the
189 // Response is valid. 189 // Response is valid.
190 v8::Local<v8::Value> wrapper = toV8(response, scriptState); 190 v8::Local<v8::Value> wrapper = ToV8(response, scriptState);
191 if (wrapper.IsEmpty()) { 191 if (wrapper.IsEmpty()) {
192 exceptionState.throwTypeError("Cannot create a Response wrapper"); 192 exceptionState.throwTypeError("Cannot create a Response wrapper");
193 return nullptr; 193 return nullptr;
194 } 194 }
195 ASSERT(wrapper->IsObject()); 195 ASSERT(wrapper->IsObject());
196 V8HiddenValue::setHiddenValue( 196 V8HiddenValue::setHiddenValue(
197 scriptState, wrapper.As<v8::Object>(), 197 scriptState, wrapper.As<v8::Object>(),
198 V8HiddenValue::readableStreamReaderInResponse(scriptState->isolate()), 198 V8HiddenValue::readableStreamReaderInResponse(scriptState->isolate()),
199 reader.v8Value()); 199 reader.v8Value());
200 } 200 }
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 return m_response->internalURLList(); 453 return m_response->internalURLList();
454 } 454 }
455 455
456 void Response::installBody() { 456 void Response::installBody() {
457 if (!internalBodyBuffer()) 457 if (!internalBodyBuffer())
458 return; 458 return;
459 refreshBody(internalBodyBuffer()->scriptState()); 459 refreshBody(internalBodyBuffer()->scriptState());
460 } 460 }
461 461
462 void Response::refreshBody(ScriptState* scriptState) { 462 void Response::refreshBody(ScriptState* scriptState) {
463 v8::Local<v8::Value> bodyBuffer = toV8(internalBodyBuffer(), scriptState); 463 v8::Local<v8::Value> bodyBuffer = ToV8(internalBodyBuffer(), scriptState);
464 v8::Local<v8::Value> response = toV8(this, scriptState); 464 v8::Local<v8::Value> response = ToV8(this, scriptState);
465 if (response.IsEmpty()) { 465 if (response.IsEmpty()) {
466 // |toV8| can return an empty handle when the worker is terminating. 466 // |toV8| can return an empty handle when the worker is terminating.
467 // We don't want the renderer to crash in such cases. 467 // We don't want the renderer to crash in such cases.
468 // TODO(yhirano): Delete this block after the graceful shutdown 468 // TODO(yhirano): Delete this block after the graceful shutdown
469 // mechanism is introduced. 469 // mechanism is introduced.
470 return; 470 return;
471 } 471 }
472 DCHECK(response->IsObject()); 472 DCHECK(response->IsObject());
473 V8HiddenValue::setHiddenValue( 473 V8HiddenValue::setHiddenValue(
474 scriptState, response.As<v8::Object>(), 474 scriptState, response.As<v8::Object>(),
475 V8HiddenValue::internalBodyBuffer(scriptState->isolate()), bodyBuffer); 475 V8HiddenValue::internalBodyBuffer(scriptState->isolate()), bodyBuffer);
476 } 476 }
477 477
478 DEFINE_TRACE(Response) { 478 DEFINE_TRACE(Response) {
479 Body::trace(visitor); 479 Body::trace(visitor);
480 visitor->trace(m_response); 480 visitor->trace(m_response);
481 visitor->trace(m_headers); 481 visitor->trace(m_headers);
482 } 482 }
483 483
484 } // namespace blink 484 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/fetch/Request.cpp ('k') | third_party/WebKit/Source/modules/indexeddb/IDBCursor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698