From Tizen 7.0, tizen.ml is enabled in web worker. Because 'tizen'
and 'xwalk' extensions are loaded on web worker. Global TaskQueue
can be truncated at 'xwalk' instance is deleted.
This singleton TaskQueue should be truncated when main JS context
is destroyed, not by web worker.
Change-Id: I078a7217622d107799a9a47786d1680db5bed5db
Signed-off-by: DongHyun Song <dh81.song@samsung.com>
(cherry picked from commit
3f743e319889eefce19e73b3d181232cde185368)
virtual void HandleBinaryMessage(const char* msg, size_t size) = 0;
virtual void HandleSyncBinaryMessage(const char* msg, size_t size) = 0;
+ virtual void SetWebWorker(bool worker) {
+ is_web_worker_ = worker;
+ }
XW_Instance xw_instance() const {
return xw_instance_;
}
+ protected:
+ bool is_web_worker_ = false;
+
private:
friend class Extension;
Utils.prototype.ArrayBufferParser = ArrayBufferParser;
var native_ = new NativeManager(extension);
+if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
+ native_.callSync('UtilsSetWorkerScope', {});
+}
exports.utils = new Utils();
REGISTER_METHOD(UtilsToLongLong);
REGISTER_METHOD(UtilsToUnsignedLongLong);
REGISTER_METHOD(UtilsCheckProfile);
+ REGISTER_METHOD(UtilsSetWorkerScope);
#undef REGISTER_METHOD
}
ReportSuccess(picojson::value(profile), out);
}
+void UtilsInstance::UtilsSetWorkerScope(const picojson::value& args, picojson::object& out) {
+ ScopeLogger();
+
+ SetWebWorker(true);
+
+ ReportSuccess(picojson::value(true), out);
+}
+
} // namespace utils
} // namespace extension
virtual ~UtilsInstance() {
// At this point, frame of the page is destroyed or reloaded, so all the jobs have to be
// removed.
- common::TaskQueue::GetInstance().DeleteJobs();
+ if (!is_webworker_) {
+ common::TaskQueue::GetInstance().DeleteJobs();
+ }
}
private:
void UtilsToLongLong(const picojson::value& args, picojson::object& out);
void UtilsToUnsignedLongLong(const picojson::value& args, picojson::object& out);
void UtilsCheckProfile(const picojson::value& args, picojson::object& out);
+ void UtilsSetWorkerScope(const picojson::value& args, picojson::object& out);
};
} // namespace utils
} // namespace extension