OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_RESOURCE_TRACKING_PAGE_LOAD_M ETRICS_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_RESOURCE_TRACKING_PAGE_LOAD_M ETRICS_OBSERVER_H_ |
6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_RESOURCE_TRACKING_PAGE_LOAD_M ETRICS_OBSERVER_H_ | 6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_RESOURCE_TRACKING_PAGE_LOAD_M ETRICS_OBSERVER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "chrome/browser/page_load_metrics/page_load_metrics_observer.h" | 10 #include "chrome/browser/page_load_metrics/page_load_metrics_observer.h" |
11 #include "content/public/common/resource_type.h" | |
12 | |
13 namespace offline_pages { | |
14 class ResourceTrackerObserver; | |
15 } | |
11 | 16 |
12 namespace page_load_metrics { | 17 namespace page_load_metrics { |
13 | 18 |
14 class ResourceTrackingPageLoadMetricsObserver | 19 class ResourceTrackingPageLoadMetricsObserver |
15 : public page_load_metrics::PageLoadMetricsObserver { | 20 : public page_load_metrics::PageLoadMetricsObserver { |
16 public: | 21 public: |
17 ResourceTrackingPageLoadMetricsObserver(); | 22 ResourceTrackingPageLoadMetricsObserver( |
23 offline_pages::ResourceTrackerObserver* request_coordinator); | |
18 ~ResourceTrackingPageLoadMetricsObserver() override; | 24 ~ResourceTrackingPageLoadMetricsObserver() override; |
19 | 25 |
20 // Called by the PageLoadMetrics framework when we start a new request, so we | 26 // Called by the PageLoadMetrics framework when we start a new request, so we |
21 // can update our data structures to be able to calculate a resource done | 27 // can update our data structures to be able to calculate a resource done |
22 // percentage. | 28 // percentage. |
23 void OnStartedResource( | 29 void OnStartedResource( |
24 const ExtraRequestStartInfo& extra_request_start_info) override; | 30 const ExtraRequestStartInfo& extra_request_start_info) override; |
25 | 31 |
26 // Called by the PageLoadMetrics framework when we start a new request, so we | 32 // Called by the PageLoadMetrics framework when we start a new request, so we |
27 // can update our data structures to be able to calculate a resource done | 33 // can update our data structures to be able to calculate a resource done |
28 // percentage. | 34 // percentage. |
29 void OnLoadedResource( | 35 void OnLoadedResource( |
30 const ExtraRequestCompleteInfo& extra_request_complete_info) override; | 36 const ExtraRequestCompleteInfo& extra_request_complete_info) override; |
31 | 37 |
32 // For the specified type, get the count of requests started and completed. | 38 // For the specified type, get the count of requests started and |
39 // completed. | |
33 // TODO(petewil) Note that type is not used yet, code to use it is coming | 40 // TODO(petewil) Note that type is not used yet, code to use it is coming |
34 // soon. | 41 // soon. |
35 void GetCountsForTypeForTesting(const content::ResourceType type, | 42 void GetCountsForTypeForTesting(const content::ResourceType type, |
RyanSturm
2017/05/10 18:30:13
How are you planning on using this? I am a fan of
Pete Williamson
2017/05/10 19:00:52
This is only used from the unit test. I removed i
| |
36 int64_t* started_count, | 43 int64_t* started_count, |
37 int64_t* completed_count); | 44 int64_t* completed_count); |
38 | 45 |
39 private: | 46 private: |
47 void InformObservers(const content::ResourceType type, | |
48 int64_t started_count, | |
49 int64_t completed_count); | |
50 | |
40 // TODO(petewil): Some way to keep track of what we've seen | 51 // TODO(petewil): Some way to keep track of what we've seen |
41 // TODO(petewil): Some way to inform our keeper of aggregate results when they | 52 // TODO(petewil): Some way to inform our keeper of aggregate results when they |
42 // change. | 53 // change. |
43 int64_t started_count_; | 54 int64_t started_count_; |
44 int64_t completed_count_; | 55 int64_t completed_count_; |
56 // Unowned pointer to the request_coordinator_, it will be valid for the | |
RyanSturm
2017/05/10 18:30:13
nit: s/the request_coordinator_/the current profil
Pete Williamson
2017/05/10 19:00:52
Done.
| |
57 // lifetime of the PageLoadMetricsObserver. | |
58 offline_pages::ResourceTrackerObserver* request_coordinator_; | |
45 }; | 59 }; |
46 | 60 |
47 } // namespace page_load_metrics | 61 } // namespace page_load_metrics |
48 | 62 |
49 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_RESOURCE_TRACKING_PAGE_LOA D_METRICS_OBSERVER_H_ | 63 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_RESOURCE_TRACKING_PAGE_LOA D_METRICS_OBSERVER_H_ |
OLD | NEW |