1635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project/* 28f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian * Copyright (C) 2009 Google Inc. All rights reserved. 3635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * 4635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * Redistribution and use in source and binary forms, with or without 5635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * modification, are permitted provided that the following conditions are 6635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * met: 7635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * 8635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * * Redistributions of source code must retain the above copyright 9635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * notice, this list of conditions and the following disclaimer. 10635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * * Redistributions in binary form must reproduce the above 11635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * copyright notice, this list of conditions and the following disclaimer 12635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * in the documentation and/or other materials provided with the 13635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * distribution. 14635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * * Neither the name of Google Inc. nor the names of its 15635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * contributors may be used to endorse or promote products derived from 16635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * this software without specific prior written permission. 17635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * 18635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project */ 30635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 31635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#include "config.h" 32635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#include "ThreadableLoader.h" 33635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 34635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#include "ScriptExecutionContext.h" 358f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian#include "Document.h" 368f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian#include "DocumentThreadableLoader.h" 378f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian#include "WorkerContext.h" 388f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian#include "WorkerRunLoop.h" 398f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian#include "WorkerThreadableLoader.h" 40635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 41635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Projectnamespace WebCore { 42635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 43231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve BlockPassRefPtr<ThreadableLoader> ThreadableLoader::create(ScriptExecutionContext* context, ThreadableLoaderClient* client, const ResourceRequest& request, const ThreadableLoaderOptions& options) 44635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project{ 45635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project ASSERT(client); 46635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project ASSERT(context); 47635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 488f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian#if ENABLE(WORKERS) 498f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian if (context->isWorkerContext()) 50231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block return WorkerThreadableLoader::create(static_cast<WorkerContext*>(context), client, WorkerRunLoop::defaultMode(), request, options); 518f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian#endif // ENABLE(WORKERS) 528f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian 538f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian ASSERT(context->isDocument()); 54231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block return DocumentThreadableLoader::create(static_cast<Document*>(context), client, request, options); 55635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project} 56635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 57231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Blockvoid ThreadableLoader::loadResourceSynchronously(ScriptExecutionContext* context, const ResourceRequest& request, ThreadableLoaderClient& client, const ThreadableLoaderOptions& options) 58635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project{ 59635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project ASSERT(context); 60635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 618f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian#if ENABLE(WORKERS) 628f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian if (context->isWorkerContext()) { 63231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block WorkerThreadableLoader::loadResourceSynchronously(static_cast<WorkerContext*>(context), request, client, options); 648f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian return; 658f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian } 668f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian#endif // ENABLE(WORKERS) 678f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian 688f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian ASSERT(context->isDocument()); 69231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block DocumentThreadableLoader::loadResourceSynchronously(static_cast<Document*>(context), request, client, options); 70635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project} 71635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 72635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project} // namespace WebCore 73