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

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

Issue 2631653002: Make ApplicationCache a DOMWindowClient (Closed)
Patch Set: Created 3 years, 11 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) 2008, 2009 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008, 2009 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 20 matching lines...) Expand all
31 #include "core/events/EventListener.h" 31 #include "core/events/EventListener.h"
32 #include "core/frame/Deprecation.h" 32 #include "core/frame/Deprecation.h"
33 #include "core/frame/HostsUsingFeatures.h" 33 #include "core/frame/HostsUsingFeatures.h"
34 #include "core/frame/LocalFrame.h" 34 #include "core/frame/LocalFrame.h"
35 #include "core/frame/UseCounter.h" 35 #include "core/frame/UseCounter.h"
36 #include "core/loader/DocumentLoader.h" 36 #include "core/loader/DocumentLoader.h"
37 #include "core/loader/FrameLoader.h" 37 #include "core/loader/FrameLoader.h"
38 38
39 namespace blink { 39 namespace blink {
40 40
41 ApplicationCache::ApplicationCache(LocalFrame* frame) 41 ApplicationCache::ApplicationCache(LocalFrame* frame) : DOMWindowClient(frame) {
42 : ContextLifecycleObserver(frame->document()) {
43 ApplicationCacheHost* cacheHost = applicationCacheHost(); 42 ApplicationCacheHost* cacheHost = applicationCacheHost();
44 if (cacheHost) 43 if (cacheHost)
45 cacheHost->setApplicationCache(this); 44 cacheHost->setApplicationCache(this);
46 } 45 }
47 46
48 DEFINE_TRACE(ApplicationCache) { 47 DEFINE_TRACE(ApplicationCache) {
49 EventTargetWithInlineData::trace(visitor); 48 EventTargetWithInlineData::trace(visitor);
50 ContextLifecycleObserver::trace(visitor); 49 DOMWindowClient::trace(visitor);
51 }
52
53 void ApplicationCache::contextDestroyed() {
54 if (ApplicationCacheHost* cacheHost = applicationCacheHost())
dcheng 2017/01/13 09:14:16 How come it's OK to skip this?
haraken 2017/01/13 09:18:21 cacheHost->setApplicationCache(0) was called just
55 cacheHost->setApplicationCache(0);
56 } 50 }
57 51
58 ApplicationCacheHost* ApplicationCache::applicationCacheHost() const { 52 ApplicationCacheHost* ApplicationCache::applicationCacheHost() const {
59 if (!frame() || !frame()->loader().documentLoader()) 53 if (!frame() || !frame()->loader().documentLoader())
60 return 0; 54 return 0;
61 return frame()->loader().documentLoader()->applicationCacheHost(); 55 return frame()->loader().documentLoader()->applicationCacheHost();
62 } 56 }
63 57
64 unsigned short ApplicationCache::status() const { 58 unsigned short ApplicationCache::status() const {
65 recordAPIUseType(); 59 recordAPIUseType();
(...skipping 25 matching lines...) Expand all
91 ApplicationCacheHost* cacheHost = applicationCacheHost(); 85 ApplicationCacheHost* cacheHost = applicationCacheHost();
92 if (cacheHost) 86 if (cacheHost)
93 cacheHost->abort(); 87 cacheHost->abort();
94 } 88 }
95 89
96 const AtomicString& ApplicationCache::interfaceName() const { 90 const AtomicString& ApplicationCache::interfaceName() const {
97 return EventTargetNames::ApplicationCache; 91 return EventTargetNames::ApplicationCache;
98 } 92 }
99 93
100 ExecutionContext* ApplicationCache::getExecutionContext() const { 94 ExecutionContext* ApplicationCache::getExecutionContext() const {
101 if (frame()) 95 return frame() ? frame()->document() : nullptr;
102 return frame()->document();
103 return 0;
104 } 96 }
105 97
106 const AtomicString& ApplicationCache::toEventType( 98 const AtomicString& ApplicationCache::toEventType(
107 ApplicationCacheHost::EventID id) { 99 ApplicationCacheHost::EventID id) {
108 switch (id) { 100 switch (id) {
109 case ApplicationCacheHost::kCheckingEvent: 101 case ApplicationCacheHost::kCheckingEvent:
110 return EventTypeNames::checking; 102 return EventTypeNames::checking;
111 case ApplicationCacheHost::kErrorEvent: 103 case ApplicationCacheHost::kErrorEvent:
112 return EventTypeNames::error; 104 return EventTypeNames::error;
113 case ApplicationCacheHost::kNoupdateEvent: 105 case ApplicationCacheHost::kNoupdateEvent:
(...skipping 27 matching lines...) Expand all
141 } else { 133 } else {
142 Deprecation::countDeprecation( 134 Deprecation::countDeprecation(
143 document, UseCounter::ApplicationCacheAPIInsecureOrigin); 135 document, UseCounter::ApplicationCacheAPIInsecureOrigin);
144 HostsUsingFeatures::countAnyWorld( 136 HostsUsingFeatures::countAnyWorld(
145 *document, 137 *document,
146 HostsUsingFeatures::Feature::ApplicationCacheAPIInsecureHost); 138 HostsUsingFeatures::Feature::ApplicationCacheAPIInsecureHost);
147 } 139 }
148 } 140 }
149 141
150 } // namespace blink 142 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698