| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2009 Apple Inc. All Rights Reserved. |
| 3 * Copyright (C) 2009, 2011 Google Inc. All Rights Reserved. | 3 * Copyright (C) 2009, 2011 Google Inc. All Rights Reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 #include "config.h" | 28 #include "config.h" |
| 29 #include "core/workers/WorkerScriptLoader.h" | 29 #include "core/workers/WorkerScriptLoader.h" |
| 30 | 30 |
| 31 #include "core/dom/ExecutionContext.h" | 31 #include "core/dom/ExecutionContext.h" |
| 32 #include "core/html/parser/TextResourceDecoder.h" | 32 #include "core/html/parser/TextResourceDecoder.h" |
| 33 #include "core/loader/WorkerThreadableLoader.h" | 33 #include "core/loader/WorkerThreadableLoader.h" |
| 34 #include "core/workers/WorkerGlobalScope.h" | 34 #include "core/workers/WorkerGlobalScope.h" |
| 35 #include "core/workers/WorkerScriptLoaderClient.h" | 35 #include "core/workers/WorkerScriptLoaderClient.h" |
| 36 #include "platform/network/ResourceResponse.h" | 36 #include "platform/network/ResourceResponse.h" |
| 37 #include "public/platform/WebURLRequest.h" |
| 37 | 38 |
| 38 #include "wtf/OwnPtr.h" | 39 #include "wtf/OwnPtr.h" |
| 39 #include "wtf/RefPtr.h" | 40 #include "wtf/RefPtr.h" |
| 40 | 41 |
| 41 namespace WebCore { | 42 namespace WebCore { |
| 42 | 43 |
| 43 WorkerScriptLoader::WorkerScriptLoader() | 44 WorkerScriptLoader::WorkerScriptLoader() |
| 44 : m_client(0) | 45 : m_client(0) |
| 45 , m_failed(false) | 46 , m_failed(false) |
| 46 , m_identifier(0) | 47 , m_identifier(0) |
| 47 , m_finishing(false) | 48 , m_finishing(false) |
| 48 , m_targetType(ResourceRequest::TargetIsWorker) | 49 , m_requestContext(blink::WebURLRequest::RequestContextWorker) |
| 49 { | 50 { |
| 50 } | 51 } |
| 51 | 52 |
| 52 WorkerScriptLoader::~WorkerScriptLoader() | 53 WorkerScriptLoader::~WorkerScriptLoader() |
| 53 { | 54 { |
| 54 } | 55 } |
| 55 | 56 |
| 56 void WorkerScriptLoader::loadSynchronously(ExecutionContext& executionContext, c
onst KURL& url, CrossOriginRequestPolicy crossOriginRequestPolicy) | 57 void WorkerScriptLoader::loadSynchronously(ExecutionContext& executionContext, c
onst KURL& url, CrossOriginRequestPolicy crossOriginRequestPolicy) |
| 57 { | 58 { |
| 58 m_url = url; | 59 m_url = url; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 const KURL& WorkerScriptLoader::responseURL() const | 99 const KURL& WorkerScriptLoader::responseURL() const |
| 99 { | 100 { |
| 100 ASSERT(!failed()); | 101 ASSERT(!failed()); |
| 101 return m_responseURL; | 102 return m_responseURL; |
| 102 } | 103 } |
| 103 | 104 |
| 104 PassOwnPtr<ResourceRequest> WorkerScriptLoader::createResourceRequest() | 105 PassOwnPtr<ResourceRequest> WorkerScriptLoader::createResourceRequest() |
| 105 { | 106 { |
| 106 OwnPtr<ResourceRequest> request = adoptPtr(new ResourceRequest(m_url)); | 107 OwnPtr<ResourceRequest> request = adoptPtr(new ResourceRequest(m_url)); |
| 107 request->setHTTPMethod("GET"); | 108 request->setHTTPMethod("GET"); |
| 108 request->setTargetType(m_targetType); | 109 request->setRequestContext(m_requestContext); |
| 109 return request.release(); | 110 return request.release(); |
| 110 } | 111 } |
| 111 | 112 |
| 112 void WorkerScriptLoader::didReceiveResponse(unsigned long identifier, const Reso
urceResponse& response) | 113 void WorkerScriptLoader::didReceiveResponse(unsigned long identifier, const Reso
urceResponse& response) |
| 113 { | 114 { |
| 114 if (response.httpStatusCode() / 100 != 2 && response.httpStatusCode()) { | 115 if (response.httpStatusCode() / 100 != 2 && response.httpStatusCode()) { |
| 115 m_failed = true; | 116 m_failed = true; |
| 116 return; | 117 return; |
| 117 } | 118 } |
| 118 m_responseURL = response.url(); | 119 m_responseURL = response.url(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 void WorkerScriptLoader::notifyFinished() | 187 void WorkerScriptLoader::notifyFinished() |
| 187 { | 188 { |
| 188 if (!m_client || m_finishing) | 189 if (!m_client || m_finishing) |
| 189 return; | 190 return; |
| 190 | 191 |
| 191 m_finishing = true; | 192 m_finishing = true; |
| 192 m_client->notifyFinished(); | 193 m_client->notifyFinished(); |
| 193 } | 194 } |
| 194 | 195 |
| 195 } // namespace WebCore | 196 } // namespace WebCore |
| OLD | NEW |