Index: third_party/WebKit/Source/core/workers/ThreadedWorkletObjectProxy.cpp |
diff --git a/third_party/WebKit/Source/modules/webdatabase/SQLTransactionClient.cpp b/third_party/WebKit/Source/core/workers/ThreadedWorkletObjectProxy.cpp |
similarity index 39% |
copy from third_party/WebKit/Source/modules/webdatabase/SQLTransactionClient.cpp |
copy to third_party/WebKit/Source/core/workers/ThreadedWorkletObjectProxy.cpp |
index f6d53a08e8102be7adea845eb66757d2edc1499b..36a2314f3e344cb2eabd33c33e5e455b3b426ddd 100644 |
--- a/third_party/WebKit/Source/modules/webdatabase/SQLTransactionClient.cpp |
+++ b/third_party/WebKit/Source/core/workers/ThreadedWorkletObjectProxy.cpp |
@@ -1,5 +1,5 @@ |
/* |
- * Copyright (C) 2009 Google Inc. All rights reserved. |
+ * Copyright (C) 2013 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 |
@@ -28,53 +28,69 @@ |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
-#include "modules/webdatabase/SQLTransactionClient.h" |
+#include "core/workers/ThreadedWorkletObjectProxy.h" |
+#include "bindings/core/v8/SerializedScriptValue.h" |
+#include "bindings/core/v8/SourceLocation.h" |
+#include "core/dom/Document.h" |
#include "core/dom/ExecutionContext.h" |
#include "core/dom/ExecutionContextTask.h" |
-#include "modules/webdatabase/Database.h" |
-#include "modules/webdatabase/DatabaseContext.h" |
-#include "platform/weborigin/SecurityOrigin.h" |
-#include "public/platform/Platform.h" |
-#include "public/platform/WebDatabaseObserver.h" |
-#include "public/platform/WebSecurityOrigin.h" |
-#include "public/platform/WebTraceLocation.h" |
+#include "core/inspector/ConsoleMessage.h" |
+#include "core/workers/ThreadedWorkletMessagingProxy.h" |
#include "wtf/Functional.h" |
+#include "wtf/PtrUtil.h" |
+#include <memory> |
namespace blink { |
-namespace { |
+std::unique_ptr<ThreadedWorkletObjectProxy> ThreadedWorkletObjectProxy::create(ThreadedWorkletMessagingProxy* messagingProxy) |
+{ |
+ DCHECK(messagingProxy); |
+ return wrapUnique(new ThreadedWorkletObjectProxy(messagingProxy)); |
+} |
-void databaseModified(const WebSecurityOrigin& origin, const String& databaseName) |
+void ThreadedWorkletObjectProxy::postTaskToMainExecutionContext(std::unique_ptr<ExecutionContextTask> task) |
{ |
- if (Platform::current()->databaseObserver()) |
- Platform::current()->databaseObserver()->databaseModified(origin, databaseName); |
+ getExecutionContext()->postTask(BLINK_FROM_HERE, std::move(task)); |
} |
-void databaseModifiedCrossThread(const String& originString, const String& databaseName) |
+void ThreadedWorkletObjectProxy::reportPendingActivity(bool hasPendingActivity) |
{ |
- databaseModified(WebSecurityOrigin::createFromString(originString), databaseName); |
+ getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&ThreadedWorkletMessagingProxy::reportPendingActivity, crossThreadUnretained(m_messagingProxy), hasPendingActivity)); |
} |
-} // namespace |
+void ThreadedWorkletObjectProxy::reportConsoleMessage(MessageSource source, MessageLevel level, const String& message, SourceLocation* location) |
+{ |
+ getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&ThreadedWorkletMessagingProxy::reportConsoleMessage, crossThreadUnretained(m_messagingProxy), source, level, message, passed(location->clone()))); |
+} |
+ |
+void ThreadedWorkletObjectProxy::postMessageToPageInspector(const String& message) |
+{ |
+ ExecutionContext* context = getExecutionContext(); |
+ if (context->isDocument()) |
+ toDocument(context)->postInspectorTask(BLINK_FROM_HERE, createCrossThreadTask(&ThreadedWorkletMessagingProxy::postMessageToPageInspector, crossThreadUnretained(m_messagingProxy), message)); |
+} |
+ |
+void ThreadedWorkletObjectProxy::workerGlobalScopeClosed() |
+{ |
+ getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&ThreadedWorkletMessagingProxy::terminateWorkletGlobalScope, crossThreadUnretained(m_messagingProxy))); |
+} |
+ |
+void ThreadedWorkletObjectProxy::workerThreadTerminated() |
+{ |
+ // This will terminate the MessagingProxy. |
+ getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&ThreadedWorkletMessagingProxy::workerThreadTerminated, crossThreadUnretained(m_messagingProxy))); |
+} |
-void SQLTransactionClient::didCommitWriteTransaction(Database* database) |
+ThreadedWorkletObjectProxy::ThreadedWorkletObjectProxy(ThreadedWorkletMessagingProxy* messagingProxy) |
+ : m_messagingProxy(messagingProxy) |
{ |
- String databaseName = database->stringIdentifier(); |
- ExecutionContext* executionContext = database->getDatabaseContext()->getExecutionContext(); |
- if (!executionContext->isContextThread()) { |
- executionContext->postTask(BLINK_FROM_HERE, createCrossThreadTask(&databaseModifiedCrossThread, executionContext->getSecurityOrigin()->toRawString(), databaseName)); |
- } else { |
- databaseModified(WebSecurityOrigin(executionContext->getSecurityOrigin()), databaseName); |
- } |
} |
-bool SQLTransactionClient::didExceedQuota(Database* database) |
+ExecutionContext* ThreadedWorkletObjectProxy::getExecutionContext() const |
{ |
- // Chromium does not allow users to manually change the quota for an origin (for now, at least). |
- // Don't do anything. |
- ASSERT(database->getDatabaseContext()->getExecutionContext()->isContextThread()); |
- return false; |
+ DCHECK(m_messagingProxy); |
+ return m_messagingProxy->getExecutionContext(); |
} |
} // namespace blink |