Integrate core-usage class to cs-logic 99/69599/2
authorKyungwook Tak <k.tak@samsung.com>
Mon, 16 May 2016 05:36:17 +0000 (14:36 +0900)
committerKyungwook Tak <k.tak@samsung.com>
Mon, 16 May 2016 05:38:03 +0000 (14:38 +0900)
Change-Id: I08439cebbc93867b5a286a083b043c1ad4cd1055
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
src/framework/service/cs-logic.cpp
src/framework/service/server-service.cpp

index 3aa92ef..f360114 100644 (file)
 #include "common/audit/logger.h"
 #include "service/type-converter.h"
 #include "service/engine-error-converter.h"
+#include "service/core-usage.h"
 #include "ui/askuser.h"
 #include "csr/error.h"
 
 namespace Csr {
 
+namespace {
+
+void setCoreUsage(const csr_cs_core_usage_e &cu)
+{
+       switch (cu) {
+       case CSR_CS_USE_CORE_HALF:
+       case CSR_CS_USE_CORE_SINGLE:
+               CpuUsageManager::set(cu);
+               break;
+
+       default:
+               break;
+       }
+}
+
+} // namespace anonymous
+
 CsLogic::CsLogic() :
        m_loader(new CsLoader(CS_ENGINE_PATH)),
        m_db(new Db::Manager(RW_DBSPACE "/.csr.db", RO_DBSPACE))
@@ -60,6 +78,8 @@ RawBuffer CsLogic::scanData(const CsContext &context, const RawBuffer &data)
 {
        EXCEPTION_GUARD_START
 
+       setCoreUsage(context.coreUsage);
+
        CsEngineContext engineContext(*m_loader);
        auto &c = engineContext.get();
 
@@ -192,6 +212,8 @@ RawBuffer CsLogic::scanFile(const CsContext &context, const std::string &filepat
 {
        EXCEPTION_GUARD_START
 
+       setCoreUsage(context.coreUsage);
+
        if (File::isInApp(filepath))
                return scanApp(context, filepath);
 
index e1dabae..af1dd88 100644 (file)
@@ -34,6 +34,7 @@
 #include "common/em-result.h"
 #include "service/exception.h"
 #include "service/access-control.h"
+#include "service/core-usage.h"
 
 #include "csr/content-screening-types.h"
 
@@ -307,6 +308,7 @@ void ServerService::onMessageProcess(const ConnShPtr &connection)
 
        m_workqueue.submit(std::bind([this, &connection, process](RawBuffer &buffer) {
                connection->send((*process)(connection, buffer));
+               CpuUsageManager::reset();
        }, connection->receive()));
 }