| 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 #ifndef WorkletScriptLoader_h | 5 #ifndef WorkletScriptLoader_h |
| 6 #define WorkletScriptLoader_h | 6 #define WorkletScriptLoader_h |
| 7 | 7 |
| 8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "core/loader/resource/ScriptResource.h" | 9 #include "core/loader/resource/ScriptResource.h" |
| 10 #include "platform/loader/fetch/ResourceClient.h" | 10 #include "platform/loader/fetch/ResourceClient.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 static WorkletScriptLoader* Create(ResourceFetcher* fetcher, Client* client) { | 39 static WorkletScriptLoader* Create(ResourceFetcher* fetcher, Client* client) { |
| 40 return new WorkletScriptLoader(fetcher, client); | 40 return new WorkletScriptLoader(fetcher, client); |
| 41 } | 41 } |
| 42 | 42 |
| 43 ~WorkletScriptLoader() override = default; | 43 ~WorkletScriptLoader() override = default; |
| 44 | 44 |
| 45 // Fetches an URL and loads it as a classic script. Synchronously calls | 45 // Fetches an URL and loads it as a classic script. Synchronously calls |
| 46 // Client::notifyWorkletScriptLoadingFinished() if there is an error. | 46 // Client::notifyWorkletScriptLoadingFinished() if there is an error. |
| 47 void FetchScript(const String& script_url); | 47 void FetchScript(const KURL& module_url_record); |
| 48 | 48 |
| 49 // Cancels resource loading and synchronously calls | 49 // Cancels resource loading and synchronously calls |
| 50 // Client::notifyWorkletScriptLoadingFinished(). | 50 // Client::notifyWorkletScriptLoadingFinished(). |
| 51 void Cancel(); | 51 void Cancel(); |
| 52 | 52 |
| 53 // Returns true if a script was successfully loaded. This should be called | 53 // Returns true if a script was successfully loaded. This should be called |
| 54 // after Client::notifyWorkletScriptLoadingFinished() is called. | 54 // after Client::notifyWorkletScriptLoadingFinished() is called. |
| 55 bool WasScriptLoadSuccessful() const; | 55 bool WasScriptLoadSuccessful() const; |
| 56 | 56 |
| 57 DECLARE_TRACE(); | 57 DECLARE_TRACE(); |
| 58 | 58 |
| 59 private: | 59 private: |
| 60 WorkletScriptLoader(ResourceFetcher*, Client*); | 60 WorkletScriptLoader(ResourceFetcher*, Client*); |
| 61 | 61 |
| 62 // ResourceClient | 62 // ResourceClient |
| 63 void NotifyFinished(Resource*) final; | 63 void NotifyFinished(Resource*) final; |
| 64 String DebugName() const final { return "WorkletLoader"; } | 64 String DebugName() const final { return "WorkletLoader"; } |
| 65 | 65 |
| 66 Member<ResourceFetcher> fetcher_; | 66 Member<ResourceFetcher> fetcher_; |
| 67 Member<Client> client_; | 67 Member<Client> client_; |
| 68 | 68 |
| 69 bool was_script_load_successful_ = false; | 69 bool was_script_load_successful_ = false; |
| 70 bool was_script_load_complete_ = false; | 70 bool was_script_load_complete_ = false; |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 } // namespace blink | 73 } // namespace blink |
| 74 | 74 |
| 75 #endif // WorkletScriptLoader_h | 75 #endif // WorkletScriptLoader_h |
| OLD | NEW |