[go: nahoru, domu]

Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
[iOS] support download js by multithread
Browse files Browse the repository at this point in the history
  • Loading branch information
jianhan-he committed Apr 22, 2019
1 parent 80cc6cf commit a88c087
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 3 deletions.
3 changes: 3 additions & 0 deletions ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "core/bridge/platform_bridge.h"
#include "core/layout/measure_func_adapter.h"
#include "base/closure.h"

namespace WeexCore
{
Expand Down Expand Up @@ -124,6 +125,8 @@ namespace WeexCore
}

void OnReceivedResult(long callback_id, std::unique_ptr<WeexJSResult>& result) override {};

void PostTaskOnComponentThread(const weex::base::Closure closure) override;
};

class WXCoreMeasureFunctionBridge : public MeasureFunctionAdapter
Expand Down
7 changes: 7 additions & 0 deletions ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,13 @@ static void MergeBorderWidthValues(NSMutableDictionary* dict,
page->CallBridgeTime(getCurrentTime() - startTime);
return result;
}

void IOSSide::PostTaskOnComponentThread(const weex::base::Closure closure) {
WXPerformBlockOnComponentThread(^{
closure();
});
}

#pragma mark - Layout Impl

WXCoreSize WXCoreMeasureFunctionBridge::Measure(const char* page_id, long render_ptr, float width, MeasureMode widthMeasureMode, float height, MeasureMode heightMeasureMode)
Expand Down
4 changes: 4 additions & 0 deletions weex_core/Source/core/bridge/eagle_bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ namespace WeexCore {
->platform_side()
->RegisterPluginModule(name.c_str(), class_name.c_str(), version.c_str());
}

void EagleBridge::WeexCoreHandler::PostTaskOnComponentThread(const weex::base::Closure& closure) {
WeexCoreManager::Instance()->getPlatformBridge()->platform_side()->PostTaskOnComponentThread(closure);
}
#endif
void EagleBridge::WeexCoreHandler::CallNativeComponent(const char* page_id, const char* module, const char* method,const char* arguments, int arguments_length, const char* options, int options_length) {
WeexCoreManager::Instance()
Expand Down
2 changes: 2 additions & 0 deletions weex_core/Source/core/bridge/eagle_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ namespace WeexCore {
void PostTaskToMsgLoop(const weex::base::Closure& closure);
#if OS_IOS
std::unique_ptr<ValueWithType> RegisterPluginModule(const std::string &name, const std::string &class_name, const std::string &version);

void PostTaskOnComponentThread(const weex::base::Closure& closure);
#endif
};

Expand Down
2 changes: 2 additions & 0 deletions weex_core/Source/core/bridge/platform_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <string>
#include <vector>
#include "base/common.h"
#include "base/closure.h"
#include "include/WeexApiHeader.h"

namespace WeexCore {
Expand Down Expand Up @@ -171,6 +172,7 @@ class PlatformBridge {
int options_length) = 0;
#if OS_IOS
virtual std::unique_ptr<ValueWithType> RegisterPluginModule(const char *name, const char *class_name, const char *version) = 0;
virtual void PostTaskOnComponentThread(const weex::base::Closure closure) = 0;
#endif
virtual void SetTimeout(const char* callback_id, const char* time) = 0;
virtual void NativeLog(const char* str_array) = 0;
Expand Down
4 changes: 1 addition & 3 deletions weex_core/Source/core/network/ios/default_request_handler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@
NSURL* nsURL = [NSURL URLWithString:NSSTRING(url)];
[[WXSDKManager bridgeMgr] DownloadJS:nsURL completion:^(NSString *script) {
WXPerformBlockOnBridgeThread(^{
WXPerformBlockOnComponentThread(^{
callback([script UTF8String] ? : "");
});
callback([script UTF8String] ? : "");
});
}];
}
Expand Down

0 comments on commit a88c087

Please sign in to comment.