OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/loader/WorkletScriptLoader.h" | 5 #include "core/loader/WorkletScriptLoader.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptSourceCode.h" | 7 #include "bindings/core/v8/ScriptSourceCode.h" |
8 #include "core/loader/FrameFetchContext.h" | 8 #include "core/loader/FrameFetchContext.h" |
9 #include "platform/loader/fetch/FetchInitiatorTypeNames.h" | 9 #include "platform/loader/fetch/FetchInitiatorTypeNames.h" |
10 #include "platform/wtf/WTF.h" | 10 #include "platform/wtf/WTF.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 WorkletScriptLoader::WorkletScriptLoader(ResourceFetcher* fetcher, | 14 WorkletScriptLoader::WorkletScriptLoader(ResourceFetcher* fetcher, |
15 Client* client) | 15 Client* client) |
16 : fetcher_(fetcher), client_(client) {} | 16 : fetcher_(fetcher), client_(client) {} |
17 | 17 |
18 void WorkletScriptLoader::FetchScript(const String& script_url) { | 18 void WorkletScriptLoader::FetchScript(const KURL& module_url_record) { |
19 DCHECK(IsMainThread()); | 19 DCHECK(IsMainThread()); |
20 DCHECK(!GetResource()); | 20 DCHECK(!GetResource()); |
21 DCHECK(!was_script_load_complete_); | 21 DCHECK(!was_script_load_complete_); |
22 | 22 |
23 ResourceRequest resource_request(script_url); | 23 ResourceRequest resource_request(module_url_record); |
24 resource_request.SetRequestContext(WebURLRequest::kRequestContextScript); | 24 resource_request.SetRequestContext(WebURLRequest::kRequestContextScript); |
25 FetchParameters params(resource_request, FetchInitiatorTypeNames::internal); | 25 FetchParameters params(resource_request, FetchInitiatorTypeNames::internal); |
26 ScriptResource* resource = ScriptResource::Fetch(params, fetcher_); | 26 ScriptResource* resource = ScriptResource::Fetch(params, fetcher_); |
27 if (!resource) { | 27 if (!resource) { |
28 NotifyFinished(nullptr); | 28 NotifyFinished(nullptr); |
29 return; | 29 return; |
30 } | 30 } |
31 SetResource(resource); | 31 SetResource(resource); |
32 // notifyFinished() will be called later. | 32 // notifyFinished() will be called later. |
33 } | 33 } |
(...skipping 26 matching lines...) Expand all Loading... |
60 return was_script_load_successful_; | 60 return was_script_load_successful_; |
61 } | 61 } |
62 | 62 |
63 DEFINE_TRACE(WorkletScriptLoader) { | 63 DEFINE_TRACE(WorkletScriptLoader) { |
64 visitor->Trace(fetcher_); | 64 visitor->Trace(fetcher_); |
65 visitor->Trace(client_); | 65 visitor->Trace(client_); |
66 ResourceOwner<ScriptResource, ScriptResourceClient>::Trace(visitor); | 66 ResourceOwner<ScriptResource, ScriptResourceClient>::Trace(visitor); |
67 } | 67 } |
68 | 68 |
69 } // namespace blink | 69 } // namespace blink |
OLD | NEW |