Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 581 | 581 |
| 582 // Store a timestamp to the cache as hint. | 582 // Store a timestamp to the cache as hint. |
| 583 void V8ScriptRunner::setCacheTimeStamp(CachedMetadataHandler* cacheHandler) | 583 void V8ScriptRunner::setCacheTimeStamp(CachedMetadataHandler* cacheHandler) |
| 584 { | 584 { |
| 585 double now = WTF::currentTime(); | 585 double now = WTF::currentTime(); |
| 586 unsigned tag = cacheTag(CacheTagTimeStamp, cacheHandler); | 586 unsigned tag = cacheTag(CacheTagTimeStamp, cacheHandler); |
| 587 cacheHandler->clearCachedMetadata(CachedMetadataHandler::CacheLocally); | 587 cacheHandler->clearCachedMetadata(CachedMetadataHandler::CacheLocally); |
| 588 cacheHandler->setCachedMetadata(tag, reinterpret_cast<char*>(&now), sizeof(n ow), CachedMetadataHandler::SendToPlatform); | 588 cacheHandler->setCachedMetadata(tag, reinterpret_cast<char*>(&now), sizeof(n ow), CachedMetadataHandler::SendToPlatform); |
| 589 } | 589 } |
| 590 | 590 |
| 591 void V8ScriptRunner::throwException(v8::Isolate* isolate, v8::Local<v8::Value> e xception, const v8::ScriptOrigin& origin) | |
| 592 { | |
| 593 // Use V8ThrowException instead of this function unless absolutely needed. | |
|
Yuki
2016/08/22 06:42:08
Thanks for the caution, but it's better to put thi
| |
| 594 // In order for the current TryCatch to catch this exception and | |
| 595 // call MessageCallback when SetVerbose(true), create a v8::Function | |
| 596 // that calls isolate->throwException(). | |
| 597 // Unlike throwStackOverflowExceptionIfNeeded(), create a temporary Script | |
| 598 // with the specified ScriptOrigin. When the exception was created but not | |
| 599 // thrown yet, the ScriptOrigin of the thrower is set to the exception. | |
| 600 // v8::Function::New() has empty ScriptOrigin, and thus the exception will | |
| 601 // be "muted" (sanitized in our terminology) if CORS does not allow. | |
| 602 // https://html.spec.whatwg.org/multipage/webappapis.html#report-the-error | |
| 603 v8::Local<v8::Script> script = compileWithoutOptions( | |
| 604 V8CompileHistogram::Cacheability::Noncacheable, isolate, | |
| 605 v8AtomicString(isolate, "((e) => { throw e; })"), origin) | |
| 606 .ToLocalChecked(); | |
| 607 v8::Local<v8::Function> thrower = runCompiledInternalScript(isolate, script) | |
|
haraken
2016/08/22 06:36:47
It's silly that we have to compile the script ever
| |
| 608 .ToLocalChecked().As<v8::Function>(); | |
| 609 callInternalFunction(thrower, thrower, 1, &exception, isolate); | |
|
haraken
2016/08/22 06:36:47
I'd prefer creating an array.
v8::Local<v8::Value
| |
| 610 } | |
| 611 | |
| 591 } // namespace blink | 612 } // namespace blink |
| OLD | NEW |