Index: Source/bindings/core/dart/DartCallback.cpp |
diff --git a/Source/web/DatabaseClientImpl.cpp b/Source/bindings/core/dart/DartCallback.cpp |
similarity index 57% |
copy from Source/web/DatabaseClientImpl.cpp |
copy to Source/bindings/core/dart/DartCallback.cpp |
index c53821321d294dc939f450faf90e71862ee59bfa..ef8058a26c401fa5756abad21b402c01f6c40d66 100644 |
--- a/Source/web/DatabaseClientImpl.cpp |
+++ b/Source/bindings/core/dart/DartCallback.cpp |
@@ -1,5 +1,5 @@ |
/* |
- * Copyright (C) 2013 Google Inc. All rights reserved. |
+ * Copyright (C) 2006-2011 Google Inc. All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions are |
@@ -29,43 +29,48 @@ |
*/ |
#include "config.h" |
-#include "web/DatabaseClientImpl.h" |
+#include "bindings/core/dart/DartCallback.h" |
-#include "core/dom/Document.h" |
-#include "core/dom/ExecutionContext.h" |
-#include "public/web/WebContentSettingsClient.h" |
-#include "web/WebLocalFrameImpl.h" |
+#include "bindings/core/dart/DartController.h" |
+#include "bindings/core/dart/DartDOMData.h" |
+#include "bindings/core/dart/DartUtilities.h" |
namespace blink { |
-PassOwnPtrWillBeRawPtr<DatabaseClientImpl> DatabaseClientImpl::create() |
+DartCallback::DartCallback(Dart_Handle object, Dart_Handle& exception) |
{ |
- return adoptPtrWillBeNoop(new DatabaseClientImpl()); |
+ if (!Dart_IsClosure(object)) { |
+ exception = Dart_NewStringFromCString("Callback must be a function"); |
+ m_callback = 0; |
+ return; |
+ } |
+ m_callback = Dart_NewPersistentHandle(object); |
} |
-DatabaseClientImpl::~DatabaseClientImpl() |
+DartCallback::~DartCallback() |
{ |
-} |
+ if (!m_callback || !isIsolateAlive()) |
+ return; |
-DEFINE_TRACE(DatabaseClientImpl) |
-{ |
- DatabaseClient::trace(visitor); |
+ DartIsolateScope scope(isolate()); |
+ Dart_DeletePersistentHandle(m_callback); |
} |
-bool DatabaseClientImpl::allowDatabase(ExecutionContext* executionContext, const String& name, const String& displayName, unsigned long estimatedSize) |
+bool DartCallback::handleEvent(int argc, Dart_Handle* argv) |
{ |
- ASSERT(executionContext->isContextThread()); |
- Document* document = toDocument(executionContext); |
- WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(document->frame()); |
- if (!webFrame) |
+ ASSERT(isolate() == Dart_CurrentIsolate()); |
+ ASSERT(m_callback); |
+ |
+ ExecutionContext* context = DartDOMData::current()->scriptExecutionContext(); |
+ DartController* dartController = DartController::retrieve(context); |
+ |
+ Dart_Handle result = dartController->callFunction(Dart_HandleFromPersistent(m_callback), argc, argv); |
+ if (Dart_IsError(result)) { |
+ DartUtilities::reportProblem(context, result); |
return false; |
- if (webFrame->contentSettingsClient()) |
- return webFrame->contentSettingsClient()->allowDatabase(name, displayName, estimatedSize); |
+ } |
+ |
return true; |
} |
-DatabaseClientImpl::DatabaseClientImpl() |
-{ |
} |
- |
-} // namespace blink |