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

Side by Side Diff: third_party/WebKit/Source/platform/loader/fetch/ResourceTimingInfo.h

Issue 2847893003: Support PerformanceResourceTiming for Service Worker Navigation Preload (Closed)
Patch Set: s/timestams/timestamps/ Created 3 years, 7 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) 2013 Intel Inc. All rights reserved. 2 * Copyright (C) 2013 Intel 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 transfer_size_ += encoded_data_length; 97 transfer_size_ += encoded_data_length;
98 } 98 }
99 long long TransferSize() const { return transfer_size_; } 99 long long TransferSize() const { return transfer_size_; }
100 100
101 void ClearLoadTimings() { 101 void ClearLoadTimings() {
102 final_response_.SetResourceLoadTiming(nullptr); 102 final_response_.SetResourceLoadTiming(nullptr);
103 for (ResourceResponse& redirect : redirect_chain_) 103 for (ResourceResponse& redirect : redirect_chain_)
104 redirect.SetResourceLoadTiming(nullptr); 104 redirect.SetResourceLoadTiming(nullptr);
105 } 105 }
106 106
107 // The timestamps in PerformanceResourceTiming are measured relative from the
108 // time origin. In most cases these timestamps must be positive value, so we
109 // use 0 for invalid negative values. But the timestamps for Service Worker
110 // navigation preload requests may be negative, because these requests may
111 // be started before the service worker started. We set this flag true, to
112 // support such case.
113 void SetNegativeAllowed(bool negative_allowed) {
114 negative_allowed_ = negative_allowed;
115 }
116 bool NegativeAllowed() const { return negative_allowed_; }
117
107 private: 118 private:
108 ResourceTimingInfo(const AtomicString& type, 119 ResourceTimingInfo(const AtomicString& type,
109 const double time, 120 const double time,
110 bool is_main_resource) 121 bool is_main_resource)
111 : type_(type), 122 : type_(type), initial_time_(time), is_main_resource_(is_main_resource) {}
112 initial_time_(time),
113 transfer_size_(0),
114 is_main_resource_(is_main_resource),
115 has_cross_origin_redirect_(false) {}
116 123
117 AtomicString type_; 124 AtomicString type_;
118 AtomicString original_timing_allow_origin_; 125 AtomicString original_timing_allow_origin_;
119 double initial_time_; 126 double initial_time_;
120 double load_finish_time_; 127 double load_finish_time_;
121 KURL initial_url_; 128 KURL initial_url_;
122 ResourceResponse final_response_; 129 ResourceResponse final_response_;
123 Vector<ResourceResponse> redirect_chain_; 130 Vector<ResourceResponse> redirect_chain_;
124 long long transfer_size_; 131 long long transfer_size_ = 0;
125 bool is_main_resource_; 132 bool is_main_resource_;
126 bool has_cross_origin_redirect_; 133 bool has_cross_origin_redirect_ = false;
134 bool negative_allowed_ = false;
127 }; 135 };
128 136
129 struct CrossThreadResourceTimingInfoData { 137 struct CrossThreadResourceTimingInfoData {
130 WTF_MAKE_NONCOPYABLE(CrossThreadResourceTimingInfoData); 138 WTF_MAKE_NONCOPYABLE(CrossThreadResourceTimingInfoData);
131 USING_FAST_MALLOC(CrossThreadResourceTimingInfoData); 139 USING_FAST_MALLOC(CrossThreadResourceTimingInfoData);
132 140
133 public: 141 public:
134 CrossThreadResourceTimingInfoData() {} 142 CrossThreadResourceTimingInfoData() {}
135 143
136 String type_; 144 String type_;
137 String original_timing_allow_origin_; 145 String original_timing_allow_origin_;
138 double initial_time_; 146 double initial_time_;
139 double load_finish_time_; 147 double load_finish_time_;
140 KURL initial_url_; 148 KURL initial_url_;
141 std::unique_ptr<CrossThreadResourceResponseData> final_response_; 149 std::unique_ptr<CrossThreadResourceResponseData> final_response_;
142 Vector<std::unique_ptr<CrossThreadResourceResponseData>> redirect_chain_; 150 Vector<std::unique_ptr<CrossThreadResourceResponseData>> redirect_chain_;
143 long long transfer_size_; 151 long long transfer_size_;
144 bool is_main_resource_; 152 bool is_main_resource_;
153 bool negative_allowed_;
145 }; 154 };
146 155
147 template <> 156 template <>
148 struct CrossThreadCopier<ResourceTimingInfo> { 157 struct CrossThreadCopier<ResourceTimingInfo> {
149 typedef WTF::PassedWrapper<std::unique_ptr<CrossThreadResourceTimingInfoData>> 158 typedef WTF::PassedWrapper<std::unique_ptr<CrossThreadResourceTimingInfoData>>
150 Type; 159 Type;
151 static Type Copy(const ResourceTimingInfo& info) { 160 static Type Copy(const ResourceTimingInfo& info) {
152 return WTF::Passed(info.CopyData()); 161 return WTF::Passed(info.CopyData());
153 } 162 }
154 }; 163 };
155 164
156 } // namespace blink 165 } // namespace blink
157 166
158 #endif 167 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698