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

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

Issue 1027593003: bindings: Use Maybe version of v8::String::NewFromUtf8() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 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 | Annotate | Revision Log
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 "config.h" 5 #include "config.h"
6 #include "modules/fetch/Body.h" 6 #include "modules/fetch/Body.h"
7 7
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/ScriptPromiseResolver.h" 9 #include "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "bindings/core/v8/ScriptState.h" 10 #include "bindings/core/v8/ScriptState.h"
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 ASSERT(m_responseType == ResponseAsJSON); 417 ASSERT(m_responseType == ResponseAsJSON);
418 ScriptState::Scope scope(m_resolver->scriptState()); 418 ScriptState::Scope scope(m_resolver->scriptState());
419 v8::Isolate* isolate = m_resolver->scriptState()->isolate(); 419 v8::Isolate* isolate = m_resolver->scriptState()->isolate();
420 v8::Local<v8::String> inputString = v8String(isolate, string); 420 v8::Local<v8::String> inputString = v8String(isolate, string);
421 v8::TryCatch trycatch; 421 v8::TryCatch trycatch;
422 v8::Local<v8::Value> parsed = v8::JSON::Parse(inputString); 422 v8::Local<v8::Value> parsed = v8::JSON::Parse(inputString);
423 if (parsed.IsEmpty()) { 423 if (parsed.IsEmpty()) {
424 if (trycatch.HasCaught()) 424 if (trycatch.HasCaught())
425 m_resolver->reject(trycatch.Exception()); 425 m_resolver->reject(trycatch.Exception());
426 else 426 else
427 m_resolver->reject(v8::Exception::Error(v8::String::NewFromUtf8(isol ate, "JSON parse error"))); 427 m_resolver->reject(v8::Exception::Error(v8NormalString(isolate, "JSO N parse error")));
428 return; 428 return;
429 } 429 }
430 m_resolver->resolve(parsed); 430 m_resolver->resolve(parsed);
431 } 431 }
432 432
433 // FileReaderLoaderClient functions. 433 // FileReaderLoaderClient functions.
434 void Body::didStartLoading() { } 434 void Body::didStartLoading() { }
435 void Body::didReceiveData() { } 435 void Body::didReceiveData() { }
436 void Body::didFinishLoading() 436 void Body::didFinishLoading()
437 { 437 {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 480
481 void Body::didBlobHandleReceiveError(PassRefPtrWillBeRawPtr<DOMException> except ion) 481 void Body::didBlobHandleReceiveError(PassRefPtrWillBeRawPtr<DOMException> except ion)
482 { 482 {
483 if (!m_resolver) 483 if (!m_resolver)
484 return; 484 return;
485 m_resolver->reject(exception); 485 m_resolver->reject(exception);
486 m_resolver.clear(); 486 m_resolver.clear();
487 } 487 }
488 488
489 } // namespace blink 489 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698