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

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

Issue 2842123002: WorkerShadowFetchContext
Patch Set: . 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 namespace blink { 58 namespace blink {
59 59
60 // We provide a custom implementation of this class that calls out to the 60 // We provide a custom implementation of this class that calls out to the
61 // embedding application instead of using WebCore's built in appcache system. 61 // embedding application instead of using WebCore's built in appcache system.
62 // This file replaces webcore/appcache/ApplicationCacheHost.cpp in our build. 62 // This file replaces webcore/appcache/ApplicationCacheHost.cpp in our build.
63 63
64 ApplicationCacheHost::ApplicationCacheHost(DocumentLoader* document_loader) 64 ApplicationCacheHost::ApplicationCacheHost(DocumentLoader* document_loader)
65 : dom_application_cache_(nullptr), 65 : dom_application_cache_(nullptr),
66 document_loader_(document_loader), 66 document_loader_(document_loader),
67 defers_events_(true) { 67 defers_events_(true) {
68 DCHECK(document_loader_);
69 } 68 }
70 69
71 ApplicationCacheHost::~ApplicationCacheHost() { 70 ApplicationCacheHost::~ApplicationCacheHost() {
72 // Verify that detachFromDocumentLoader() has been performed already. 71 // Verify that detachFromDocumentLoader() has been performed already.
73 DCHECK(!host_); 72 DCHECK(!host_);
74 } 73 }
75 74
76 void ApplicationCacheHost::WillStartLoading(ResourceRequest& request) { 75 void ApplicationCacheHost::WillStartLoading(ResourceRequest& request) {
77 if (!IsApplicationCacheEnabled()) 76 if (!IsApplicationCacheEnabled())
78 return; 77 return;
79 78
80 if (request.GetFrameType() == WebURLRequest::kFrameTypeTopLevel || 79 if (request.GetFrameType() == WebURLRequest::kFrameTypeTopLevel ||
81 request.GetFrameType() == WebURLRequest::kFrameTypeNested) { 80 request.GetFrameType() == WebURLRequest::kFrameTypeNested) {
82 WillStartLoadingMainResource(request); 81 WillStartLoadingMainResource(request);
83 } else { 82 } else {
84 WillStartLoadingResource(request); 83 WillStartLoadingResource(request);
85 } 84 }
86 } 85 }
87 86
88 void ApplicationCacheHost::WillStartLoadingMainResource( 87 void ApplicationCacheHost::WillStartLoadingMainResource(
89 ResourceRequest& request) { 88 ResourceRequest& request) {
90 // We defer creating the outer host object to avoid spurious 89 // We defer creating the outer host object to avoid spurious
91 // creation/destruction around creating empty documents. At this point, we're 90 // creation/destruction around creating empty documents. At this point, we're
92 // initiating a main resource load for the document, so its for real. 91 // initiating a main resource load for the document, so its for real.
93 92
94 DCHECK(IsApplicationCacheEnabled()); 93 DCHECK(IsApplicationCacheEnabled());
95 94
96 DCHECK(document_loader_->GetFrame()); 95 if (!host_) {
97 LocalFrame& frame = *document_loader_->GetFrame(); 96 DCHECK(document_loader_->GetFrame());
98 host_ = frame.Loader().Client()->CreateApplicationCacheHost(this); 97 LocalFrame& frame = *document_loader_->GetFrame();
99 if (!host_) 98 host_ = frame.Loader().Client()->CreateApplicationCacheHost(this);
100 return; 99 if (!host_)
100 return;
101 }
101 102
102 WrappedResourceRequest wrapped(request); 103 WrappedResourceRequest wrapped(request);
103 104
104 const WebApplicationCacheHost* spawning_host = nullptr; 105 const WebApplicationCacheHost* spawning_host = nullptr;
105 Frame* spawning_frame = frame.Tree().Parent(); 106 if (document_loader_) {
106 if (!spawning_frame || !spawning_frame->IsLocalFrame()) 107 DCHECK(document_loader_->GetFrame());
107 spawning_frame = frame.Loader().Opener(); 108 LocalFrame& frame = *document_loader_->GetFrame();
108 if (!spawning_frame || !spawning_frame->IsLocalFrame()) 109 Frame* spawning_frame = frame.Tree().Parent();
109 spawning_frame = &frame; 110 if (!spawning_frame || !spawning_frame->IsLocalFrame())
110 if (DocumentLoader* spawning_doc_loader = 111 spawning_frame = frame.Loader().Opener();
111 ToLocalFrame(spawning_frame)->Loader().GetDocumentLoader()) { 112 if (!spawning_frame || !spawning_frame->IsLocalFrame())
112 spawning_host = 113 spawning_frame = &frame;
113 spawning_doc_loader->GetApplicationCacheHost() 114 if (DocumentLoader* spawning_doc_loader =
114 ? spawning_doc_loader->GetApplicationCacheHost()->host_.get() 115 ToLocalFrame(spawning_frame)->Loader().GetDocumentLoader()) {
115 : nullptr; 116 spawning_host =
117 spawning_doc_loader->GetApplicationCacheHost()
118 ? spawning_doc_loader->GetApplicationCacheHost()->host_.get()
119 : nullptr;
120 }
116 } 121 }
117 122
118 host_->WillStartMainResourceRequest(wrapped, spawning_host); 123 host_->WillStartMainResourceRequest(wrapped, spawning_host);
119 124
120 // NOTE: The semantics of this method, and others in this interface, are 125 // NOTE: The semantics of this method, and others in this interface, are
121 // subtly different than the method names would suggest. For example, in this 126 // subtly different than the method names would suggest. For example, in this
122 // method never returns an appcached response in the SubstituteData out 127 // method never returns an appcached response in the SubstituteData out
123 // argument, instead we return the appcached response thru the usual resource 128 // argument, instead we return the appcached response thru the usual resource
124 // loading pipeline. 129 // loading pipeline.
125 } 130 }
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 } 316 }
312 return success; 317 return success;
313 } 318 }
314 319
315 void ApplicationCacheHost::Abort() { 320 void ApplicationCacheHost::Abort() {
316 if (host_) 321 if (host_)
317 host_->Abort(); 322 host_->Abort();
318 } 323 }
319 324
320 bool ApplicationCacheHost::IsApplicationCacheEnabled() { 325 bool ApplicationCacheHost::IsApplicationCacheEnabled() {
321 DCHECK(document_loader_->GetFrame()); 326 DCHECK(host_ || document_loader_->GetFrame());
327 if (host_)
328 return true;
322 return document_loader_->GetFrame()->GetSettings() && 329 return document_loader_->GetFrame()->GetSettings() &&
323 document_loader_->GetFrame() 330 document_loader_->GetFrame()
324 ->GetSettings() 331 ->GetSettings()
325 ->GetOfflineWebApplicationCacheEnabled(); 332 ->GetOfflineWebApplicationCacheEnabled();
326 } 333 }
327 334
328 void ApplicationCacheHost::DidChangeCacheAssociation() { 335 void ApplicationCacheHost::DidChangeCacheAssociation() {
329 // FIXME: Prod the inspector to update its notion of what cache the page is 336 // FIXME: Prod the inspector to update its notion of what cache the page is
330 // using. 337 // using.
331 } 338 }
(...skipping 21 matching lines...) Expand all
353 NotifyApplicationCache(kErrorEvent, 0, 0, reason, url.GetString(), status, 360 NotifyApplicationCache(kErrorEvent, 0, 0, reason, url.GetString(), status,
354 message); 361 message);
355 } 362 }
356 363
357 DEFINE_TRACE(ApplicationCacheHost) { 364 DEFINE_TRACE(ApplicationCacheHost) {
358 visitor->Trace(dom_application_cache_); 365 visitor->Trace(dom_application_cache_);
359 visitor->Trace(document_loader_); 366 visitor->Trace(document_loader_);
360 } 367 }
361 368
362 } // namespace blink 369 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/loader/appcache/ApplicationCacheHost.h ('k') | third_party/WebKit/Source/core/workers/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698