Skip to content

Commit 7405032

Browse files
ykai55jianliang00
authored andcommitted
[Feature][iOS] Decoupling LynxService framework and Trail/Log service interface from Lynx framework
The frameworks like Lynx can now also use services without relying on the Lynx component after this refactoring. issue: m-6748739071 AutoSubmit: True SkipChecks: macro AutoLand: release/3.5
1 parent 69d8186 commit 7405032

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+599
-483
lines changed

BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ group("default") {
2222
deps += [ "platform/harmony" ]
2323
} else if (is_ios) {
2424
deps += [ "platform/darwin/ios/lynx_service:LynxService" ]
25+
deps += [ "platform/darwin/ios/lynx_service_api:LynxServiceAPI_podspec" ]
2526
deps += [ "platform/darwin/ios/lynx_devtool:devtool_podspec" ]
2627
deps += [ "platform/darwin/ios/lynx_xelement:XElement" ]
2728
deps += [ "platform/darwin/ios:iOS" ]

core/renderer/BUILD.gn

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ lynx_core_source_set("tasm") {
9393
deps += [ "../runtime/bindings/napi:napi_binding_jsc" ]
9494
}
9595
}
96+
if (is_mac && !enable_unittests) {
97+
deps += [
98+
"../../platform/darwin/ios/lynx_service_api:lynx_service_api_sources",
99+
]
100+
}
96101

97102
if (lepus_compile) {
98103
public_deps += [ "../template_bundle/template_codec:lepus_compile" ]

explorer/darwin/ios/lynx_explorer/Podfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ target 'LynxExplorer' do
4040
'Devtool',
4141
'Http',
4242
]
43+
pod 'LynxServiceAPI', :path => '../../../..', :subspecs => [
44+
'Core'
45+
]
4346

4447
pod 'XElement', :path => '../../../..', :subspecs => [
4548
'Behavior',

platform/darwin/common/lynx/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ common_lynx_shared_sources = [
101101
"resource/LynxTemplateResource.m",
102102
"service/LynxService.m",
103103
"service/LynxServiceResourceRequestParameters.m",
104+
"service/LynxVerificationResult.m",
104105
"trace/LynxTraceEventDef.h",
105106
"utils/LynxColorUtils.mm",
106107
"utils/LynxConvertUtils.h",

platform/darwin/common/lynx/LynxEnv.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
#import <Lynx/LynxService.h>
3030
#import <Lynx/LynxServiceDevToolProtocol.h>
3131
#import <Lynx/LynxServiceExtensionProtocol.h>
32-
#import <Lynx/LynxServiceLogProtocol.h>
3332
#import <LynxBase/LynxBaseEnv.h>
3433
#import <LynxBase/LynxBaseService.h>
34+
#import <LynxServiceAPI/LynxServiceLogProtocol.h>
3535

3636
#include "base/include/fml/synchronization/shared_mutex.h"
3737
#include "base/trace/native/trace_event.h"

platform/darwin/common/lynx/base/LynxResourceServiceFetcherUnitTest.m

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ - (void)setUp {
2525
// Register LynxServiceResource with the mock instance
2626
_mockLynxServiceResourceProtocol = OCMProtocolMock(@protocol(LynxServiceResourceProtocol));
2727
_mockLynxServices = OCMClassMock([LynxServices class]);
28-
OCMStub(
29-
ClassMethod([_mockLynxServices getInstanceWithProtocol:@protocol(LynxServiceResourceProtocol)
30-
bizID:DEFAULT_LYNX_SERVICE]))
28+
OCMStub(ClassMethod(
29+
[_mockLynxServices getInstanceWithProtocol:@protocol(LynxServiceResourceProtocol)]))
3130
.andReturn(_mockLynxServiceResourceProtocol);
3231
}
3332

platform/darwin/common/lynx/performance/LynxPerformanceController.mm

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,7 @@ - (void)onPerformanceEvent:(nonnull LynxPerformanceEntry*)entry {
175175
[_observer onPerformanceEvent:entry];
176176

177177
if (_reporter == nil) {
178-
id<LynxServiceEventReporterProtocol> reporter =
179-
[LynxServices getInstanceWithProtocol:@protocol(LynxServiceEventReporterProtocol)
180-
bizID:DEFAULT_LYNX_SERVICE];
178+
id<LynxServiceEventReporterProtocol> reporter = LynxService(LynxServiceEventReporterProtocol);
181179
if (reporter != nil && [reporter respondsToSelector:@selector(onPerformanceEvent:)]) {
182180
_reporter = reporter;
183181
}

platform/darwin/common/lynx/public/service/LynxService.h

Lines changed: 11 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -4,85 +4,31 @@
44

55
#ifndef DARWIN_COMMON_LYNX_SERVICE_LYNXSERVICE_H_
66
#define DARWIN_COMMON_LYNX_SERVICE_LYNXSERVICE_H_
7+
78
#import <Foundation/Foundation.h>
8-
#import <Lynx/LynxDefines.h>
99
#import <Lynx/LynxServiceModuleProtocol.h>
1010
#import <Lynx/LynxServiceMonitorProtocol.h>
11-
#import <Lynx/LynxServiceProtocol.h>
1211
#import <Lynx/LynxServiceSecurityProtocol.h>
13-
#import <Lynx/LynxServiceTrailProtocol.h>
12+
#import <LynxServiceAPI/LynxServiceTrailProtocol.h>
13+
#import <LynxServiceAPI/ServiceAPI.h>
14+
1415
#if TARGET_OS_IOS
1516
#import <Lynx/LynxServiceImageProtocol.h>
1617
#endif
1718

18-
NS_ASSUME_NONNULL_BEGIN
19-
20-
/*
21-
* You can use @LynxServiceRegister to specify a LynxService will be
22-
* registered into LynxServices instance automatically. This annotation
23-
* should only be used for LynxServices subclasses, and before the
24-
* @implementation code fragment in the .m file. e.g.: LynxMonitorService
25-
* is a subclass of LynxServices, in LynxMonitorService.m
26-
* // ...import headers...
27-
* @LynxServiceRegister(LynxMonitorService)
28-
* @implmentation LynxMonitorService
29-
* //...
30-
* @end
31-
*/
32-
33-
#ifndef LynxServiceRegister
34-
#define LynxServiceRegister(clsName) \
35-
interface LynxServices(clsName) @end @implementation LynxServices(clsName) \
36-
+(NSString *)LYNX_CONCAT(__lynx_auto_register_serivce__, \
37-
LYNX_CONCAT(clsName, LYNX_CONCAT(__LINE__, __COUNTER__))) { \
38-
return @ #clsName; \
39-
} \
40-
@end
41-
#endif
19+
#import <Lynx/LynxServiceTrailExtensionProtocol.h>
4220

43-
/**
44-
* Bind protocol and class, e.g., LYNX_SERVICE_BIND (LynxMonitorService,
45-
* LynxMonitorProtocol)
46-
*/
47-
#define LynxServiceBind(cls, pro) ([LynxServices bindClass:cls toProtocol:@protocol(pro)])
48-
49-
/**
50-
* Get the default object that implements the specified protocol, e.g.,
51-
* LYNX_SERVICE(LynxMonitorProtocol) -> id<LynxMonitorProtocol>
52-
*/
53-
#define LynxService(pro) \
54-
((id<pro>)([LynxServices getInstanceWithProtocol:@protocol(pro) bizID:DEFAULT_LYNX_SERVICE]))
55-
/**
56-
* Get the object that implements the specified protocol, e.g.,
57-
* LYNX_SERVICE(LynxMonitorProtocol, default) -> id<LynxMonitorProtocol>
58-
*/
59-
#define LynxServiceBID(pro, bid) \
60-
((id<pro>)([LynxServices getInstanceWithProtocol:@protocol(pro) bizID:bid]))
21+
@interface LynxServiceHelper : NSObject
22+
+ (nullable id<LynxServiceTrailExtensionProtocol>)getLynxTrailExtensionService;
23+
@end
6124

6225
/**
63-
* Get LynxTrail Instance
64-
* LynxTrail
26+
* Get LynxTrailService Instance
6527
*/
6628
#define LynxTrail LynxService(LynxServiceTrailProtocol)
67-
68-
@interface LynxServices : NSObject
69-
7029
/**
71-
* Register default service
72-
* @param cls Protocol implementation class, which implements sharedInstance and is a singleton.
30+
* Get extended LynxTrailService Instance
7331
*/
74-
+ (void)registerService:(Class)cls;
75-
76-
/**
77-
* Get implementation through protocol
78-
* @param protocol The protocol, which implements sharedInstance and returns a singleton
79-
* @param bizID Business ID
80-
* @return An instance of the protocol implementation class; returns null if the protocol has not
81-
* been bound
82-
*/
83-
+ (id)getInstanceWithProtocol:(Protocol *)protocol bizID:(NSString *__nullable)bizID;
84-
85-
@end
32+
#define LynxTrailExtensionService ([LynxServiceHelper getLynxTrailExtensionService])
8633

87-
NS_ASSUME_NONNULL_END
8834
#endif // DARWIN_COMMON_LYNX_SERVICE_LYNXSERVICE_H_

platform/darwin/common/lynx/public/service/LynxServiceDevToolProtocol.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#define DARWIN_COMMON_LYNX_SERVICE_LYNXSERVICEIDEVTOOLPROTOCOL_H_
77

88
#import <Foundation/Foundation.h>
9-
#import <Lynx/LynxServiceProtocol.h>
9+
#import <LynxServiceAPI/ServiceAPI.h>
1010

1111
NS_ASSUME_NONNULL_BEGIN
1212

platform/darwin/common/lynx/public/service/LynxServiceEventReporterProtocol.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#import <Foundation/Foundation.h>
99
#import <Lynx/LynxEventReporter.h>
1010
#import <Lynx/LynxPerformanceObserverProtocol.h>
11-
#import <Lynx/LynxServiceProtocol.h>
11+
#import <LynxServiceAPI/ServiceAPI.h>
1212

1313
@class LynxView;
1414

0 commit comments

Comments
 (0)