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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 namespace WebCore { | 42 namespace WebCore { |
43 | 43 |
44 class FormData; | 44 class FormData; |
45 class LocalFrame; | 45 class LocalFrame; |
46 class KURL; | 46 class KURL; |
47 class ResourceError; | 47 class ResourceError; |
48 class ResourceHandle; | 48 class ResourceHandle; |
49 class ResourceRequest; | 49 class ResourceRequest; |
50 class ResourceResponse; | 50 class ResourceResponse; |
51 | 51 |
52 // This class triggers asynchronous loads independent of LocalFrame staying aliv
e (i.e., auditing pingbacks). | 52 // Issue an asynchronous, one-directional request at some resources, ignoring |
53 // Since nothing depends on resources loaded through this class, we just want | 53 // any response. The request is made independent of any LocalFrame staying alive
, |
54 // to allow the load to live long enough to ensure the message was actually sent
. | 54 // and must only stay alive until the transmission has completed successfully |
55 // Therefore, as soon as a callback is received from the ResourceHandle, this cl
ass | 55 // (or not -- errors are not propagated back either.) Upon transmission, the |
56 // will cancel the load and delete itself. | 56 // the load is cancelled and the loader cancels itself. |
57 class PingLoader FINAL : public PageLifecycleObserver, private blink::WebURLLoad
erClient { | 57 // |
58 WTF_MAKE_NONCOPYABLE(PingLoader); WTF_MAKE_FAST_ALLOCATED; | 58 // The ping loader is used by audit pings, beacon transmissions and image loads |
| 59 // during page unloading. |
| 60 // |
| 61 class PingLoader : public PageLifecycleObserver, private blink::WebURLLoaderClie
nt { |
| 62 WTF_MAKE_NONCOPYABLE(PingLoader); |
| 63 WTF_MAKE_FAST_ALLOCATED; |
59 public: | 64 public: |
| 65 virtual ~PingLoader(); |
| 66 |
60 enum ViolationReportType { | 67 enum ViolationReportType { |
61 ContentSecurityPolicyViolationReport, | 68 ContentSecurityPolicyViolationReport, |
62 XSSAuditorViolationReport | 69 XSSAuditorViolationReport |
63 }; | 70 }; |
64 | 71 |
65 static void loadImage(LocalFrame*, const KURL& url); | 72 static void loadImage(LocalFrame*, const KURL& url); |
66 static void sendPing(LocalFrame*, const KURL& pingURL, const KURL& destinati
onURL); | 73 static void sendLinkAuditPing(LocalFrame*, const KURL& pingURL, const KURL&
destinationURL); |
67 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); |
68 | 75 |
69 virtual ~PingLoader(); | 76 protected: |
70 | |
71 private: | |
72 PingLoader(LocalFrame*, ResourceRequest&, const FetchInitiatorInfo&, StoredC
redentials); | 77 PingLoader(LocalFrame*, ResourceRequest&, const FetchInitiatorInfo&, StoredC
redentials); |
73 | 78 |
74 static void start(LocalFrame*, ResourceRequest&, const FetchInitiatorInfo&,
StoredCredentials = AllowStoredCredentials); | 79 static void start(LocalFrame*, ResourceRequest&, const FetchInitiatorInfo&,
StoredCredentials = AllowStoredCredentials); |
75 | 80 |
| 81 private: |
76 virtual void didReceiveResponse(blink::WebURLLoader*, const blink::WebURLRes
ponse&) OVERRIDE; | 82 virtual void didReceiveResponse(blink::WebURLLoader*, const blink::WebURLRes
ponse&) OVERRIDE; |
77 virtual void didReceiveData(blink::WebURLLoader*, const char*, int, int) OVE
RRIDE; | 83 virtual void didReceiveData(blink::WebURLLoader*, const char*, int, int) OVE
RRIDE; |
78 virtual void didFinishLoading(blink::WebURLLoader*, double, int64_t) OVERRID
E; | 84 virtual void didFinishLoading(blink::WebURLLoader*, double, int64_t) OVERRID
E; |
79 virtual void didFail(blink::WebURLLoader*, const blink::WebURLError&) OVERRI
DE; | 85 virtual void didFail(blink::WebURLLoader*, const blink::WebURLError&) OVERRI
DE; |
80 | 86 |
81 void timeout(Timer<PingLoader>*); | 87 void timeout(Timer<PingLoader>*); |
82 | 88 |
83 OwnPtr<blink::WebURLLoader> m_loader; | 89 OwnPtr<blink::WebURLLoader> m_loader; |
84 Timer<PingLoader> m_timeout; | 90 Timer<PingLoader> m_timeout; |
85 String m_url; | 91 String m_url; |
86 unsigned long m_identifier; | 92 unsigned long m_identifier; |
87 }; | 93 }; |
88 | 94 |
89 } | 95 } |
90 | 96 |
91 #endif | 97 #endif // PingLoader_h |
OLD | NEW |