OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/common/metrics_helpers.h" | 5 #include "chrome/common/metrics_helpers.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/md5.h" | 10 #include "base/md5.h" |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 WriteAttribute("targetidhash", command_hash); | 219 WriteAttribute("targetidhash", command_hash); |
220 | 220 |
221 // TODO(jhughes): Properly track windows. | 221 // TODO(jhughes): Properly track windows. |
222 WriteIntAttribute("window", 0); | 222 WriteIntAttribute("window", 0); |
223 WriteCommonEventAttributes(); | 223 WriteCommonEventAttributes(); |
224 | 224 |
225 ++num_events_; | 225 ++num_events_; |
226 } | 226 } |
227 | 227 |
228 void MetricsLogBase::RecordLoadEvent(int window_id, | 228 void MetricsLogBase::RecordLoadEvent(int window_id, |
229 const GURL& url, | 229 const GURL& url, |
230 PageTransition::Type origin, | 230 content::PageTransition origin, |
231 int session_index, | 231 int session_index, |
232 TimeDelta load_time) { | 232 TimeDelta load_time) { |
233 DCHECK(!locked_); | 233 DCHECK(!locked_); |
234 | 234 |
235 OPEN_ELEMENT_FOR_SCOPE("document"); | 235 OPEN_ELEMENT_FOR_SCOPE("document"); |
236 WriteAttribute("action", "load"); | 236 WriteAttribute("action", "load"); |
237 WriteIntAttribute("docid", session_index); | 237 WriteIntAttribute("docid", session_index); |
238 WriteIntAttribute("window", window_id); | 238 WriteIntAttribute("window", window_id); |
239 WriteAttribute("loadtime", base::Int64ToString(load_time.InMilliseconds())); | 239 WriteAttribute("loadtime", base::Int64ToString(load_time.InMilliseconds())); |
240 | 240 |
241 std::string origin_string; | 241 std::string origin_string; |
242 | 242 |
243 switch (PageTransition::StripQualifier(origin)) { | 243 switch (content::PageTransitionStripQualifier(origin)) { |
244 // TODO(jhughes): Some of these mappings aren't right... we need to add | 244 // TODO(jhughes): Some of these mappings aren't right... we need to add |
245 // some values to the server's enum. | 245 // some values to the server's enum. |
246 case PageTransition::LINK: | 246 case content::PAGE_TRANSITION_LINK: |
247 case PageTransition::MANUAL_SUBFRAME: | 247 case content::PAGE_TRANSITION_MANUAL_SUBFRAME: |
248 origin_string = "link"; | 248 origin_string = "link"; |
249 break; | 249 break; |
250 | 250 |
251 case PageTransition::TYPED: | 251 case content::PAGE_TRANSITION_TYPED: |
252 origin_string = "typed"; | 252 origin_string = "typed"; |
253 break; | 253 break; |
254 | 254 |
255 case PageTransition::AUTO_BOOKMARK: | 255 case content::PAGE_TRANSITION_AUTO_BOOKMARK: |
256 origin_string = "bookmark"; | 256 origin_string = "bookmark"; |
257 break; | 257 break; |
258 | 258 |
259 case PageTransition::AUTO_SUBFRAME: | 259 case content::PAGE_TRANSITION_AUTO_SUBFRAME: |
260 case PageTransition::RELOAD: | 260 case content::PAGE_TRANSITION_RELOAD: |
261 origin_string = "refresh"; | 261 origin_string = "refresh"; |
262 break; | 262 break; |
263 | 263 |
264 case PageTransition::GENERATED: | 264 case content::PAGE_TRANSITION_GENERATED: |
265 case PageTransition::KEYWORD: | 265 case content::PAGE_TRANSITION_KEYWORD: |
266 origin_string = "global-history"; | 266 origin_string = "global-history"; |
267 break; | 267 break; |
268 | 268 |
269 case PageTransition::START_PAGE: | 269 case content::PAGE_TRANSITION_START_PAGE: |
270 origin_string = "start-page"; | 270 origin_string = "start-page"; |
271 break; | 271 break; |
272 | 272 |
273 case PageTransition::FORM_SUBMIT: | 273 case content::PAGE_TRANSITION_FORM_SUBMIT: |
274 origin_string = "form-submit"; | 274 origin_string = "form-submit"; |
275 break; | 275 break; |
276 | 276 |
277 default: | 277 default: |
278 NOTREACHED() << "Received an unknown page transition type: " << | 278 NOTREACHED() << "Received an unknown page transition type: " << |
279 PageTransition::StripQualifier(origin); | 279 content::PageTransitionStripQualifier(origin); |
280 } | 280 } |
281 if (!origin_string.empty()) | 281 if (!origin_string.empty()) |
282 WriteAttribute("origin", origin_string); | 282 WriteAttribute("origin", origin_string); |
283 | 283 |
284 WriteCommonEventAttributes(); | 284 WriteCommonEventAttributes(); |
285 | 285 |
286 ++num_events_; | 286 ++num_events_; |
287 } | 287 } |
288 | 288 |
289 void MetricsLogBase::RecordWindowEvent(WindowEventType type, | 289 void MetricsLogBase::RecordWindowEvent(WindowEventType type, |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 snapshot.Subtract(*already_logged); | 522 snapshot.Subtract(*already_logged); |
523 } | 523 } |
524 | 524 |
525 // Snapshot now contains only a delta to what we've already_logged. | 525 // Snapshot now contains only a delta to what we've already_logged. |
526 if (snapshot.redundant_count() > 0) { | 526 if (snapshot.redundant_count() > 0) { |
527 TransmitHistogramDelta(histogram, snapshot); | 527 TransmitHistogramDelta(histogram, snapshot); |
528 // Add new data into our running total. | 528 // Add new data into our running total. |
529 already_logged->Add(snapshot); | 529 already_logged->Add(snapshot); |
530 } | 530 } |
531 } | 531 } |
OLD | NEW |