OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 16 matching lines...) Expand all Loading... | |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "core/loader/ThreadableLoader.h" | 31 #include "core/loader/ThreadableLoader.h" |
32 | 32 |
33 #include "core/dom/Document.h" | 33 #include "core/dom/Document.h" |
34 #include "core/dom/ExecutionContext.h" | 34 #include "core/dom/ExecutionContext.h" |
35 #include "core/loader/DocumentThreadableLoader.h" | 35 #include "core/loader/DocumentThreadableLoader.h" |
36 #include "core/loader/ThreadableLoadingContext.h" | 36 #include "core/loader/ThreadableLoadingContext.h" |
37 #include "core/loader/WorkerFetchContext.h" | |
37 #include "core/loader/WorkerThreadableLoader.h" | 38 #include "core/loader/WorkerThreadableLoader.h" |
38 #include "core/workers/WorkerGlobalScope.h" | 39 #include "core/workers/WorkerGlobalScope.h" |
40 #include "platform/RuntimeEnabledFeatures.h" | |
39 | 41 |
40 namespace blink { | 42 namespace blink { |
41 | 43 |
42 ThreadableLoader* ThreadableLoader::Create( | 44 ThreadableLoader* ThreadableLoader::Create( |
43 ExecutionContext& context, | 45 ExecutionContext& context, |
44 ThreadableLoaderClient* client, | 46 ThreadableLoaderClient* client, |
45 const ThreadableLoaderOptions& options, | 47 const ThreadableLoaderOptions& options, |
46 const ResourceLoaderOptions& resource_loader_options) { | 48 const ResourceLoaderOptions& resource_loader_options) { |
47 DCHECK(client); | 49 DCHECK(client); |
48 | 50 |
49 if (context.IsWorkerGlobalScope()) { | 51 if (context.IsWorkerGlobalScope()) { |
52 if (RuntimeEnabledFeatures::offMainThreadFetchEnabled()) { | |
53 WorkerFetchContext* worker_fetch_contrext = | |
54 ToWorkerGlobalScope(&context)->GetFetchContext(); | |
55 if (worker_fetch_contrext) { | |
kinuko
2017/05/13 13:26:42
When this could return nullptr?
horo
2017/05/13 17:05:45
Ah, yes.
This should be DCHECK().
| |
56 return DocumentThreadableLoader::Create( | |
kinuko
2017/05/13 13:26:42
Can you add a TODO to DocumentThreadableLoader to
horo
2017/05/13 17:05:45
Done.
| |
57 *ThreadableLoadingContext::Create(*ToWorkerGlobalScope(&context)), | |
58 client, options, resource_loader_options); | |
59 } | |
60 } | |
50 return WorkerThreadableLoader::Create(ToWorkerGlobalScope(context), client, | 61 return WorkerThreadableLoader::Create(ToWorkerGlobalScope(context), client, |
51 options, resource_loader_options); | 62 options, resource_loader_options); |
52 } | 63 } |
53 | 64 |
54 return DocumentThreadableLoader::Create( | 65 return DocumentThreadableLoader::Create( |
55 *ThreadableLoadingContext::Create(*ToDocument(&context)), client, options, | 66 *ThreadableLoadingContext::Create(*ToDocument(&context)), client, options, |
56 resource_loader_options); | 67 resource_loader_options); |
57 } | 68 } |
58 | 69 |
59 void ThreadableLoader::LoadResourceSynchronously( | 70 void ThreadableLoader::LoadResourceSynchronously( |
60 ExecutionContext& context, | 71 ExecutionContext& context, |
61 const ResourceRequest& request, | 72 const ResourceRequest& request, |
62 ThreadableLoaderClient& client, | 73 ThreadableLoaderClient& client, |
63 const ThreadableLoaderOptions& options, | 74 const ThreadableLoaderOptions& options, |
64 const ResourceLoaderOptions& resource_loader_options) { | 75 const ResourceLoaderOptions& resource_loader_options) { |
65 if (context.IsWorkerGlobalScope()) { | 76 if (context.IsWorkerGlobalScope()) { |
66 WorkerThreadableLoader::LoadResourceSynchronously( | 77 WorkerThreadableLoader::LoadResourceSynchronously( |
67 ToWorkerGlobalScope(context), request, client, options, | 78 ToWorkerGlobalScope(context), request, client, options, |
68 resource_loader_options); | 79 resource_loader_options); |
69 return; | 80 return; |
70 } | 81 } |
71 | 82 |
72 DocumentThreadableLoader::LoadResourceSynchronously( | 83 DocumentThreadableLoader::LoadResourceSynchronously( |
73 ToDocument(context), request, client, options, resource_loader_options); | 84 ToDocument(context), request, client, options, resource_loader_options); |
74 } | 85 } |
75 | 86 |
76 } // namespace blink | 87 } // namespace blink |
OLD | NEW |