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 15 matching lines...) Expand all Loading... |
26 */ | 26 */ |
27 | 27 |
28 #include "config.h" | 28 #include "config.h" |
29 | 29 |
30 #include "core/workers/WorkerScriptLoader.h" | 30 #include "core/workers/WorkerScriptLoader.h" |
31 | 31 |
32 #include "core/dom/ScriptExecutionContext.h" | 32 #include "core/dom/ScriptExecutionContext.h" |
33 #include "core/loader/TextResourceDecoder.h" | 33 #include "core/loader/TextResourceDecoder.h" |
34 #include "core/loader/WorkerThreadableLoader.h" | 34 #include "core/loader/WorkerThreadableLoader.h" |
35 #include "core/platform/network/ResourceResponse.h" | 35 #include "core/platform/network/ResourceResponse.h" |
36 #include "core/workers/WorkerContext.h" | 36 #include "core/workers/WorkerGlobalScope.h" |
37 #include "core/workers/WorkerScriptLoaderClient.h" | 37 #include "core/workers/WorkerScriptLoaderClient.h" |
38 | 38 |
39 #include <wtf/OwnPtr.h> | 39 #include <wtf/OwnPtr.h> |
40 #include <wtf/RefPtr.h> | 40 #include <wtf/RefPtr.h> |
41 #include <wtf/UnusedParam.h> | 41 #include <wtf/UnusedParam.h> |
42 | 42 |
43 namespace WebCore { | 43 namespace WebCore { |
44 | 44 |
45 WorkerScriptLoader::WorkerScriptLoader() | 45 WorkerScriptLoader::WorkerScriptLoader() |
46 : m_client(0) | 46 : m_client(0) |
47 , m_failed(false) | 47 , m_failed(false) |
48 , m_identifier(0) | 48 , m_identifier(0) |
49 , m_finishing(false) | 49 , m_finishing(false) |
50 , m_targetType(ResourceRequest::TargetIsWorker) | 50 , m_targetType(ResourceRequest::TargetIsWorker) |
51 { | 51 { |
52 } | 52 } |
53 | 53 |
54 WorkerScriptLoader::~WorkerScriptLoader() | 54 WorkerScriptLoader::~WorkerScriptLoader() |
55 { | 55 { |
56 } | 56 } |
57 | 57 |
58 void WorkerScriptLoader::loadSynchronously(ScriptExecutionContext* scriptExecuti
onContext, const KURL& url, CrossOriginRequestPolicy crossOriginRequestPolicy) | 58 void WorkerScriptLoader::loadSynchronously(ScriptExecutionContext* scriptExecuti
onContext, const KURL& url, CrossOriginRequestPolicy crossOriginRequestPolicy) |
59 { | 59 { |
60 m_url = url; | 60 m_url = url; |
61 | 61 |
62 OwnPtr<ResourceRequest> request(createResourceRequest()); | 62 OwnPtr<ResourceRequest> request(createResourceRequest()); |
63 if (!request) | 63 if (!request) |
64 return; | 64 return; |
65 | 65 |
66 ASSERT_WITH_SECURITY_IMPLICATION(scriptExecutionContext->isWorkerContext()); | 66 ASSERT_WITH_SECURITY_IMPLICATION(scriptExecutionContext->isWorkerGlobalScope
()); |
67 | 67 |
68 ThreadableLoaderOptions options; | 68 ThreadableLoaderOptions options; |
69 options.allowCredentials = AllowStoredCredentials; | 69 options.allowCredentials = AllowStoredCredentials; |
70 options.crossOriginRequestPolicy = crossOriginRequestPolicy; | 70 options.crossOriginRequestPolicy = crossOriginRequestPolicy; |
71 options.sendLoadCallbacks = SendCallbacks; | 71 options.sendLoadCallbacks = SendCallbacks; |
72 // FIXME: Should we add EnforceScriptSrcDirective here? | 72 // FIXME: Should we add EnforceScriptSrcDirective here? |
73 options.contentSecurityPolicyEnforcement = DoNotEnforceContentSecurityPolicy
; | 73 options.contentSecurityPolicyEnforcement = DoNotEnforceContentSecurityPolicy
; |
74 | 74 |
75 WorkerThreadableLoader::loadResourceSynchronously(static_cast<WorkerContext*
>(scriptExecutionContext), *request, *this, options); | 75 WorkerThreadableLoader::loadResourceSynchronously(static_cast<WorkerGlobalSc
ope*>(scriptExecutionContext), *request, *this, options); |
76 } | 76 } |
77 | 77 |
78 void WorkerScriptLoader::loadAsynchronously(ScriptExecutionContext* scriptExecut
ionContext, const KURL& url, CrossOriginRequestPolicy crossOriginRequestPolicy,
WorkerScriptLoaderClient* client) | 78 void WorkerScriptLoader::loadAsynchronously(ScriptExecutionContext* scriptExecut
ionContext, const KURL& url, CrossOriginRequestPolicy crossOriginRequestPolicy,
WorkerScriptLoaderClient* client) |
79 { | 79 { |
80 ASSERT(client); | 80 ASSERT(client); |
81 m_client = client; | 81 m_client = client; |
82 m_url = url; | 82 m_url = url; |
83 | 83 |
84 OwnPtr<ResourceRequest> request(createResourceRequest()); | 84 OwnPtr<ResourceRequest> request(createResourceRequest()); |
85 if (!request) | 85 if (!request) |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 void WorkerScriptLoader::notifyFinished() | 180 void WorkerScriptLoader::notifyFinished() |
181 { | 181 { |
182 if (!m_client || m_finishing) | 182 if (!m_client || m_finishing) |
183 return; | 183 return; |
184 | 184 |
185 m_finishing = true; | 185 m_finishing = true; |
186 m_client->notifyFinished(); | 186 m_client->notifyFinished(); |
187 } | 187 } |
188 | 188 |
189 } // namespace WebCore | 189 } // namespace WebCore |
OLD | NEW |