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

Side by Side Diff: components/page_load_metrics/browser/metrics_web_contents_observer.h

Issue 1377223002: Add page load abort metrics to PageLoadMetrics system (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@plm_backgrounded_master
Patch Set: remove TODO Created 5 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
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 #ifndef COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_OBSE RVER_H_ 5 #ifndef COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_OBSE RVER_H_
6 #define COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_OBSE RVER_H_ 6 #define COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_OBSE RVER_H_
7 7
8 #include "base/containers/scoped_ptr_map.h" 8 #include "base/containers/scoped_ptr_map.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "components/page_load_metrics/common/page_load_timing.h" 11 #include "components/page_load_metrics/common/page_load_timing.h"
12 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
13 #include "content/public/browser/web_contents_observer.h" 13 #include "content/public/browser/web_contents_observer.h"
14 #include "content/public/browser/web_contents_user_data.h" 14 #include "content/public/browser/web_contents_user_data.h"
15 #include "net/base/net_errors.h"
15 16
16 namespace content { 17 namespace content {
17 class NavigationHandle; 18 class NavigationHandle;
18 class RenderFrameHost; 19 class RenderFrameHost;
19 } // namespace content 20 } // namespace content
20 21
21 namespace IPC { 22 namespace IPC {
22 class Message; 23 class Message;
23 } // namespace IPC 24 } // namespace IPC
24 25
25 namespace page_load_metrics { 26 namespace page_load_metrics {
26 27
28 // If you add elements from this enum, make sure you update the enum
29 // value in histograms.xml. Only add elements to the end to prevent
30 // inconsistencies between versions.
31 enum PageLoadEvent {
32 PAGE_LOAD_STARTED,
33
34 // A provisional load is a load before it commits, i.e. before it receives the
35 // first bytes of the response body or knows the encoding of the response
36 // body. A load failed before it was committed for any reason, e.g. from a
37 // user abort or a network timeout.
38 PAGE_LOAD_FAILED_BEFORE_COMMIT,
39
40 // A subset of PAGE_LOAD_FAILED_BEFORE_COMMIT, this counts the
41 // specific failures due to user aborts.
42 PAGE_LOAD_ABORTED_BEFORE_COMMIT,
43
44 // When a load is aborted anytime before the page's first layout, we increase
45 // these counts. This includes all failed provisional loads.
46 PAGE_LOAD_ABORTED_BEFORE_FIRST_LAYOUT,
47
48 // We increase this count if a page load successfully has a layout.
49 // Differentiate between loads that were backgrounded before first layout.
50 // Note that a load that is backgrounded, then foregrounded before first
51 // layout will still end up in the backgrounded bucket.
52 PAGE_LOAD_SUCCESSFUL_FIRST_LAYOUT_FOREGROUND,
53 PAGE_LOAD_SUCCESSFUL_FIRST_LAYOUT_BACKGROUND,
54
55 // Add values before this final count.
56 PAGE_LOAD_LAST_ENTRY
57 };
58
27 class PageLoadTracker { 59 class PageLoadTracker {
28 public: 60 public:
29 explicit PageLoadTracker(bool in_foreground); 61 explicit PageLoadTracker(bool in_foreground);
30 ~PageLoadTracker(); 62 ~PageLoadTracker();
31 void Commit(); 63 void Commit();
32 void WebContentsHidden(); 64 void WebContentsHidden();
33 65
34 // Returns true if the timing was successfully updated. 66 // Returns true if the timing was successfully updated.
35 bool UpdateTiming(const PageLoadTiming& timing); 67 bool UpdateTiming(const PageLoadTiming& timing);
68 void RecordEvent(PageLoadEvent event);
36 69
37 private: 70 private:
38 void RecordTimingHistograms(); 71 void RecordTimingHistograms();
39 72
40 bool has_commit_; 73 bool has_commit_;
41 74
42 // We record separate metrics for events that occur after a background, 75 // We record separate metrics for events that occur after a background,
43 // because metrics like layout/paint are delayed artificially 76 // because metrics like layout/paint are delayed artificially
44 // when they occur in the bacground. 77 // when they occur in the bacground.
45 base::TimeTicks background_time_; 78 base::TimeTicks background_time_;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 base::ScopedPtrMap<content::NavigationHandle*, scoped_ptr<PageLoadTracker>> 123 base::ScopedPtrMap<content::NavigationHandle*, scoped_ptr<PageLoadTracker>>
91 provisional_loads_; 124 provisional_loads_;
92 scoped_ptr<PageLoadTracker> committed_load_; 125 scoped_ptr<PageLoadTracker> committed_load_;
93 126
94 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); 127 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver);
95 }; 128 };
96 129
97 } // namespace page_load_metrics 130 } // namespace page_load_metrics
98 131
99 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_O BSERVER_H_ 132 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_O BSERVER_H_
OLDNEW
« no previous file with comments | « components/page_load_metrics/browser/DEPS ('k') | components/page_load_metrics/browser/metrics_web_contents_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698