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

Side by Side Diff: chrome/browser/page_load_metrics/metrics_web_contents_observer.cc

Issue 2403113004: Add new background abort type. (Closed)
Patch Set: fix tests Created 4 years, 2 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
« no previous file with comments | « no previous file | chrome/browser/page_load_metrics/observers/aborts_page_load_metrics_observer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/browser/page_load_metrics/metrics_web_contents_observer.h" 5 #include "chrome/browser/page_load_metrics/metrics_web_contents_observer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <ostream> 8 #include <ostream>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 416
417 void PageLoadTracker::WebContentsHidden() { 417 void PageLoadTracker::WebContentsHidden() {
418 // Only log the first time we background in a given page load. 418 // Only log the first time we background in a given page load.
419 if (background_time_.is_null()) { 419 if (background_time_.is_null()) {
420 // Make sure we either started in the foreground and haven't been 420 // Make sure we either started in the foreground and haven't been
421 // foregrounded yet, or started in the background and have already been 421 // foregrounded yet, or started in the background and have already been
422 // foregrounded. 422 // foregrounded.
423 DCHECK_EQ(started_in_foreground_, foreground_time_.is_null()); 423 DCHECK_EQ(started_in_foreground_, foreground_time_.is_null());
424 background_time_ = base::TimeTicks::Now(); 424 background_time_ = base::TimeTicks::Now();
425 ClampBrowserTimestampIfInterProcessTimeTickSkew(&background_time_); 425 ClampBrowserTimestampIfInterProcessTimeTickSkew(&background_time_);
426 // Though most cases where a tab is backgrounded are user initiated, we
427 // can't be certain that we were backgrounded due to a user action. For
428 // example, on Android, the screen times out after a period of inactivity,
429 // resulting in a non-user-initiated backgrounding.
430 const bool abort_is_user_initiated = false;
431 NotifyAbort(ABORT_BACKGROUND, abort_is_user_initiated, background_time_,
432 true);
426 } 433 }
427 434
428 for (const auto& observer : observers_) 435 for (const auto& observer : observers_)
429 observer->OnHidden(); 436 observer->OnHidden();
430 } 437 }
431 438
432 void PageLoadTracker::WebContentsShown() { 439 void PageLoadTracker::WebContentsShown() {
433 // Only log the first time we foreground in a given page load. 440 // Only log the first time we foreground in a given page load.
434 if (foreground_time_.is_null()) { 441 if (foreground_time_.is_null()) {
435 // Make sure we either started in the background and haven't been 442 // Make sure we either started in the background and haven't been
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
1098 content::NavigationHandle* navigation_handle) const { 1105 content::NavigationHandle* navigation_handle) const {
1099 DCHECK(navigation_handle->IsInMainFrame()); 1106 DCHECK(navigation_handle->IsInMainFrame());
1100 DCHECK(!navigation_handle->HasCommitted() || 1107 DCHECK(!navigation_handle->HasCommitted() ||
1101 !navigation_handle->IsSamePage()); 1108 !navigation_handle->IsSamePage());
1102 1109
1103 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(), 1110 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(),
1104 navigation_handle).ShouldTrack(); 1111 navigation_handle).ShouldTrack();
1105 } 1112 }
1106 1113
1107 } // namespace page_load_metrics 1114 } // namespace page_load_metrics
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/page_load_metrics/observers/aborts_page_load_metrics_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698