316 lines
13 KiB
Diff
316 lines
13 KiB
Diff
From 66b5e193f3fc4d1bdc579b1051dc76aa90d3b61e Mon Sep 17 00:00:00 2001
|
|
From: Christophe Chapuis <chris.chapuis@gmail.com>
|
|
Date: Sun, 16 Jul 2017 11:09:09 +0000
|
|
Subject: [PATCH 02/10] PalmServiceBridge: adapt to Chromium 53 code base
|
|
|
|
Signed-off-by: Christophe Chapuis <chris.chapuis@gmail.com>
|
|
---
|
|
.../Source/bindings/modules/v8/generated.gni | 2 +
|
|
.../WebKit/Source/modules/webos/BUILD.gn | 14 +++++++
|
|
.../WebKit/Source/modules/webos/LunaServiceMgr.cpp | 4 +-
|
|
.../Source/modules/webos/PalmServiceBridge.cpp | 43 +++++++---------------
|
|
.../Source/modules/webos/PalmServiceBridge.h | 36 +++++++++---------
|
|
.../Source/modules/webos/PalmServiceBridge.idl | 5 ++-
|
|
6 files changed, 52 insertions(+), 52 deletions(-)
|
|
|
|
diff --git a/src/3rdparty/chromium/third_party/WebKit/Source/bindings/modules/v8/generated.gni b/src/3rdparty/chromium/third_party/WebKit/Source/bindings/modules/v8/generated.gni
|
|
index 0d8f27d..db9b850 100644
|
|
--- a/src/3rdparty/chromium/third_party/WebKit/Source/bindings/modules/v8/generated.gni
|
|
+++ b/src/3rdparty/chromium/third_party/WebKit/Source/bindings/modules/v8/generated.gni
|
|
@@ -46,6 +46,8 @@ bindings_modules_generated_union_type_files = [
|
|
"$bindings_modules_v8_output_dir/RenderingContext.h",
|
|
"$bindings_modules_v8_output_dir/RequestOrUSVString.cpp",
|
|
"$bindings_modules_v8_output_dir/RequestOrUSVString.h",
|
|
+ "$bindings_modules_v8_output_dir/ServiceCallback.cpp",
|
|
+ "$bindings_modules_v8_output_dir/ServiceCallback.h",
|
|
"$bindings_modules_v8_output_dir/ServiceWorkerOrMessagePort.cpp",
|
|
"$bindings_modules_v8_output_dir/ServiceWorkerOrMessagePort.h",
|
|
"$bindings_modules_v8_output_dir/StringOrArrayBufferOrNFCMessage.cpp",
|
|
diff --git a/src/3rdparty/chromium/third_party/WebKit/Source/modules/webos/BUILD.gn b/src/3rdparty/chromium/third_party/WebKit/Source/modules/webos/BUILD.gn
|
|
index effd211..2da4492 100644
|
|
--- a/src/3rdparty/chromium/third_party/WebKit/Source/modules/webos/BUILD.gn
|
|
+++ b/src/3rdparty/chromium/third_party/WebKit/Source/modules/webos/BUILD.gn
|
|
@@ -1,6 +1,11 @@
|
|
# Copyright 2017 Herman van Hazendonk. All rights reserved.
|
|
|
|
import("//third_party/WebKit/Source/modules/modules.gni")
|
|
+import("//build/config/linux/pkg_config.gni")
|
|
+
|
|
+pkg_config("ls2") {
|
|
+ packages = [ "luna-service2", "glib-2.0" ]
|
|
+}
|
|
|
|
blink_modules_sources("webos") {
|
|
sources = [
|
|
@@ -10,4 +15,13 @@ blink_modules_sources("webos") {
|
|
"PalmServiceBridge.cpp",
|
|
"PalmServiceBridge.h",
|
|
]
|
|
+
|
|
+ public_configs = [
|
|
+ ":ls2",
|
|
+ ]
|
|
+
|
|
+ libs = [
|
|
+ "PmLogLib",
|
|
+ ]
|
|
+
|
|
}
|
|
diff --git a/src/3rdparty/chromium/third_party/WebKit/Source/modules/webos/LunaServiceMgr.cpp b/src/3rdparty/chromium/third_party/WebKit/Source/modules/webos/LunaServiceMgr.cpp
|
|
index 55feab8..f4b9f60 100644
|
|
--- a/src/3rdparty/chromium/third_party/WebKit/Source/modules/webos/LunaServiceMgr.cpp
|
|
+++ b/src/3rdparty/chromium/third_party/WebKit/Source/modules/webos/LunaServiceMgr.cpp
|
|
@@ -1,5 +1,3 @@
|
|
-#include "config.h"
|
|
-
|
|
#include "base/message_loop/message_loop.h"
|
|
#include "base/bind.h"
|
|
|
|
@@ -49,7 +47,7 @@ void GMainContextIterate()
|
|
base::MessageLoop *pCurrentMsgLoop = base::MessageLoop::current();
|
|
if( doIterateNext && pCurrentMsgLoop )
|
|
{
|
|
- pCurrentMsgLoop->PostDelayedTask(FROM_HERE, base::Bind(&GMainContextIterate), base::TimeDelta::FromMilliseconds(100));
|
|
+ pCurrentMsgLoop->task_runner()->PostDelayedTask(FROM_HERE, base::Bind(&GMainContextIterate), base::TimeDelta::FromMilliseconds(100));
|
|
}
|
|
}
|
|
|
|
diff --git a/src/3rdparty/chromium/third_party/WebKit/Source/modules/webos/PalmServiceBridge.cpp b/src/3rdparty/chromium/third_party/WebKit/Source/modules/webos/PalmServiceBridge.cpp
|
|
index 22c160e..b6ece79 100644
|
|
--- a/src/3rdparty/chromium/third_party/WebKit/Source/modules/webos/PalmServiceBridge.cpp
|
|
+++ b/src/3rdparty/chromium/third_party/WebKit/Source/modules/webos/PalmServiceBridge.cpp
|
|
@@ -1,4 +1,3 @@
|
|
-#include "config.h"
|
|
#include "PalmServiceBridge.h"
|
|
#include "Logging.h"
|
|
|
|
@@ -6,7 +5,6 @@
|
|
#include "core/events/Event.h"
|
|
#include "core/dom/ExceptionCode.h"
|
|
#include "core/frame/Frame.h"
|
|
-#include "platform/Logging.h"
|
|
#include "core/page/Page.h"
|
|
#include "core/frame/Settings.h"
|
|
#include <wtf/text/WTFString.h>
|
|
@@ -15,7 +13,6 @@
|
|
#include "bindings/core/v8/ScriptState.h"
|
|
#include "bindings/core/v8/V8Binding.h"
|
|
#include "bindings/core/v8/ExceptionState.h"
|
|
-#include <wtf/RefCountedLeakCounter.h>
|
|
|
|
#include <map>
|
|
#include <set>
|
|
@@ -28,10 +25,6 @@ namespace blink {
|
|
typedef std::set<PalmServiceBridge*> ServicesSet;
|
|
typedef std::map<Document*, ServicesSet*> ServicesSetMap;
|
|
|
|
-#ifndef NDEBUG
|
|
-static WTF::RefCountedLeakCounter serviceBridgeCounter("PalmServiceBridge");
|
|
-#endif
|
|
-
|
|
static ServicesSetMap* servicesByDocument()
|
|
{
|
|
static ServicesSetMap map;
|
|
@@ -41,7 +34,7 @@ static ServicesSetMap* servicesByDocument()
|
|
int PalmServiceBridge::numHandlesForUrl(const char* appId)
|
|
{
|
|
for (ServicesSetMap::iterator setIt = servicesByDocument()->begin(); setIt != servicesByDocument()->end(); ++setIt) {
|
|
- if (!strcmp(appId, setIt->first->url().string().utf8().data()))
|
|
+ if (!strcmp(appId, setIt->first->url().getString().utf8().data()))
|
|
return setIt->second->size();
|
|
}
|
|
|
|
@@ -52,7 +45,7 @@ void PalmServiceBridge::handlesForUrl(const char* appId, std::list<PalmServiceBr
|
|
{
|
|
outHandles.clear();
|
|
for (ServicesSetMap::iterator setIt = servicesByDocument()->begin(); setIt != servicesByDocument()->end(); ++setIt) {
|
|
- if (!strcmp(appId, setIt->first->url().string().utf8().data())) {
|
|
+ if (!strcmp(appId, setIt->first->url().getString().utf8().data())) {
|
|
ServicesSet* set = setIt->second;
|
|
|
|
for (ServicesSet::iterator s = set->begin(); s != set->end(); ++s)
|
|
@@ -102,6 +95,7 @@ static void removeFromServicesByDocument(Document* doc, PalmServiceBridge* svc)
|
|
|
|
PalmServiceBridge::PalmServiceBridge(ExecutionContext* context, bool subscribe)
|
|
: ActiveDOMObject(context),
|
|
+ ActiveScriptWrappable(this),
|
|
m_canceled(false),
|
|
m_subscribed(subscribe),
|
|
m_inServiceCallback(false),
|
|
@@ -115,9 +109,6 @@ PalmServiceBridge::PalmServiceBridge(ExecutionContext* context, bool subscribe)
|
|
|
|
addToServicesByDocument(document(), this);
|
|
|
|
-#ifndef NDEBUG
|
|
- serviceBridgeCounter.increment();
|
|
-#endif
|
|
Frame *frame = document()->frame();
|
|
Settings* settings = document()->settings();
|
|
if (settings != 0 && document()->page()->mainFrame() == frame) {
|
|
@@ -161,15 +152,11 @@ PalmServiceBridge::~PalmServiceBridge()
|
|
if (m_scriptState)
|
|
m_scriptState->clear();
|
|
|
|
- if (executionContext() && document())
|
|
+ if (getExecutionContext() && document())
|
|
removeFromServicesByDocument(document(), this);
|
|
|
|
if (m_identifier)
|
|
free(m_identifier);
|
|
-
|
|
-#ifndef NDEBUG
|
|
- serviceBridgeCounter.decrement();
|
|
-#endif
|
|
}
|
|
|
|
void PalmServiceBridge::detachServices(Document* doc)
|
|
@@ -247,7 +234,7 @@ void PalmServiceBridge::serviceResponse(const char* body)
|
|
ScriptState *pScriptState = m_scriptState->get();
|
|
v8::Isolate *isolateCurrent = pScriptState->isolate();
|
|
v8::HandleScope handleScope(isolateCurrent);
|
|
- v8::Handle<v8::Value> cbValue = m_callbackScriptValue.v8ValueUnsafe();
|
|
+ v8::Handle<v8::Value> cbValue = m_callbackScriptValue.v8ValueFor(pScriptState);
|
|
if (!cbValue.IsEmpty() && cbValue->IsFunction()) {
|
|
v8::Handle<v8::Function> cbFctV8 = cbValue.As<v8::Function>();
|
|
v8::Handle<v8::Value> argv[1];
|
|
@@ -273,28 +260,24 @@ void PalmServiceBridge::cancel()
|
|
}
|
|
}
|
|
|
|
-void PalmServiceBridge::stop()
|
|
+void PalmServiceBridge::contextDestroyed()
|
|
{
|
|
- DEBUG("PalmServiceBridge[%p]: stopping ... (identifier %s privileged %d subscribed %d)",
|
|
- this, m_identifier, m_isPrivileged, m_subscribed);
|
|
-
|
|
cancel();
|
|
}
|
|
|
|
-bool PalmServiceBridge::canSuspend() const
|
|
+bool PalmServiceBridge::hasPendingActivity() const
|
|
{
|
|
- return false;
|
|
+ return m_canceled == false && getExecutionContext() && !getExecutionContext()->activeDOMObjectsAreStopped();
|
|
}
|
|
|
|
-void PalmServiceBridge::contextDestroyed()
|
|
+Document* PalmServiceBridge::document() const
|
|
{
|
|
- ActiveDOMObject::contextDestroyed();
|
|
+ ASSERT(getExecutionContext()->isDocument());
|
|
+ return static_cast<Document*>(getExecutionContext());
|
|
}
|
|
|
|
-Document* PalmServiceBridge::document() const
|
|
+DEFINE_TRACE(PalmServiceBridge)
|
|
{
|
|
- ASSERT(executionContext()->isDocument());
|
|
- return static_cast<Document*>(executionContext());
|
|
+ ActiveDOMObject::trace(visitor);
|
|
}
|
|
-
|
|
} // namespace blink
|
|
diff --git a/src/3rdparty/chromium/third_party/WebKit/Source/modules/webos/PalmServiceBridge.h b/src/3rdparty/chromium/third_party/WebKit/Source/modules/webos/PalmServiceBridge.h
|
|
index 4984a09..46b6440 100644
|
|
--- a/src/3rdparty/chromium/third_party/WebKit/Source/modules/webos/PalmServiceBridge.h
|
|
+++ b/src/3rdparty/chromium/third_party/WebKit/Source/modules/webos/PalmServiceBridge.h
|
|
@@ -6,12 +6,11 @@
|
|
#include "bindings/core/v8/ScriptWrappable.h"
|
|
#include "bindings/core/v8/V8Binding.h"
|
|
#include "bindings/core/v8/ScriptValue.h"
|
|
+#include "bindings/modules/v8/ServiceCallback.h"
|
|
#include "core/events/Event.h"
|
|
#include "core/events/EventListener.h"
|
|
#include "core/events/EventTarget.h"
|
|
#include "LunaServiceMgr.h"
|
|
-#include <wtf/OwnPtr.h>
|
|
-#include "wtf/PassOwnPtr.h"
|
|
|
|
// #include <heap/Strong.h>
|
|
// #include <heap/StrongInlines.h>
|
|
@@ -25,14 +24,17 @@ namespace blink {
|
|
class Document;
|
|
|
|
|
|
-class PalmServiceBridge : public RefCounted<PalmServiceBridge>,
|
|
+class PalmServiceBridge : public GarbageCollectedFinalized<PalmServiceBridge>,
|
|
public LunaServiceManagerListener,
|
|
- public ActiveDOMObject, public ScriptWrappable {
|
|
+ public ActiveDOMObject,
|
|
+ public ScriptWrappable, public ActiveScriptWrappable {
|
|
DEFINE_WRAPPERTYPEINFO();
|
|
+ USING_GARBAGE_COLLECTED_MIXIN(PalmServiceBridge)
|
|
+ WTF_MAKE_NONCOPYABLE(PalmServiceBridge);
|
|
public:
|
|
- static PassRefPtr<PalmServiceBridge> create(ExecutionContext* context, bool subscribe = false)
|
|
+ static PalmServiceBridge *create(ExecutionContext* context, bool subscribe = false)
|
|
{
|
|
- return adoptRef(new PalmServiceBridge(context, subscribe));
|
|
+ return new PalmServiceBridge(context, subscribe);
|
|
}
|
|
|
|
bool init(Document*, bool subscribed = false);
|
|
@@ -53,28 +55,28 @@ class PalmServiceBridge : public RefCounted<PalmServiceBridge>,
|
|
int call(const String& uri, const String& payload, ExceptionState&);
|
|
void cancel();
|
|
|
|
- void setOnservicecallback(ScriptValue& cbScriptValue) {
|
|
- m_callbackScriptValue = cbScriptValue;
|
|
- if (m_scriptState) {
|
|
- m_scriptState->clear();
|
|
- }
|
|
- m_scriptState = adoptPtr(new ScriptStateProtectingContext(cbScriptValue.scriptState()));
|
|
+ void setOnservicecallback(ScriptState *&cbState, ServiceCallback *cbValue) {
|
|
+ m_callbackScriptValue = ScriptValue::from(cbState, cbValue->v8Value(cbState->isolate()));
|
|
+ m_scriptState.reset(new ScriptStateProtectingContext(cbState));
|
|
}
|
|
- ScriptValue onservicecallback() const { return m_callbackScriptValue; }
|
|
+ ScriptWrappable *onservicecallback(ScriptState *cbState) const { return nullptr; }
|
|
|
|
// callback from LunaServiceManagerListener
|
|
virtual void serviceResponse(const char* body);
|
|
|
|
Document* document() const;
|
|
|
|
- // ActiveDOMObject:
|
|
+ // ContextLifecycleObserver:
|
|
virtual void contextDestroyed();
|
|
- virtual bool canSuspend() const;
|
|
- virtual void stop();
|
|
+
|
|
+ // ActiveScriptWrappable.
|
|
+ bool hasPendingActivity() const final;
|
|
+
|
|
+ DECLARE_VIRTUAL_TRACE();
|
|
|
|
private:
|
|
ScriptValue m_callbackScriptValue;
|
|
- OwnPtr<ScriptStateProtectingContext> m_scriptState;
|
|
+ std::unique_ptr<ScriptStateProtectingContext> m_scriptState;
|
|
|
|
bool m_canceled;
|
|
bool m_subscribed;
|
|
diff --git a/src/3rdparty/chromium/third_party/WebKit/Source/modules/webos/PalmServiceBridge.idl b/src/3rdparty/chromium/third_party/WebKit/Source/modules/webos/PalmServiceBridge.idl
|
|
index 43e1fdd..fc808d0 100644
|
|
--- a/src/3rdparty/chromium/third_party/WebKit/Source/modules/webos/PalmServiceBridge.idl
|
|
+++ b/src/3rdparty/chromium/third_party/WebKit/Source/modules/webos/PalmServiceBridge.idl
|
|
@@ -2,7 +2,8 @@ callback ServiceCallback = void (DOMString message);
|
|
|
|
[
|
|
Exposed=(Window,Worker),
|
|
- ActiveDOMObject,
|
|
+ ActiveScriptWrappable,
|
|
+ DependentLifetime,
|
|
Constructor,
|
|
ConstructorCallWith=ExecutionContext
|
|
] interface PalmServiceBridge {
|
|
@@ -10,5 +11,5 @@ callback ServiceCallback = void (DOMString message);
|
|
[RaisesException] unsigned long call(DOMString method, DOMString url);
|
|
void cancel();
|
|
|
|
- attribute ServiceCallback onservicecallback;
|
|
+ [CallWith=ScriptState] attribute ServiceCallback onservicecallback;
|
|
};
|
|
--
|
|
2.7.4
|
|
|