OLD | NEW |
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 25 matching lines...) Expand all Loading... |
36 #include "core/fetch/ResourceLoaderOptions.h" | 36 #include "core/fetch/ResourceLoaderOptions.h" |
37 #include "core/frame/LocalFrameLifecycleObserver.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 EncodedFormData; |
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 LocalFrameLifecycleObserver, 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<EncodedFormData> 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&) final; | 86 void didReceiveResponse(WebURLLoader*, const WebURLResponse&) final; |
87 void didReceiveData(WebURLLoader*, const char*, int, int) final; | 87 void didReceiveData(WebURLLoader*, const char*, int, int) final; |
88 void didFinishLoading(WebURLLoader*, double, int64_t) final; | 88 void didFinishLoading(WebURLLoader*, double, int64_t) final; |
89 void didFail(WebURLLoader*, const WebURLError&) final; | 89 void didFail(WebURLLoader*, const WebURLError&) final; |
90 | 90 |
91 void timeout(Timer<PingLoader>*); | 91 void timeout(Timer<PingLoader>*); |
92 | 92 |
93 void didFailLoading(LocalFrame*); | 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 |
OLD | NEW |