Changeset 112353 in webkit


Ignore:
Timestamp:
Mar 27, 2012 7:02:18 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[EFL][WK2] Add RunLoopEfl and WorkQueueEfl
https://bugs.webkit.org/show_bug.cgi?id=62777

Patch by YoungTaeck Song <youngtaeck.song@samsung.com> on 2012-03-27
Reviewed by Hajime Morita.

Source/WebCore:

Add initial version RunLoopEfl for WebKit2 Efl.

  • platform/RunLoop.h:

(TimerBase):
(RunLoop):

  • platform/efl/RunLoopEfl.cpp:

(WebCore::RunLoop::RunLoop):
(WebCore::RunLoop::~RunLoop):
(WebCore):
(WebCore::RunLoop::run):
(WebCore::RunLoop::stop):
(WebCore::RunLoop::wakeUpEvent):
(WebCore::RunLoop::wakeUp):
(WebCore::RunLoop::TimerBase::TimerBase):
(WebCore::RunLoop::TimerBase::~TimerBase):
(WebCore::RunLoop::TimerBase::timerFired):
(WebCore::RunLoop::TimerBase::start):
(WebCore::RunLoop::TimerBase::stop):
(WebCore::RunLoop::TimerBase::isActive):

Source/WebKit2:

Add initial version WorkQueueEfl for WebKit2 Efl.

  • Platform/CoreIPC/Connection.h:
  • Platform/CoreIPC/unix/ConnectionUnix.cpp:

(CoreIPC::Connection::platformInvalidate):
(CoreIPC::Connection::open):

  • Platform/PlatformProcessIdentifier.h:

(WebKit):

  • Platform/WorkQueue.h:

(WorkQueue):

  • Platform/efl/WorkQueueEfl.cpp: Added.

(TimerWorkItem):
(TimerWorkItem::TimerWorkItem):
(TimerWorkItem::~TimerWorkItem):
(TimerWorkItem::function):
(TimerWorkItem::queue):
(TimerWorkItem::timerID):
(WorkQueue::platformInitialize):
(WorkQueue::platformInvalidate):
(WorkQueue::performWork):
(WorkQueue::performFdWork):
(WorkQueue::sendMessageToThread):
(WorkQueue::workQueueThread):
(WorkQueue::registerSocketEventHandler):
(WorkQueue::unregisterSocketEventHandler):
(WorkQueue::dispatch):
(WorkQueue::timerFired):
(WorkQueue::dispatchAfterDelay):

  • PlatformEfl.cmake:
Location:
trunk/Source
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r112347 r112353  
     12012-03-27  YoungTaeck Song  <youngtaeck.song@samsung.com>
     2
     3        [EFL][WK2] Add RunLoopEfl and WorkQueueEfl
     4        https://bugs.webkit.org/show_bug.cgi?id=62777
     5
     6        Reviewed by Hajime Morita.
     7
     8        Add initial version RunLoopEfl for WebKit2 Efl.
     9
     10        * platform/RunLoop.h:
     11        (TimerBase):
     12        (RunLoop):
     13        * platform/efl/RunLoopEfl.cpp:
     14        (WebCore::RunLoop::RunLoop):
     15        (WebCore::RunLoop::~RunLoop):
     16        (WebCore):
     17        (WebCore::RunLoop::run):
     18        (WebCore::RunLoop::stop):
     19        (WebCore::RunLoop::wakeUpEvent):
     20        (WebCore::RunLoop::wakeUp):
     21        (WebCore::RunLoop::TimerBase::TimerBase):
     22        (WebCore::RunLoop::TimerBase::~TimerBase):
     23        (WebCore::RunLoop::TimerBase::timerFired):
     24        (WebCore::RunLoop::TimerBase::start):
     25        (WebCore::RunLoop::TimerBase::stop):
     26        (WebCore::RunLoop::TimerBase::isActive):
     27
    1282012-03-27  Benjamin Poulain  <bpoulain@apple.com>
    229
  • trunk/Source/WebCore/platform/RunLoop.h

    r109161 r112353  
    3838#if PLATFORM(GTK)
    3939#include <wtf/gobject/GRefPtr.h>
     40#endif
     41
     42#if PLATFORM(EFL)
     43#include <Ecore.h>
    4044#endif
    4145
     
    96100        GRefPtr<GSource> m_timerSource;
    97101        gboolean m_isRepeating;
     102#elif PLATFORM(EFL)
     103        static bool timerFired(void* data);
     104        OwnPtr<Ecore_Timer> m_timer;
     105        bool m_isRepeating;
    98106#endif
    99107    };
     
    158166    GRefPtr<GMainContext> m_runLoopContext;
    159167    Vector<GRefPtr<GMainLoop> > m_runLoopMainLoops;
     168#elif PLATFORM(EFL)
     169    bool m_initEfl;
     170    OwnPtr<Ecore_Pipe> m_pipe;
     171    static void wakeUpEvent(void* data, void*, unsigned int);
    160172#endif
    161173};
  • trunk/Source/WebCore/platform/efl/RunLoopEfl.cpp

    r109031 r112353  
    11/*
    22 * Copyright (C) 2012 ProFUSION embedded systems. All rights reserved.
     3 * Copyright (C) 2012 Samsung Electronics
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    2728#include "RunLoop.h"
    2829
    29 #include "NotImplemented.h"
     30#include <Ecore.h>
     31#include <Ecore_Evas.h>
     32#include <Ecore_File.h>
     33#include <Edje.h>
     34#include <wtf/OwnPtr.h>
     35#include <wtf/PassOwnPtr.h>
     36
     37static const int ecorePipeMessageSize = 1;
     38static const char wakupEcorePipeMessage[] = "W";
    3039
    3140namespace WebCore {
    3241
    3342RunLoop::RunLoop()
     43    : m_initEfl(false)
    3444{
    35     notImplemented();
     45    if (!ecore_init()) {
     46        LOG_ERROR("could not init ecore.");
     47        return;
     48    }
     49
     50    if (!ecore_evas_init()) {
     51        LOG_ERROR("could not init ecore_evas.");
     52        goto errorEcoreEvas;
     53    }
     54
     55    if (!ecore_file_init()) {
     56        LOG_ERROR("could not init ecore_file.");
     57        goto errorEcoreFile;
     58    }
     59
     60    if (!edje_init()) {
     61        LOG_ERROR("could not init edje.");
     62        goto errorEdje;
     63    }
     64
     65    m_pipe = adoptPtr(ecore_pipe_add(wakeUpEvent, this));
     66    m_initEfl = true;
     67
     68    return;
     69
     70errorEdje:
     71    ecore_file_shutdown();
     72errorEcoreFile:
     73    ecore_evas_shutdown();
     74errorEcoreEvas:
     75    ecore_shutdown();
    3676}
    3777
    3878RunLoop::~RunLoop()
    3979{
    40     notImplemented();
     80    if (m_initEfl) {
     81        edje_shutdown();
     82        ecore_file_shutdown();
     83        ecore_evas_shutdown();
     84        ecore_shutdown();
     85    }
     86}
     87
     88void RunLoop::run()
     89{
     90    ecore_main_loop_begin();
     91}
     92
     93void RunLoop::stop()
     94{
     95    ecore_main_loop_quit();
     96}
     97
     98void RunLoop::wakeUpEvent(void* data, void*, unsigned int)
     99{
     100    static_cast<RunLoop*>(data)->performWork();
    41101}
    42102
    43103void RunLoop::wakeUp()
    44104{
    45     notImplemented();
     105    ecore_pipe_write(m_pipe.get(), wakupEcorePipeMessage, ecorePipeMessageSize);
     106}
     107
     108RunLoop::TimerBase::TimerBase(RunLoop*)
     109    : m_isRepeating(false)
     110{
     111}
     112
     113RunLoop::TimerBase::~TimerBase()
     114{
     115    stop();
     116}
     117
     118bool RunLoop::TimerBase::timerFired(void* data)
     119{
     120    RunLoop::TimerBase* timer = static_cast<RunLoop::TimerBase*>(data);
     121
     122    timer->fired();
     123
     124    if (!timer->m_isRepeating) {
     125        timer->m_timer = nullptr;
     126        return ECORE_CALLBACK_CANCEL;
     127    }
     128
     129    return ECORE_CALLBACK_RENEW;
     130}
     131
     132void RunLoop::TimerBase::start(double nextFireInterval, bool repeat)
     133{
     134    m_isRepeating = repeat;
     135    m_timer = adoptPtr(ecore_timer_add(nextFireInterval, reinterpret_cast<Ecore_Task_Cb>(timerFired), this));
     136}
     137
     138void RunLoop::TimerBase::stop()
     139{
     140    m_timer = nullptr;
     141}
     142
     143bool RunLoop::TimerBase::isActive() const
     144{
     145    return (m_timer) ? true : false;
    46146}
    47147
  • trunk/Source/WebKit2/ChangeLog

    r112338 r112353  
     12012-03-27  YoungTaeck Song  <youngtaeck.song@samsung.com>
     2
     3        [EFL][WK2] Add RunLoopEfl and WorkQueueEfl
     4        https://bugs.webkit.org/show_bug.cgi?id=62777
     5
     6        Reviewed by Hajime Morita.
     7
     8        Add initial version WorkQueueEfl for WebKit2 Efl.
     9
     10        * Platform/CoreIPC/Connection.h:
     11        * Platform/CoreIPC/unix/ConnectionUnix.cpp:
     12        (CoreIPC::Connection::platformInvalidate):
     13        (CoreIPC::Connection::open):
     14        * Platform/PlatformProcessIdentifier.h:
     15        (WebKit):
     16        * Platform/WorkQueue.h:
     17        (WorkQueue):
     18        * Platform/efl/WorkQueueEfl.cpp: Added.
     19        (TimerWorkItem):
     20        (TimerWorkItem::TimerWorkItem):
     21        (TimerWorkItem::~TimerWorkItem):
     22        (TimerWorkItem::function):
     23        (TimerWorkItem::queue):
     24        (TimerWorkItem::timerID):
     25        (WorkQueue::platformInitialize):
     26        (WorkQueue::platformInvalidate):
     27        (WorkQueue::performWork):
     28        (WorkQueue::performFdWork):
     29        (WorkQueue::sendMessageToThread):
     30        (WorkQueue::workQueueThread):
     31        (WorkQueue::registerSocketEventHandler):
     32        (WorkQueue::unregisterSocketEventHandler):
     33        (WorkQueue::dispatch):
     34        (WorkQueue::timerFired):
     35        (WorkQueue::dispatchAfterDelay):
     36        * PlatformEfl.cmake:
     37
    1382012-03-27  Anders Carlsson  <andersca@apple.com>
    239
  • trunk/Source/WebKit2/Platform/CoreIPC/Connection.h

    r105475 r112353  
    4747#endif
    4848
    49 #if PLATFORM(QT) || PLATFORM(GTK)
     49#if PLATFORM(QT) || PLATFORM(GTK) || PLATFORM(EFL)
    5050#include "PlatformProcessIdentifier.h"
    5151#endif
  • trunk/Source/WebKit2/Platform/CoreIPC/unix/ConnectionUnix.cpp

    r103178 r112353  
    154154#endif
    155155
     156#if PLATFORM(EFL)
     157    m_connectionQueue.unregisterSocketEventHandler(m_socketDescriptor);
     158#endif
     159
    156160    m_socketDescriptor = -1;
    157161    m_isConnected = false;
     
    424428    m_connectionQueue.registerEventSourceHandler(m_socketDescriptor, (G_IO_HUP | G_IO_ERR), bind(&Connection::connectionDidClose, this));
    425429    m_connectionQueue.registerEventSourceHandler(m_socketDescriptor, G_IO_IN, bind(&Connection::readyReadHandler, this));
     430#elif PLATFORM(EFL)
     431    m_connectionQueue.registerSocketEventHandler(m_socketDescriptor, bind(&Connection::readyReadHandler, this));
    426432#endif
    427433
  • trunk/Source/WebKit2/Platform/PlatformProcessIdentifier.h

    r95901 r112353  
    4747#endif
    4848typedef GPid PlatformProcessIdentifier;
     49#elif PLATFORM(EFL)
     50typedef pid_t PlatformProcessIdentifier;
    4951#endif
    5052
  • trunk/Source/WebKit2/Platform/WorkQueue.h

    r109129 r112353  
    4242#include <wtf/Vector.h>
    4343
     44#if (PLATFORM(QT) && !OS(DARWIN)) || PLATFORM(GTK) || PLATFORM(EFL)
     45#include "PlatformProcessIdentifier.h"
     46#endif
     47
    4448#if PLATFORM(QT) && !OS(DARWIN)
    4549#include <QSocketNotifier>
    46 #include "PlatformProcessIdentifier.h"
    4750class QObject;
    4851class QThread;
    4952#elif PLATFORM(GTK)
    50 #include "PlatformProcessIdentifier.h"
    5153#include <wtf/gobject/GRefPtr.h>
    5254typedef gboolean (*GSourceFunc) (gpointer data);
     55#elif PLATFORM(EFL)
     56#include <Ecore.h>
    5357#endif
    5458
     
    9195    void unregisterEventSourceHandler(int);
    9296    void dispatchOnTermination(WebKit::PlatformProcessIdentifier, const Function<void()>&);
     97#elif PLATFORM(EFL)
     98    void registerSocketEventHandler(int, const Function<void()>&);
     99    void unregisterSocketEventHandler(int);
    93100#endif
    94101
     
    178185    HashMap<int, Vector<EventSource*> > m_eventSources;
    179186    typedef HashMap<int, Vector<EventSource*> >::iterator EventSourceIterator;
     187#elif PLATFORM(EFL)
     188    fd_set m_fileDescriptorSet;
     189    int m_maxFileDescriptor;
     190    int m_readFromPipeDescriptor;
     191    int m_writeToPipeDescriptor;
     192    bool m_threadLoop;
     193
     194    Vector<Function<void()> > m_workItemQueue;
     195    Mutex m_workItemQueueLock;
     196
     197    int m_socketDescriptor;
     198    Function<void()> m_socketEventHandler;
     199
     200    HashMap<int, OwnPtr<Ecore_Timer> > m_timers;
     201
     202    void sendMessageToThread(const char*);
     203    static void* workQueueThread(WorkQueue*);
     204    void performWork();
     205    void performFileDescriptorWork();
     206    static bool timerFired(void*);
    180207#endif
    181208};
  • trunk/Source/WebKit2/PlatformEfl.cmake

    r107747 r112353  
    88LIST(APPEND WebKit2_SOURCES
    99    Platform/efl/ModuleEfl.cpp
    10     Platform/efl/RunLoopEfl.cpp
    1110    Platform/efl/WorkQueueEfl.cpp
    1211    Platform/unix/SharedMemoryUnix.cpp
Note: See TracChangeset for help on using the changeset viewer.