OLD | NEW |
---|---|
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 enum PageLoadEvent { | |
29 STARTED_PROVISIONAL_LOAD, | |
Randy Smith (Not in Mondays)
2015/10/01 16:07:39
I'd like to have comments on these values that exp
Charlie Harrison
2015/10/01 16:59:55
Will do, good suggestions.
| |
30 ABORTED_PROVISIONAL_LOAD, | |
31 ABORTED_LOAD_BEFORE_FIRST_LAYOUT, | |
32 SUCCESSFUL_FIRST_LAYOUT, | |
33 | |
34 // Add values before this final count. | |
35 EVENT_COUNT | |
Randy Smith (Not in Mondays)
2015/10/01 16:07:39
I *think* that the custom for these is the enum na
| |
36 }; | |
37 | |
27 class PageLoadTracker { | 38 class PageLoadTracker { |
28 public: | 39 public: |
29 explicit PageLoadTracker(bool in_foreground); | 40 explicit PageLoadTracker(bool in_foreground); |
30 ~PageLoadTracker(); | 41 ~PageLoadTracker(); |
31 void Commit(); | 42 void Commit(); |
32 void WebContentsHidden(); | 43 void WebContentsHidden(); |
33 | 44 |
34 // Returns true if the timing was successfully updated. | 45 // Returns true if the timing was successfully updated. |
35 bool UpdateTiming(const PageLoadTiming& timing); | 46 bool UpdateTiming(const PageLoadTiming& timing); |
47 void RecordEvent(PageLoadEvent event); | |
36 | 48 |
37 private: | 49 private: |
38 void RecordTimingHistograms(); | 50 void RecordTimingHistograms(); |
39 | 51 |
40 bool has_commit_; | 52 bool has_commit_; |
41 | 53 |
42 // We record separate metrics for events that occur after a background, | 54 // We record separate metrics for events that occur after a background, |
43 // because metrics like layout/paint are delayed artificially | 55 // because metrics like layout/paint are delayed artificially |
44 // when they occur in the bacground. | 56 // when they occur in the bacground. |
45 base::TimeTicks background_time_; | 57 base::TimeTicks background_time_; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 base::ScopedPtrMap<content::NavigationHandle*, scoped_ptr<PageLoadTracker>> | 102 base::ScopedPtrMap<content::NavigationHandle*, scoped_ptr<PageLoadTracker>> |
91 provisional_loads_; | 103 provisional_loads_; |
92 scoped_ptr<PageLoadTracker> committed_load_; | 104 scoped_ptr<PageLoadTracker> committed_load_; |
93 | 105 |
94 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); | 106 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); |
95 }; | 107 }; |
96 | 108 |
97 } // namespace page_load_metrics | 109 } // namespace page_load_metrics |
98 | 110 |
99 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_O BSERVER_H_ | 111 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_O BSERVER_H_ |
OLD | NEW |