| Index: sky/engine/bindings-dart/core/dart/shared_lib/DartNativeExtensions.cpp
|
| diff --git a/sky/engine/platform/TestingPlatformSupport.cpp b/sky/engine/bindings-dart/core/dart/shared_lib/DartNativeExtensions.cpp
|
| similarity index 53%
|
| copy from sky/engine/platform/TestingPlatformSupport.cpp
|
| copy to sky/engine/bindings-dart/core/dart/shared_lib/DartNativeExtensions.cpp
|
| index d16f3bbce3f8c6e19075236339b1707fb52364af..742722d49681e665f325c38d61ee36a5a12e3b29 100644
|
| --- a/sky/engine/platform/TestingPlatformSupport.cpp
|
| +++ b/sky/engine/bindings-dart/core/dart/shared_lib/DartNativeExtensions.cpp
|
| @@ -28,62 +28,56 @@
|
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| */
|
|
|
| -#include "sky/engine/config.h"
|
| +#include "config.h"
|
|
|
| -#include "sky/engine/platform/TestingPlatformSupport.h"
|
| +#include "bindings/core/dart/shared_lib/DartNativeExtensions.h"
|
| +
|
| +#include "bindings/core/dart/DartUtilities.h"
|
|
|
| namespace blink {
|
|
|
| -TestingDiscardableMemory::TestingDiscardableMemory(size_t size) : m_data(size), m_isLocked(true)
|
| +#if defined(ENABLE_DART_NATIVE_EXTENSIONS)
|
| +Dart_Handle DartNativeExtensions::loadExtension(const String& url, Dart_Handle parentLibrary)
|
| {
|
| -}
|
| + String userUri = url.substring(String("dart-ext:").length());
|
|
|
| -TestingDiscardableMemory::~TestingDiscardableMemory()
|
| -{
|
| -}
|
| + String name;
|
| + String path;
|
| + size_t index = userUri.reverseFind('/');
|
| + if (index == kNotFound) {
|
| + name = userUri;
|
| + path = "./";
|
| + } else if (index == userUri.length() - 1) {
|
| + return Dart_NewApiError("Extension name missing.");
|
| + } else {
|
| + name = userUri.substring(index + 1);
|
| + path = userUri.substring(0, index + 1);
|
| + }
|
|
|
| -bool TestingDiscardableMemory::lock()
|
| -{
|
| - ASSERT(!m_isLocked);
|
| - m_isLocked = true;
|
| - return false;
|
| -}
|
| + void* libraryHandle = 0;
|
| + Dart_Handle result = loadExtensionLibrary(path, name, &libraryHandle);
|
| + if (Dart_IsError(result)) {
|
| + return result;
|
| + }
|
|
|
| -void* TestingDiscardableMemory::data()
|
| -{
|
| - ASSERT(m_isLocked);
|
| - return m_data.data();
|
| -}
|
| + String initFunctionName = name + "_Init";
|
|
|
| -void TestingDiscardableMemory::unlock()
|
| -{
|
| - ASSERT(m_isLocked);
|
| - m_isLocked = false;
|
| - // Force eviction to catch clients not correctly checking the return value of lock().
|
| - memset(m_data.data(), 0, m_data.size());
|
| -}
|
| + typedef Dart_Handle (*InitFunctionType)(Dart_Handle library);
|
| + InitFunctionType fn;
|
| + result = resolveSymbol(libraryHandle, initFunctionName, reinterpret_cast<void**>(&fn));
|
| + if (Dart_IsError(result)) {
|
| + return result;
|
| + }
|
|
|
| -TestingPlatformSupport::TestingPlatformSupport(const Config& config)
|
| - : m_config(config)
|
| - , m_oldPlatform(blink::Platform::current())
|
| -{
|
| - blink::Platform::initialize(this);
|
| + return (*fn)(parentLibrary);
|
| }
|
| -
|
| -TestingPlatformSupport::~TestingPlatformSupport()
|
| +#else
|
| +Dart_Handle DartNativeExtensions::loadExtension(const String& url, Dart_Handle parentLibrary)
|
| {
|
| - blink::Platform::initialize(m_oldPlatform);
|
| + return Dart_NewApiError("Native extensions are not enabled.");
|
| }
|
| +#endif // defined(ENABLE_DART_NATIVE_EXTENSIONS)
|
|
|
| -blink::WebDiscardableMemory* TestingPlatformSupport::allocateAndLockDiscardableMemory(size_t bytes)
|
| -{
|
| - return !m_config.hasDiscardableMemorySupport ? 0 : new TestingDiscardableMemory(bytes);
|
| }
|
|
|
| -const unsigned char* TestingPlatformSupport::getTraceCategoryEnabledFlag(const char* categoryName)
|
| -{
|
| - static const unsigned char tracingIsDisabled = 0;
|
| - return &tracingIsDisabled;
|
| -}
|
|
|
| -} // namespace blink
|
|
|