Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
C
Chromium
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
Chromium
Commits
a90da11d
Commit
a90da11d
authored
Jan 05, 2023
by
Linshizhi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stage: Uniform Interface for service codes.
parent
6aaad925
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
193 additions
and
0 deletions
+193
-0
.gitmodules
.gitmodules
+3
-0
bindings.gni
third_party/blink/renderer/bindings/bindings.gni
+6
-0
local_window_proxy.cc
...rty/blink/renderer/bindings/core/v8/local_window_proxy.cc
+3
-0
nativeBox.cc
third_party/blink/renderer/bindings/core/v8/nativeBox.cc
+90
-0
nativeBox.h
third_party/blink/renderer/bindings/core/v8/nativeBox.h
+19
-0
v8_initializer_custom.cc
.../blink/renderer/bindings/core/v8/v8_initializer_custom.cc
+61
-0
v8_initializer_custom.h
...y/blink/renderer/bindings/core/v8/v8_initializer_custom.h
+10
-0
loadablemodule
...d_party/blink/renderer/bindings/extensions/loadablemodule
+1
-0
No files found.
.gitmodules
0 → 100644
View file @
a90da11d
[submodule "third_party/blink/renderer/bindings/extensions/loadablemodule"]
path = third_party/blink/renderer/bindings/extensions/loadablemodule
url = git@gitlab.laihua.com:linshizhi/loadablemodule.git
third_party/blink/renderer/bindings/bindings.gni
View file @
a90da11d
...
...
@@ -146,6 +146,12 @@ blink_core_sources_bindings =
"core/v8/v8_idle_task_runner.h",
"core/v8/v8_initializer.cc",
"core/v8/v8_initializer.h",
#"core/v8/v8_initializer_custom.cc",
#"core/v8/v8_initializer_custom.h",
#"core/v8/nativeBox.h",
#"core/v8/nativeBox.cc",
"extensions/loadablemodule/src/Loadable.cc",
"extensions/loadablemodule/src/Loadable.h",
"core/v8/v8_intersection_observer_delegate.cc",
"core/v8/v8_intersection_observer_delegate.h",
"core/v8/v8_iterator_result_value.cc",
...
...
third_party/blink/renderer/bindings/core/v8/local_window_proxy.cc
View file @
a90da11d
...
...
@@ -43,6 +43,7 @@
#include "third_party/blink/renderer/bindings/core/v8/v8_gc_for_context_dispose.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_html_document.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_initializer.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_initializer_custom.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_page_popup_controller_binding.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_window.h"
#include "third_party/blink/renderer/core/execution_context/agent.h"
...
...
@@ -213,6 +214,8 @@ void LocalWindowProxy::Initialize() {
if
(
World
().
IsMainWorld
())
{
GetFrame
()
->
Loader
().
DispatchDidClearWindowObjectInMainWorld
();
}
// PostInitializeV8(GetIsolate());
}
void
LocalWindowProxy
::
CreateContext
()
{
...
...
third_party/blink/renderer/bindings/core/v8/nativeBox.cc
0 → 100644
View file @
a90da11d
#include "nativeBox.h"
#include <string>
#include <vector>
#include "third_party/blink/renderer/bindings/extensions/loadablemodule/src/Loadable.h"
#include "v8/include/v8.h"
#include "v8/include/v8-primitive.h"
#include "v8/include/v8-typed-array.h"
#include "v8/include/v8-value.h"
#include "v8/include/v8-object.h"
using
std
::
vector
;
using
v8
::
TypedArray
;
using
v8
::
String
;
using
v8
::
Value
;
using
v8
::
Uint32
;
using
v8
::
Object
;
using
v8
::
Local
;
namespace
L
=
Loadable
;
#if 0
// Anonymous which contains all transform functions
namespace {
}
NativeBox::NativeBox(L::LoadableModule *module): native(module) {}
Local<Object> NativeBox::ToObject(v8::Isolate *isolate) {
// Find out an anatomy of LoadableModule
// and spawn correspond JSObject which is equivalent to
// LoadableModule in aspect of interfaces.
Local<Object> obj = Local<Object>();
if (!native) {
// No LoadableModule found
// return null Handle<JSObject> .
return obj;
}
// Analyze LoadableModule
vector<L::IFaceSpec> IFSpecs = native->specs();
for (vector<L::IFaceSpec>::iterator iter = IFSpecs.begin();
iter < IFSpecs.end(); ++iter) {
// Get return type
L::ArgType retType = iter->getRet();
// Get type of arguments
std::vector<L::ArgType> args = iter->getArgs();
void *callback = iter->getCallback();
// Spawn correspond method and attach the method to
// spawned JSObj.
auto transform_layer = [&](const v8::FunctionCallbackInfo<v8::Value>& args_) -> void {
if (args.size() != args_.Length()) return;
int i = 0;
// Transform argument into native.
for (std::vector<L::ArgType>::iterator iter = args.begin();
iter < args.end(); ++iter) {
switch (*iter) {
case L::ARG_TYPE_NUM:
transformToNative<uint32_t>(args[i]);
break;
case L::ARG_TYPE_STR:
transformToNative<std::string>(args[i]);
break;
case L::ARG_TYPE_ARRAY:
transformToNative<uint8_t*>(args[i]);
break;
}
++i;
}
};
}
return obj;
}
#endif
third_party/blink/renderer/bindings/core/v8/nativeBox.h
0 → 100644
View file @
a90da11d
#include "v8/include/v8-isolate.h"
#include "v8/include/v8-value.h"
#include "v8/include/v8-object.h"
#include "v8/include/v8-local-handle.h"
#include "third_party/blink/renderer/bindings/extensions/loadablemodule/src/Loadable.h"
namespace
L
=
Loadable
;
class
NativeBox
{
public
:
NativeBox
()
=
delete
;
NativeBox
(
L
::
LoadableModule
*
module
);
v8
::
Local
<
v8
::
Object
>
ToObject
(
v8
::
Isolate
*
isolate
);
private
:
L
::
LoadableModule
*
native
;
};
third_party/blink/renderer/bindings/core/v8/v8_initializer_custom.cc
0 → 100644
View file @
a90da11d
#include <string>
#include <iostream>
#include "nativeBox.h"
#include "v8/include/v8.h"
#include "v8/include/v8-template.h"
#include "v8/include/v8-context.h"
#include "v8/include/v8-object.h"
#include "v8/include/v8-primitive.h"
#include "third_party/blink/renderer/bindings/extensions/loadablemodule/src/Loadable.h"
#include <dlfcn.h>
using
v8
::
Local
;
using
v8
::
ObjectTemplate
;
using
v8
::
Context
;
using
v8
::
Object
;
using
v8
::
Value
;
using
v8
::
Maybe
;
using
v8
::
String
;
static
void
LoadeModule
(
const
v8
::
FunctionCallbackInfo
<
v8
::
Value
>&
args
)
{
if
(
args
.
Length
()
<
1
)
return
;;
v8
::
Isolate
*
isolate
=
args
.
GetIsolate
();
v8
::
HandleScope
scope
(
isolate
);
Local
<
Value
>
arg
=
args
[
0
];
String
::
Utf8Value
moduleName
(
isolate
,
arg
);
void
*
symbols
=
dlopen
(
"liblms.so"
,
RTLD_LAZY
);
if
(
!
symbols
)
{
std
::
cout
<<
"No Module found"
<<
std
::
endl
;
return
;
}
Loadable
::
LoadableModule
*
(
*
load
)(
std
::
string
);
load
=
(
Loadable
::
LoadableModule
*
(
*
)(
std
::
string
))
dlsym
(
symbols
,
"load"
);
Loadable
::
LoadableModule
*
module
=
load
(
"MP4Encoder"
);
NativeBox
box
{
module
};
args
.
GetReturnValue
().
Set
(
box
.
ToObject
(
isolate
));
}
void
PostInitializeV8
(
v8
::
Isolate
*
isolate
)
{
Local
<
Context
>
context
=
isolate
->
GetCurrentContext
();
Local
<
Object
>
global
=
context
->
Global
();
Local
<
Value
>
callbackName
=
v8
::
String
::
NewFromUtf8
(
isolate
,
"LoadModule"
).
ToLocalChecked
();
Local
<
Value
>
callback
=
v8
::
FunctionTemplate
::
New
(
isolate
,
LoadeModule
)
->
GetFunction
(
context
).
ToLocalChecked
();
Maybe
<
bool
>
ret
=
global
->
Set
(
context
,
callbackName
,
callback
);
ret
.
IsJust
();
}
third_party/blink/renderer/bindings/core/v8/v8_initializer_custom.h
0 → 100644
View file @
a90da11d
#include "v8/include/v8.h"
#ifndef V8_INITIALIZER_CUSTOM_H
#define V8_INITIALIZER_CUSTOM_H
void
PostInitializeV8
(
v8
::
Isolate
*
isolate
);
void
PostInitializeV8_Context
(
v8
::
Isolate
*
isolate
,
v8
::
Local
<
v8
::
Context
>
context
);
#endif
/* V8_INITIALIZER_CUSTOM_H */
loadablemodule
@
0a966f95
Subproject commit 0a966f95cb3603cc87723cec4a6ebd5f15da06e5
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment