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

Side by Side Diff: Source/core/loader/PingLoader.h

Issue 1311433008: Migrate PingLoader to be a LocalFrameLifecycleObserver. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix style. Created 5 years, 3 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
« no previous file with comments | « Source/core/loader/BeaconLoader.cpp ('k') | Source/core/loader/PingLoader.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 31
32 #ifndef PingLoader_h 32 #ifndef PingLoader_h
33 #define PingLoader_h 33 #define PingLoader_h
34 34
35 #include "core/CoreExport.h" 35 #include "core/CoreExport.h"
36 #include "core/fetch/ResourceLoaderOptions.h" 36 #include "core/fetch/ResourceLoaderOptions.h"
37 #include "core/page/PageLifecycleObserver.h" 37 #include "core/frame/LocalFrameLifecycleObserver.h"
38 #include "platform/Timer.h" 38 #include "platform/Timer.h"
39 #include "platform/heap/Handle.h" 39 #include "platform/heap/Handle.h"
40 #include "public/platform/WebURLLoaderClient.h" 40 #include "public/platform/WebURLLoaderClient.h"
41 #include "wtf/Noncopyable.h" 41 #include "wtf/Noncopyable.h"
42 #include "wtf/RefPtr.h" 42 #include "wtf/RefPtr.h"
43 43
44 namespace blink { 44 namespace blink {
45 45
46 class FormData; 46 class FormData;
47 class LocalFrame; 47 class LocalFrame;
48 class KURL; 48 class KURL;
49 class ResourceRequest; 49 class ResourceRequest;
50 50
51 // Issue an asynchronous, one-directional request at some resources, ignoring 51 // Issue an asynchronous, one-directional request at some resources, ignoring
52 // any response. The request is made independent of any LocalFrame staying alive , 52 // any response. The request is made independent of any LocalFrame staying alive ,
53 // and must only stay alive until the transmission has completed successfully 53 // and must only stay alive until the transmission has completed successfully
54 // (or not -- errors are not propagated back either.) Upon transmission, the 54 // (or not -- errors are not propagated back either.) Upon transmission, the
55 // the load is cancelled and the loader cancels itself. 55 // the load is cancelled and the loader cancels itself.
56 // 56 //
57 // The ping loader is used by audit pings, beacon transmissions and image loads 57 // The ping loader is used by audit pings, beacon transmissions and image loads
58 // during page unloading. 58 // during page unloading.
59 // 59 //
60 class CORE_EXPORT PingLoader : public RefCountedWillBeRefCountedGarbageCollected <PingLoader>, public PageLifecycleObserver, private WebURLLoaderClient { 60 class CORE_EXPORT PingLoader : public RefCountedWillBeRefCountedGarbageCollected <PingLoader>, public LocalFrameLifecycleObserver, private WebURLLoaderClient {
61 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(PingLoader); 61 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(PingLoader);
62 WTF_MAKE_NONCOPYABLE(PingLoader); 62 WTF_MAKE_NONCOPYABLE(PingLoader);
63 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(PingLoader); 63 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(PingLoader);
64 public: 64 public:
65 ~PingLoader() override; 65 ~PingLoader() override;
66 66
67 enum ViolationReportType { 67 enum ViolationReportType {
68 ContentSecurityPolicyViolationReport, 68 ContentSecurityPolicyViolationReport,
69 XSSAuditorViolationReport 69 XSSAuditorViolationReport
70 }; 70 };
71 71
72 static void loadImage(LocalFrame*, const KURL&); 72 static void loadImage(LocalFrame*, const KURL&);
73 static void sendLinkAuditPing(LocalFrame*, const KURL& pingURL, const KURL& destinationURL); 73 static void sendLinkAuditPing(LocalFrame*, const KURL& pingURL, const KURL& destinationURL);
74 static void sendViolationReport(LocalFrame*, const KURL& reportURL, PassRefP tr<FormData> report, ViolationReportType); 74 static void sendViolationReport(LocalFrame*, const KURL& reportURL, PassRefP tr<FormData> report, ViolationReportType);
75 75
76 DECLARE_VIRTUAL_TRACE(); 76 DECLARE_VIRTUAL_TRACE();
77 77
78 protected: 78 protected:
79 PingLoader(LocalFrame*, ResourceRequest&, const FetchInitiatorInfo&, StoredC redentials); 79 PingLoader(LocalFrame*, ResourceRequest&, const FetchInitiatorInfo&, StoredC redentials);
80 80
81 static void start(LocalFrame*, ResourceRequest&, const FetchInitiatorInfo&, StoredCredentials = AllowStoredCredentials); 81 static void start(LocalFrame*, ResourceRequest&, const FetchInitiatorInfo&, StoredCredentials = AllowStoredCredentials);
82 82
83 void dispose(); 83 void dispose();
84 84
85 private: 85 private:
86 void didReceiveResponse(WebURLLoader*, const WebURLResponse&) override; 86 void didReceiveResponse(WebURLLoader*, const WebURLResponse&) final;
87 void didReceiveData(WebURLLoader*, const char*, int, int) override; 87 void didReceiveData(WebURLLoader*, const char*, int, int) final;
88 void didFinishLoading(WebURLLoader*, double, int64_t) override; 88 void didFinishLoading(WebURLLoader*, double, int64_t) final;
89 void didFail(WebURLLoader*, const WebURLError&) override; 89 void didFail(WebURLLoader*, const WebURLError&) final;
90 90
91 void timeout(Timer<PingLoader>*); 91 void timeout(Timer<PingLoader>*);
92 92
93 void didFailLoading(Page*); 93 void didFailLoading(LocalFrame*);
94 94
95 OwnPtr<WebURLLoader> m_loader; 95 OwnPtr<WebURLLoader> m_loader;
96 Timer<PingLoader> m_timeout; 96 Timer<PingLoader> m_timeout;
97 String m_url; 97 String m_url;
98 unsigned long m_identifier; 98 unsigned long m_identifier;
99 }; 99 };
100 100
101 } // namespace blink 101 } // namespace blink
102 102
103 #endif // PingLoader_h 103 #endif // PingLoader_h
OLDNEW
« no previous file with comments | « Source/core/loader/BeaconLoader.cpp ('k') | Source/core/loader/PingLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698