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

Side by Side Diff: Source/core/testing/Internals.cpp

Issue 23254004: Implement ScriptPromise and ScriptFunction (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Control shouldn't reach the end of a non-void function Created 7 years, 4 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
« no previous file with comments | « Source/core/testing/Internals.h ('k') | Source/core/testing/Internals.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2013 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 21 matching lines...) Expand all
32 #include "InternalProfilers.h" 32 #include "InternalProfilers.h"
33 #include "InternalRuntimeFlags.h" 33 #include "InternalRuntimeFlags.h"
34 #include "InternalSettings.h" 34 #include "InternalSettings.h"
35 #include "LayerRect.h" 35 #include "LayerRect.h"
36 #include "LayerRectList.h" 36 #include "LayerRectList.h"
37 #include "MallocStatistics.h" 37 #include "MallocStatistics.h"
38 #include "MockPagePopupDriver.h" 38 #include "MockPagePopupDriver.h"
39 #include "RuntimeEnabledFeatures.h" 39 #include "RuntimeEnabledFeatures.h"
40 #include "TypeConversions.h" 40 #include "TypeConversions.h"
41 #include "bindings/v8/ExceptionState.h" 41 #include "bindings/v8/ExceptionState.h"
42 #include "bindings/v8/ScriptFunction.h"
43 #include "bindings/v8/ScriptPromise.h"
42 #include "bindings/v8/SerializedScriptValue.h" 44 #include "bindings/v8/SerializedScriptValue.h"
43 #include "bindings/v8/V8ThrowException.h" 45 #include "bindings/v8/V8ThrowException.h"
44 #include "core/animation/DocumentTimeline.h" 46 #include "core/animation/DocumentTimeline.h"
45 #include "core/css/StyleSheetContents.h" 47 #include "core/css/StyleSheetContents.h"
46 #include "core/css/resolver/StyleResolver.h" 48 #include "core/css/resolver/StyleResolver.h"
47 #include "core/css/resolver/ViewportStyleResolver.h" 49 #include "core/css/resolver/ViewportStyleResolver.h"
48 #include "core/dom/ClientRect.h" 50 #include "core/dom/ClientRect.h"
49 #include "core/dom/ClientRectList.h" 51 #include "core/dom/ClientRectList.h"
50 #include "core/dom/DOMStringList.h" 52 #include "core/dom/DOMStringList.h"
51 #include "core/dom/Document.h" 53 #include "core/dom/Document.h"
(...skipping 2094 matching lines...) Expand 10 before | Expand all | Expand 10 after
2146 if (!sharedContext) 2148 if (!sharedContext)
2147 return false; 2149 return false;
2148 sharedContext->getExtensions()->loseContextCHROMIUM(Extensions3D::GUILTY_CON TEXT_RESET_ARB, Extensions3D::INNOCENT_CONTEXT_RESET_ARB); 2150 sharedContext->getExtensions()->loseContextCHROMIUM(Extensions3D::GUILTY_CON TEXT_RESET_ARB, Extensions3D::INNOCENT_CONTEXT_RESET_ARB);
2149 // To prevent tests that call loseSharedGraphicsContext3D from being 2151 // To prevent tests that call loseSharedGraphicsContext3D from being
2150 // flaky, we call finish so that the context is guaranteed to be lost 2152 // flaky, we call finish so that the context is guaranteed to be lost
2151 // synchronously (i.e. before returning). 2153 // synchronously (i.e. before returning).
2152 sharedContext->finish(); 2154 sharedContext->finish();
2153 return true; 2155 return true;
2154 } 2156 }
2155 2157
2158 namespace {
2159
2160 class AddOneFunction : public ScriptFunction {
2161 public:
2162 static v8::Handle<v8::Function> create()
2163 {
2164 AddOneFunction* function = new AddOneFunction;
2165 return function->releaseToV8Function();
abarth-chromium 2013/08/19 22:03:19 I'm not 100% happy with this line. I'd rather if
2166 }
2167
2168 private:
2169 virtual ScriptValue call(ScriptValue value) OVERRIDE
2170 {
2171 v8::Local<v8::Value> v8Value = value.v8Value();
2172 ASSERT(v8Value->IsNumber());
2173 int intValue = v8Value.As<v8::Integer>()->Value();
2174 ScriptValue result = ScriptValue(v8::Integer::New(intValue + 1));
2175 return result;
2176 }
2177 };
2178
2156 } 2179 }
2180
2181 ScriptValue Internals::addOneToPromise(ScriptValue promise)
2182 {
2183 ScriptValue result;
2184 bool success = ScriptPromise(promise).then(AddOneFunction::create(), result) ;
2185 RELEASE_ASSERT(success);
2186 return result;
2187 }
2188
2189 }
OLDNEW
« no previous file with comments | « Source/core/testing/Internals.h ('k') | Source/core/testing/Internals.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698