Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Source / platform / network / ResourceTimingInfo.h
blob0db4292350851b0fe33b211dde0c007d1c819932
1 /*
2 * Copyright (C) 2013 Intel Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
31 #ifndef ResourceTimingInfo_h
32 #define ResourceTimingInfo_h
34 #include "platform/CrossThreadCopier.h"
35 #include "platform/network/ResourceRequest.h"
36 #include "platform/network/ResourceResponse.h"
37 #include "wtf/text/AtomicString.h"
39 namespace blink {
41 struct CrossThreadResourceTimingInfoData;
43 class PLATFORM_EXPORT ResourceTimingInfo {
44 public:
45 static PassOwnPtr<ResourceTimingInfo> create(const AtomicString& type, const double time, bool isMainResource)
47 return adoptPtr(new ResourceTimingInfo(type, time, isMainResource));
49 static PassOwnPtr<ResourceTimingInfo> adopt(PassOwnPtr<CrossThreadResourceTimingInfoData>);
51 // Gets a copy of the data suitable for passing to another thread.
52 PassOwnPtr<CrossThreadResourceTimingInfoData> copyData() const;
54 double initialTime() const { return m_initialTime; }
55 bool isMainResource() const { return m_isMainResource; }
57 void setInitiatorType(const AtomicString& type) { m_type = type; }
58 const AtomicString& initiatorType() const { return m_type; }
60 void setOriginalTimingAllowOrigin(const AtomicString& originalTimingAllowOrigin) { m_originalTimingAllowOrigin = originalTimingAllowOrigin; }
61 const AtomicString& originalTimingAllowOrigin() const { return m_originalTimingAllowOrigin; }
63 void setLoadFinishTime(double time) { m_loadFinishTime = time; }
64 double loadFinishTime() const { return m_loadFinishTime; }
66 void setInitialRequest(const ResourceRequest& request) { m_initialRequest = request; }
67 const ResourceRequest& initialRequest() const { return m_initialRequest; }
69 void setFinalResponse(const ResourceResponse& response) { m_finalResponse = response; }
70 const ResourceResponse& finalResponse() const { return m_finalResponse; }
72 void addRedirect(const ResourceResponse& redirectResponse) { m_redirectChain.append(redirectResponse); }
73 const Vector<ResourceResponse>& redirectChain() const { return m_redirectChain; }
75 void clearLoadTimings()
77 m_finalResponse.setResourceLoadTiming(nullptr);
78 for (ResourceResponse& redirect : m_redirectChain)
79 redirect.setResourceLoadTiming(nullptr);
82 private:
83 ResourceTimingInfo(const AtomicString& type, const double time, bool isMainResource)
84 : m_type(type)
85 , m_initialTime(time)
86 , m_isMainResource(isMainResource)
90 AtomicString m_type;
91 AtomicString m_originalTimingAllowOrigin;
92 double m_initialTime;
93 double m_loadFinishTime;
94 ResourceRequest m_initialRequest;
95 ResourceResponse m_finalResponse;
96 Vector<ResourceResponse> m_redirectChain;
97 bool m_isMainResource;
100 struct CrossThreadResourceTimingInfoData {
101 WTF_MAKE_NONCOPYABLE(CrossThreadResourceTimingInfoData);
102 WTF_MAKE_FAST_ALLOCATED(CrossThreadResourceTimingInfoData);
103 public:
104 CrossThreadResourceTimingInfoData() {}
106 String m_type;
107 String m_originalTimingAllowOrigin;
108 double m_initialTime;
109 double m_loadFinishTime;
110 OwnPtr<CrossThreadResourceRequestData> m_initialRequest;
111 OwnPtr<CrossThreadResourceResponseData> m_finalResponse;
112 Vector<OwnPtr<CrossThreadResourceResponseData>> m_redirectChain;
113 bool m_isMainResource;
116 template<> struct CrossThreadCopierBase<false, false, false, ResourceTimingInfo> {
117 typedef PassOwnPtr<CrossThreadResourceTimingInfoData> Type;
118 static Type copy(const ResourceTimingInfo& info) { return info.copyData(); }
121 } // namespace blink
123 #endif