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

Unified Diff: Source/bindings/v8/custom/V8PromiseCustom.cpp

Issue 166173002: Count Promise constructor callings. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: Source/bindings/v8/custom/V8PromiseCustom.cpp
diff --git a/Source/bindings/v8/custom/V8PromiseCustom.cpp b/Source/bindings/v8/custom/V8PromiseCustom.cpp
index 66e366818b480da0a7bda3739656916d8076b59c..047607492954c3308348ccdbc5fd5bef3f5f61ed 100644
--- a/Source/bindings/v8/custom/V8PromiseCustom.cpp
+++ b/Source/bindings/v8/custom/V8PromiseCustom.cpp
@@ -44,6 +44,7 @@
#include "core/dom/Document.h"
#include "core/dom/ExecutionContextTask.h"
#include "core/frame/DOMWindow.h"
+#include "core/frame/UseCounter.h"
#include "core/inspector/InspectorInstrumentation.h"
#include "core/workers/WorkerGlobalScope.h"
#include "platform/Task.h"
@@ -486,6 +487,11 @@ void V8Promise::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& inf
{
v8SetReturnValue(info, v8::Local<v8::Value>());
v8::Isolate* isolate = info.GetIsolate();
+ ExecutionContext* executionContext = activeExecutionContext(isolate);
+ ASSERT(executionContext);
haraken 2014/02/14 07:21:39 Remove this ASSERT. This should be always non NULL
yhirano 2014/02/14 07:37:55 Done.
+ String consoleMessage("Promise API is changing and this function might be affected.");
+ executionContext->addConsoleMessage(JSMessageSource, WarningMessageLevel, consoleMessage);
+ UseCounter::count(executionContext, UseCounter::PromiseConstructor);
if (!info.Length() || !info[0]->IsFunction()) {
throwTypeError("Promise constructor takes a function argument", isolate);
return;
@@ -519,6 +525,11 @@ void V8Promise::thenMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info
void V8Promise::castMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Isolate* isolate = info.GetIsolate();
+ ExecutionContext* executionContext = activeExecutionContext(isolate);
+ ASSERT(executionContext);
+ String consoleMessage("Promise API is changing and this function might be affected.");
+ executionContext->addConsoleMessage(JSMessageSource, WarningMessageLevel, consoleMessage);
+ UseCounter::count(executionContext, UseCounter::PromiseCast);
v8::Local<v8::Value> result = v8::Undefined(isolate);
if (info.Length() > 0)
result = info[0];
@@ -544,6 +555,11 @@ void V8Promise::catchMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& inf
void V8Promise::resolveMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Isolate* isolate = info.GetIsolate();
+ ExecutionContext* executionContext = activeExecutionContext(isolate);
+ ASSERT(executionContext);
+ String consoleMessage("Promise API is changing and this function might be affected.");
+ executionContext->addConsoleMessage(JSMessageSource, WarningMessageLevel, consoleMessage);
+ UseCounter::count(executionContext, UseCounter::PromiseResolve);
v8::Local<v8::Value> result = v8::Undefined(isolate);
if (info.Length() > 0)
result = info[0];
@@ -556,6 +572,11 @@ void V8Promise::resolveMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& i
void V8Promise::rejectMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Isolate* isolate = info.GetIsolate();
+ ExecutionContext* executionContext = activeExecutionContext(isolate);
+ ASSERT(executionContext);
+ String consoleMessage("Promise API is changing and this function might be affected.");
+ executionContext->addConsoleMessage(JSMessageSource, WarningMessageLevel, consoleMessage);
+ UseCounter::count(executionContext, UseCounter::PromiseReject);
v8::Local<v8::Value> result = v8::Undefined(isolate);
if (info.Length() > 0)
result = info[0];
« no previous file with comments | « LayoutTests/fast/js/Promise-then-without-callbacks-in-workers-expected.txt ('k') | Source/core/frame/UseCounter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698