Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1278)

Side by Side Diff: third_party/WebKit/Source/core/loader/ThreadableLoader.cpp

Issue 2880733002: Partially implement WorkerFetchContext and WorkerThreadableLoadingContext and add virtual tests (Closed)
Patch Set: incorporated kinuko's comment Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 DCHECK(ToWorkerGlobalScope(&context)->GetFetchContext());
54 // TODO(horo): Rename DocumentThreadableLoader. We will use it on the
55 // worker thread when off-main-thread-fetch is enabled.
56 return DocumentThreadableLoader::Create(
57 *ThreadableLoadingContext::Create(*ToWorkerGlobalScope(&context)),
58 client, options, resource_loader_options);
59 }
50 return WorkerThreadableLoader::Create(ToWorkerGlobalScope(context), client, 60 return WorkerThreadableLoader::Create(ToWorkerGlobalScope(context), client,
51 options, resource_loader_options); 61 options, resource_loader_options);
52 } 62 }
53 63
54 return DocumentThreadableLoader::Create( 64 return DocumentThreadableLoader::Create(
55 *ThreadableLoadingContext::Create(*ToDocument(&context)), client, options, 65 *ThreadableLoadingContext::Create(*ToDocument(&context)), client, options,
56 resource_loader_options); 66 resource_loader_options);
57 } 67 }
58 68
59 void ThreadableLoader::LoadResourceSynchronously( 69 void ThreadableLoader::LoadResourceSynchronously(
60 ExecutionContext& context, 70 ExecutionContext& context,
61 const ResourceRequest& request, 71 const ResourceRequest& request,
62 ThreadableLoaderClient& client, 72 ThreadableLoaderClient& client,
63 const ThreadableLoaderOptions& options, 73 const ThreadableLoaderOptions& options,
64 const ResourceLoaderOptions& resource_loader_options) { 74 const ResourceLoaderOptions& resource_loader_options) {
65 if (context.IsWorkerGlobalScope()) { 75 if (context.IsWorkerGlobalScope()) {
66 WorkerThreadableLoader::LoadResourceSynchronously( 76 WorkerThreadableLoader::LoadResourceSynchronously(
67 ToWorkerGlobalScope(context), request, client, options, 77 ToWorkerGlobalScope(context), request, client, options,
68 resource_loader_options); 78 resource_loader_options);
69 return; 79 return;
70 } 80 }
71 81
72 DocumentThreadableLoader::LoadResourceSynchronously( 82 DocumentThreadableLoader::LoadResourceSynchronously(
73 ToDocument(context), request, client, options, resource_loader_options); 83 ToDocument(context), request, client, options, resource_loader_options);
74 } 84 }
75 85
76 } // namespace blink 86 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698