| Index: chrome/browser/page_load_metrics/observers/ads_page_load_metrics_observer.h
|
| diff --git a/chrome/browser/page_load_metrics/observers/ads_page_load_metrics_observer.h b/chrome/browser/page_load_metrics/observers/ads_page_load_metrics_observer.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..43be807323fc3cdd01cb115b5ae19c518cd9ae5d
|
| --- /dev/null
|
| +++ b/chrome/browser/page_load_metrics/observers/ads_page_load_metrics_observer.h
|
| @@ -0,0 +1,74 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_ADS_PAGE_LOAD_METRICS_OBSERVER_H_
|
| +#define CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_ADS_PAGE_LOAD_METRICS_OBSERVER_H_
|
| +
|
| +#include <list>
|
| +#include <unordered_map>
|
| +
|
| +#include "base/macros.h"
|
| +#include "chrome/browser/page_load_metrics/page_load_metrics_observer.h"
|
| +#include "net/http/http_response_info.h"
|
| +
|
| +class AdsPageLoadMetricsObserver
|
| + : public page_load_metrics::PageLoadMetricsObserver {
|
| + public:
|
| + AdsPageLoadMetricsObserver();
|
| + ~AdsPageLoadMetricsObserver() override;
|
| +
|
| + // page_load_metrics::PageLoadMetricsObserver:s
|
| + ObservePolicy OnCommit(content::NavigationHandle* navigation_handle) override;
|
| + ObservePolicy OnCommitSubFrame(
|
| + content::NavigationHandle* navigation_handle) override;
|
| + ObservePolicy FlushMetricsOnAppEnterBackground(
|
| + const page_load_metrics::PageLoadTiming& timing,
|
| + const page_load_metrics::PageLoadExtraInfo& extra_info) override;
|
| + void OnLoadedResource(
|
| + const page_load_metrics::ExtraRequestInfo& extra_request_info) override;
|
| + void OnComplete(const page_load_metrics::PageLoadTiming& timing,
|
| + const page_load_metrics::PageLoadExtraInfo& info) override;
|
| +
|
| + private:
|
| + struct AdFrameData {
|
| + size_t frame_bytes;
|
| + size_t frame_bytes_uncached;
|
| + };
|
| +
|
| + using FrameTreeNodeId = int;
|
| +
|
| + void RecordHistograms();
|
| +
|
| + // Checks to see if a resource is waiting for |frame_tree_node_id| to commit
|
| + // before it can be processed. If so, call OnLoadedResource for the delayed
|
| + // resource.
|
| + void ProcessDelayedResources(FrameTreeNodeId frame_tree_node_id);
|
| +
|
| + // Stores the size data of each ad frame. Pointed to by ad_frames_ so use a
|
| + // data structure that won't move the data around.
|
| + std::list<AdFrameData> ad_frames_data_storage_;
|
| +
|
| + // Maps a frame (by id) to the AdFrameData responsible for the frame. The
|
| + // responsible frame is the top-most frame labeled as an ad in the frame's
|
| + // ancestry, which may be itself. If no responsible frame is found, the data
|
| + // is nullptr.
|
| + std::unordered_map<FrameTreeNodeId, AdFrameData*> ad_frames_data_;
|
| +
|
| + // When the observer receives report of a document resource loading for a
|
| + // sub-frame before the sub-frame commit occurs, hold onto the resource
|
| + // request info (delay it) until the sub-frame commits.
|
| + std::unordered_map<FrameTreeNodeId, page_load_metrics::ExtraRequestInfo>
|
| + delayed_resources_;
|
| +
|
| + size_t page_bytes_ = 0;
|
| + size_t uncached_page_bytes_ = 0;
|
| + int top_level_frame_count_ = 0;
|
| + int top_level_ad_frame_count_ = 0;
|
| +
|
| + bool enabled_ = true;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(AdsPageLoadMetricsObserver);
|
| +};
|
| +
|
| +#endif // CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_ADS_PAGE_LOAD_METRICS_OBSERVER_H_
|
|
|