Home | History | Annotate | Download | only in qt
      1 /*
      2  * Copyright (C) 2010 Apple Inc. All rights reserved.
      3  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
      4  *
      5  * Redistribution and use in source and binary forms, with or without
      6  * modification, are permitted provided that the following conditions
      7  * are met:
      8  * 1. Redistributions of source code must retain the above copyright
      9  *    notice, this list of conditions and the following disclaimer.
     10  * 2. Redistributions in binary form must reproduce the above copyright
     11  *    notice, this list of conditions and the following disclaimer in the
     12  *    documentation and/or other materials provided with the distribution.
     13  *
     14  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
     15  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     16  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     17  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
     18  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     19  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     20  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     21  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     22  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     23  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     24  * THE POSSIBILITY OF SUCH DAMAGE.
     25  */
     26 
     27 #include "config.h"
     28 #include "ThreadLauncher.h"
     29 
     30 #include "RunLoop.h"
     31 #include "WebProcess.h"
     32 #include <runtime/InitializeThreading.h>
     33 #include <wtf/Threading.h>
     34 
     35 #include <QApplication>
     36 #include <QDebug>
     37 #include <QFile>
     38 #include <QLocalServer>
     39 #include <QProcess>
     40 
     41 #include <QtCore/qglobal.h>
     42 
     43 #include <sys/resource.h>
     44 #include <unistd.h>
     45 
     46 using namespace WebCore;
     47 
     48 namespace WebKit {
     49 
     50 static void* webThreadBody(void* /* context */)
     51 {
     52     // Initialization
     53     JSC::initializeThreading();
     54     WTF::initializeMainThread();
     55 
     56     // FIXME: We do not support threaded mode for now.
     57 
     58     WebProcess::shared().initialize(-1, RunLoop::current());
     59     RunLoop::run();
     60 
     61     return 0;
     62 }
     63 
     64 CoreIPC::Connection::Identifier ThreadLauncher::createWebThread()
     65 {
     66     srandom(time(0));
     67     int connectionIdentifier = random();
     68 
     69     if (!createThread(webThreadBody, reinterpret_cast<void*>(connectionIdentifier), "WebKit2: WebThread")) {
     70         qWarning() << "failed starting thread";
     71         return 0;
     72     }
     73 
     74     return connectionIdentifier;
     75 }
     76 
     77 } // namespace WebKit
     78