forked from ks32/chromium-crosswalk
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GRC] Decouple PageSignalReceiver from TabManager.
Previously PageSignalReceiver depends on TabManager because it calls directly to TabManager::WebContentsData and TabManager::TabStatsCollector. TabManager also depends on PageSignalReceiver directly or indirectly. To make PageSignalReceiver decoupled from TabManger, we need to introduce a layering that PageSignalReceiver calls into but not part of TabManager. Thus, this patch: 1. Decoupled PageSignalReceiver from TabManager by adding PageSignalObserver API; 2. Add [Add|Remove]Observer APIs in PageSignalReceiver; 3. Implemented a TabManager::ResourceCoordinatorSignalObserver which implements PageSignalObserver APIs. BUG=775691 Change-Id: I8c111ed36bbdb39c69d3568e5f7396dcd01c4ad7 Reviewed-on: https://chromium-review.googlesource.com/752506 Commit-Queue: lpy <[email protected]> Reviewed-by: Zhen Wang <[email protected]> Cr-Commit-Position: refs/heads/master@{#514308}
- Loading branch information
Showing
9 changed files
with
161 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
chrome/browser/resource_coordinator/tab_manager_resource_coordinator_signal_observer.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// 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. | ||
|
||
#include "chrome/browser/resource_coordinator/tab_manager_resource_coordinator_signal_observer.h" | ||
|
||
#include "base/time/time.h" | ||
#include "chrome/browser/browser_process.h" | ||
#include "chrome/browser/resource_coordinator/tab_manager_stats_collector.h" | ||
#include "chrome/browser/resource_coordinator/tab_manager_web_contents_data.h" | ||
|
||
namespace resource_coordinator { | ||
|
||
TabManager::ResourceCoordinatorSignalObserver:: | ||
ResourceCoordinatorSignalObserver() { | ||
if (auto* page_signal_receiver = PageSignalReceiver::GetInstance()) | ||
page_signal_receiver->AddObserver(this); | ||
} | ||
|
||
TabManager::ResourceCoordinatorSignalObserver:: | ||
~ResourceCoordinatorSignalObserver() { | ||
if (auto* page_signal_receiver = PageSignalReceiver::GetInstance()) | ||
page_signal_receiver->RemoveObserver(this); | ||
} | ||
|
||
void TabManager::ResourceCoordinatorSignalObserver::NotifyPageAlmostIdle( | ||
content::WebContents* web_contents) { | ||
auto* web_contents_data = | ||
TabManager::WebContentsData::FromWebContents(web_contents); | ||
web_contents_data->NotifyAlmostIdle(); | ||
} | ||
|
||
void TabManager::ResourceCoordinatorSignalObserver:: | ||
OnExpectedTaskQueueingDurationSet(content::WebContents* web_contents, | ||
base::TimeDelta duration) { | ||
g_browser_process->GetTabManager() | ||
->stats_collector() | ||
->RecordExpectedTaskQueueingDuration(web_contents, duration); | ||
} | ||
|
||
} // namespace resource_coordinator |
35 changes: 35 additions & 0 deletions
35
chrome/browser/resource_coordinator/tab_manager_resource_coordinator_signal_observer.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// 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_RESOURCE_COORDINATOR_TAB_MANAGER_RESOURCE_COORDINATOR_SIGNAL_OBSERVER_H_ | ||
#define CHROME_BROWSER_RESOURCE_COORDINATOR_TAB_MANAGER_RESOURCE_COORDINATOR_SIGNAL_OBSERVER_H_ | ||
|
||
#include "base/macros.h" | ||
#include "chrome/browser/resource_coordinator/page_signal_receiver.h" | ||
#include "chrome/browser/resource_coordinator/tab_manager.h" | ||
|
||
namespace resource_coordinator { | ||
|
||
// TabManager::ResourceCoordinatorSignalObserver implements some observer | ||
// interfaces, for example it currently implements PageSignalObserver but can | ||
// implement more; and receives signals from resource coordinator through those | ||
// interfaces. | ||
class TabManager::ResourceCoordinatorSignalObserver | ||
: public PageSignalObserver { | ||
public: | ||
ResourceCoordinatorSignalObserver(); | ||
~ResourceCoordinatorSignalObserver() override; | ||
|
||
// PageSignalObserver implementation. | ||
void NotifyPageAlmostIdle(content::WebContents* web_contents) override; | ||
void OnExpectedTaskQueueingDurationSet(content::WebContents* web_contents, | ||
base::TimeDelta duration) override; | ||
|
||
private: | ||
DISALLOW_COPY_AND_ASSIGN(ResourceCoordinatorSignalObserver); | ||
}; | ||
|
||
} // namespace resource_coordinator | ||
|
||
#endif // CHROME_BROWSER_RESOURCE_COORDINATOR_TAB_MANAGER_RESOURCE_COORDINATOR_SIGNAL_OBSERVER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters