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

Side by Side Diff: chrome/browser/resource_coordinator/resource_coordinator_web_contents_observer.cc

Issue 2710823003: NOCOMMIT prototype: GRC service plumbing and process priority
Patch Set: Rebase Created 3 years, 6 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 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 #include "chrome/browser/resource_coordinator/resource_coordinator_web_contents_ observer.h" 5 #include "chrome/browser/resource_coordinator/resource_coordinator_web_contents_ observer.h"
6 6
7 #include "content/public/browser/navigation_handle.h"
8 #include "content/public/browser/render_frame_host.h"
9 #include "content/public/browser/render_process_host.h"
7 #include "content/public/common/service_manager_connection.h" 10 #include "content/public/common/service_manager_connection.h"
8 #include "services/resource_coordinator/public/cpp/resource_coordinator_features .h" 11 #include "services/resource_coordinator/public/cpp/resource_coordinator_features .h"
9 12
10 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ResourceCoordinatorWebContentsObserver); 13 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ResourceCoordinatorWebContentsObserver);
11 14
12 ResourceCoordinatorWebContentsObserver::ResourceCoordinatorWebContentsObserver( 15 ResourceCoordinatorWebContentsObserver::ResourceCoordinatorWebContentsObserver(
13 content::WebContents* web_contents) 16 content::WebContents* web_contents)
14 : WebContentsObserver(web_contents) { 17 : WebContentsObserver(web_contents) {
15 tab_resource_coordinator_ = 18 tab_resource_coordinator_ =
16 base::MakeUnique<resource_coordinator::ResourceCoordinatorInterface>( 19 base::MakeUnique<resource_coordinator::ResourceCoordinatorInterface>(
(...skipping 11 matching lines...) Expand all
28 31
29 void ResourceCoordinatorWebContentsObserver::WasShown() { 32 void ResourceCoordinatorWebContentsObserver::WasShown() {
30 tab_resource_coordinator_->SendEvent( 33 tab_resource_coordinator_->SendEvent(
31 resource_coordinator::EventType::kOnWebContentsShown); 34 resource_coordinator::EventType::kOnWebContentsShown);
32 } 35 }
33 36
34 void ResourceCoordinatorWebContentsObserver::WasHidden() { 37 void ResourceCoordinatorWebContentsObserver::WasHidden() {
35 tab_resource_coordinator_->SendEvent( 38 tab_resource_coordinator_->SendEvent(
36 resource_coordinator::EventType::kOnWebContentsHidden); 39 resource_coordinator::EventType::kOnWebContentsHidden);
37 } 40 }
41
42 void ResourceCoordinatorWebContentsObserver::ReadyToCommitNavigation(
43 content::NavigationHandle* navigation_handle) {
44 auto* frame_resource_coordinator =
45 navigation_handle->GetRenderFrameHost()->GetFrameResourceCoordinator();
46 tab_resource_coordinator_->AddChild(*frame_resource_coordinator);
47 frame_resource_coordinator->SendEvent(
48 resource_coordinator::EventType::kOnNavigationCommit);
49 }
50
51 void ResourceCoordinatorWebContentsObserver::DidFinishNavigation(
52 content::NavigationHandle* navigation_handle) {
53 content::RenderFrameHost* render_frame =
54 navigation_handle->GetRenderFrameHost();
55 auto* frame_resource_coordinator =
56 render_frame->GetFrameResourceCoordinator();
57 auto* process_resource_coordinator =
58 render_frame->GetProcess()->GetProcessResourceCoordinator();
59
60 process_resource_coordinator->AddChild(*frame_resource_coordinator);
61 tab_resource_coordinator_->AddChild(*process_resource_coordinator);
62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698