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

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

Issue 2056153002: Convert PageLoadMetrics to Mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 5 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_METRICS_WEB_CONTENTS_OBSERVER_H_ 5 #ifndef COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_
6 #define COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_ 6 #define COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "components/page_load_metrics/browser/page_load_metrics_observer.h" 14 #include "components/page_load_metrics/browser/page_load_metrics_observer.h"
15 #include "components/page_load_metrics/common/page_load_metrics.mojom.h"
15 #include "components/page_load_metrics/common/page_load_timing.h" 16 #include "components/page_load_metrics/common/page_load_timing.h"
16 #include "content/public/browser/render_widget_host.h" 17 #include "content/public/browser/render_widget_host.h"
17 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
18 #include "content/public/browser/web_contents_observer.h" 19 #include "content/public/browser/web_contents_observer.h"
19 #include "content/public/browser/web_contents_user_data.h" 20 #include "content/public/browser/web_contents_user_data.h"
21 #include "mojo/public/cpp/bindings/binding.h"
20 #include "net/base/net_errors.h" 22 #include "net/base/net_errors.h"
21 #include "third_party/WebKit/public/web/WebInputEvent.h" 23 #include "third_party/WebKit/public/web/WebInputEvent.h"
22 24
23 namespace content { 25 namespace content {
24 class NavigationHandle; 26 class NavigationHandle;
25 class RenderFrameHost; 27 class RenderFrameHost;
26 } // namespace content 28 } // namespace content
27 29
28 namespace IPC { 30 namespace IPC {
29 class Message; 31 class Message;
30 } // namespace IPC 32 } // namespace IPC
31 33
32 namespace page_load_metrics { 34 namespace page_load_metrics {
33 35
36 class MetricsWebContentsObserver;
34 class PageLoadTracker; 37 class PageLoadTracker;
35 38
36 namespace internal { 39 namespace internal {
37 40
38 extern const char kErrorEvents[]; 41 extern const char kErrorEvents[];
39 extern const char kAbortChainSizeReload[]; 42 extern const char kAbortChainSizeReload[];
40 extern const char kAbortChainSizeForwardBack[]; 43 extern const char kAbortChainSizeForwardBack[];
41 extern const char kAbortChainSizeNewNavigation[]; 44 extern const char kAbortChainSizeNewNavigation[];
42 extern const char kAbortChainSizeNoCommit[]; 45 extern const char kAbortChainSizeNoCommit[];
43 extern const char kAbortChainSizeSameURL[]; 46 extern const char kAbortChainSizeSameURL[];
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 // Note that the returned metrics is owned by the web contents. 276 // Note that the returned metrics is owned by the web contents.
274 static MetricsWebContentsObserver* CreateForWebContents( 277 static MetricsWebContentsObserver* CreateForWebContents(
275 content::WebContents* web_contents, 278 content::WebContents* web_contents,
276 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface); 279 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface);
277 MetricsWebContentsObserver( 280 MetricsWebContentsObserver(
278 content::WebContents* web_contents, 281 content::WebContents* web_contents,
279 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface); 282 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface);
280 ~MetricsWebContentsObserver() override; 283 ~MetricsWebContentsObserver() override;
281 284
282 // content::WebContentsObserver implementation: 285 // content::WebContentsObserver implementation:
283 bool OnMessageReceived(const IPC::Message& message, 286 void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override;
284 content::RenderFrameHost* render_frame_host) override; 287 void RenderFrameHostChanged(content::RenderFrameHost* old_host,
288 content::RenderFrameHost* new_host) override;
289 void WebContentsDestroyed() override;
285 void DidStartNavigation( 290 void DidStartNavigation(
286 content::NavigationHandle* navigation_handle) override; 291 content::NavigationHandle* navigation_handle) override;
287 void DidFinishNavigation( 292 void DidFinishNavigation(
288 content::NavigationHandle* navigation_handle) override; 293 content::NavigationHandle* navigation_handle) override;
289 void DidRedirectNavigation( 294 void DidRedirectNavigation(
290 content::NavigationHandle* navigation_handle) override; 295 content::NavigationHandle* navigation_handle) override;
291 void NavigationStopped() override; 296 void NavigationStopped() override;
292 void OnInputEvent(const blink::WebInputEvent& event) override; 297 void OnInputEvent(const blink::WebInputEvent& event) override;
293 void WasShown() override; 298 void WasShown() override;
294 void WasHidden() override; 299 void WasHidden() override;
295 void RenderProcessGone(base::TerminationStatus status) override; 300 void RenderProcessGone(base::TerminationStatus status) override;
296 void RenderViewHostChanged(content::RenderViewHost* old_host, 301 void RenderViewHostChanged(content::RenderViewHost* old_host,
297 content::RenderViewHost* new_host) override; 302 content::RenderViewHost* new_host) override;
298 303
299 // This getter function is required for testing. 304 // This getter function is required for testing.
300 const PageLoadExtraInfo GetPageLoadExtraInfoForCommittedLoad(); 305 const PageLoadExtraInfo GetPageLoadExtraInfoForCommittedLoad();
301 306
307 // Exposed for testing.
308 void OnTimingUpdated(content::RenderFrameHost*,
309 const PageLoadTiming& timing,
310 const PageLoadMetadata& metadata);
311
302 private: 312 private:
303 friend class content::WebContentsUserData<MetricsWebContentsObserver>; 313 friend class content::WebContentsUserData<MetricsWebContentsObserver>;
314 friend class MetricsWebContentsObserverTest;
315
316 class PageLoadMetricsImpl;
304 317
305 void HandleFailedNavigationForTrackedLoad( 318 void HandleFailedNavigationForTrackedLoad(
306 content::NavigationHandle* navigation_handle, 319 content::NavigationHandle* navigation_handle,
307 std::unique_ptr<PageLoadTracker> tracker); 320 std::unique_ptr<PageLoadTracker> tracker);
308 321
309 void HandleCommittedNavigationForTrackedLoad( 322 void HandleCommittedNavigationForTrackedLoad(
310 content::NavigationHandle* navigation_handle, 323 content::NavigationHandle* navigation_handle,
311 std::unique_ptr<PageLoadTracker> tracker); 324 std::unique_ptr<PageLoadTracker> tracker);
312 325
313 // Notify all loads, provisional and committed, that we performed an action 326 // Notify all loads, provisional and committed, that we performed an action
314 // that might abort them. 327 // that might abort them.
315 void NotifyAbortAllLoads(UserAbortType abort_type); 328 void NotifyAbortAllLoads(UserAbortType abort_type);
316 void NotifyAbortAllLoadsWithTimestamp(UserAbortType abort_type, 329 void NotifyAbortAllLoadsWithTimestamp(UserAbortType abort_type,
317 base::TimeTicks timestamp, 330 base::TimeTicks timestamp,
318 bool is_certainly_browser_timestamp); 331 bool is_certainly_browser_timestamp);
319 332
320 // Register / Unregister input event callback to given RenderViewHost 333 // Register / Unregister input event callback to given RenderViewHost
321 void RegisterInputEventObserver(content::RenderViewHost* host); 334 void RegisterInputEventObserver(content::RenderViewHost* host);
322 void UnregisterInputEventObserver(content::RenderViewHost* host); 335 void UnregisterInputEventObserver(content::RenderViewHost* host);
323 336
324 // Notify aborted provisional loads that a new navigation occurred. This is 337 // Notify aborted provisional loads that a new navigation occurred. This is
325 // used for more consistent attribution tracking for aborted provisional 338 // used for more consistent attribution tracking for aborted provisional
326 // loads. This method returns the provisional load that was likely aborted 339 // loads. This method returns the provisional load that was likely aborted
327 // by this navigation, to help instantiate the new PageLoadTracker. 340 // by this navigation, to help instantiate the new PageLoadTracker.
328 std::unique_ptr<PageLoadTracker> NotifyAbortedProvisionalLoadsNewNavigation( 341 std::unique_ptr<PageLoadTracker> NotifyAbortedProvisionalLoadsNewNavigation(
329 content::NavigationHandle* new_navigation); 342 content::NavigationHandle* new_navigation);
330 343
331 void OnTimingUpdated(content::RenderFrameHost*, 344 // Register a PageLoadMetricsImpl factory, listening for connections to
332 const PageLoadTiming& timing, 345 // |host|.
333 const PageLoadMetadata& metadata); 346 void RegisterInterfaceImpl(content::RenderFrameHost* host);
334 347
335 bool ShouldTrackNavigation( 348 bool ShouldTrackNavigation(
336 content::NavigationHandle* navigation_handle) const; 349 content::NavigationHandle* navigation_handle) const;
337 350
338 // True if the web contents is currently in the foreground. 351 // True if the web contents is currently in the foreground.
339 bool in_foreground_; 352 bool in_foreground_;
340 353
341 // The PageLoadTrackers must be deleted before the |embedder_interface_|, 354 // The PageLoadTrackers must be deleted before the |embedder_interface_|,
342 // because they hold a pointer to the |embedder_interface_|. 355 // because they hold a pointer to the |embedder_interface_|.
343 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface_; 356 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface_;
(...skipping 10 matching lines...) Expand all
354 // navigation failed. This is because most provisional loads are destroyed 367 // navigation failed. This is because most provisional loads are destroyed
355 // and vanish before we get signal about what caused the abort (new 368 // and vanish before we get signal about what caused the abort (new
356 // navigation, stop button, etc.). 369 // navigation, stop button, etc.).
357 std::vector<std::unique_ptr<PageLoadTracker>> aborted_provisional_loads_; 370 std::vector<std::unique_ptr<PageLoadTracker>> aborted_provisional_loads_;
358 371
359 std::unique_ptr<PageLoadTracker> committed_load_; 372 std::unique_ptr<PageLoadTracker> committed_load_;
360 373
361 // Has the MWCO observed at least one navigation? 374 // Has the MWCO observed at least one navigation?
362 bool has_navigated_; 375 bool has_navigated_;
363 376
377 // Interface implementations we need to delete.
378 std::vector<std::unique_ptr<PageLoadMetricsImpl>> registered_interfaces_;
379
364 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); 380 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver);
365 }; 381 };
366 382
367 } // namespace page_load_metrics 383 } // namespace page_load_metrics
368 384
369 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_ 385 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_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