Commit 81be6ff2 authored by Hui Shu's avatar Hui Shu
Browse files

Crash intentionally when requestTiles with invalid key.

This should not happen and BrowserViewRenderer/GlobalTileManager would
be in an invalid state when it happens.
Remove this CHECK before we ship L.

BUG: 17369933

Change-Id: I288b67ac9a8bd018aed207decabb37de41889a73
parent e219a730
......@@ -197,7 +197,12 @@ void BrowserViewRenderer::RequestMemoryPolicy(
GlobalTileManager* manager = GlobalTileManager::GetInstance();
// The following line will call BrowserViewRenderer::SetTilesNum().
manager->RequestTiles(new_policy.num_resources_limit, tile_manager_key_);
bool success =
manager->RequestTiles(new_policy.num_resources_limit, tile_manager_key_);
CHECK(success) << "tile_manager_key_ is invalid."
<< "\n Current memory policy: bytes_limit " << memory_policy_.bytes_limit
<< " num_resources_limit " << memory_policy_.num_resources_limit
<< "\n hardware enabled " << hardware_enabled_;
}
void BrowserViewRenderer::SetNumTiles(size_t num_tiles,
......
......@@ -64,9 +64,12 @@ void GlobalTileManager::SetTileLimit(size_t num_tiles_limit) {
num_tiles_limit_ = num_tiles_limit;
}
void GlobalTileManager::RequestTiles(size_t new_num_of_tiles, Key key) {
bool GlobalTileManager::RequestTiles(size_t new_num_of_tiles, Key key) {
DCHECK(IsConsistent());
DCHECK(sequence_checker_.CalledOnValidSequencedThread());
if (std::find(mru_list_.begin(), mru_list_.end(), *key) == mru_list_.end()) {
return false;
}
size_t old_num_of_tiles = (*key)->GetNumTiles();
size_t num_of_active_views = std::distance(mru_list_.begin(), key) + 1;
size_t tiles_per_view_limit;
......@@ -81,7 +84,7 @@ void GlobalTileManager::RequestTiles(size_t new_num_of_tiles, Key key) {
if (new_total_allocated_tiles <= num_tiles_limit_) {
total_allocated_tiles_ = new_total_allocated_tiles;
(*key)->SetNumTiles(new_num_of_tiles, false);
return;
return true;
}
// Does not have enough tiles. Now evict other clients' tiles.
......@@ -93,11 +96,11 @@ void GlobalTileManager::RequestTiles(size_t new_num_of_tiles, Key key) {
new_total_allocated_tiles -= evicted_tiles;
total_allocated_tiles_ = new_total_allocated_tiles;
(*key)->SetNumTiles(new_num_of_tiles, false);
return;
return true;
} else {
total_allocated_tiles_ = num_tiles_limit_;
(*key)->SetNumTiles(tiles_left + old_num_of_tiles + evicted_tiles, false);
return;
return true;
}
}
......
......@@ -36,7 +36,8 @@ class GlobalTileManager {
// tiles are available for the client. If the number of tiles left is not
// enough to satisfy the request, the manager will evict tiles allocated to
// other clients.
void RequestTiles(size_t new_num_of_tiles, Key key);
// Returns false if the key cannot be found in |mru_list_|.
bool RequestTiles(size_t new_num_of_tiles, Key key);
Key PushBack(GlobalTileManagerClient* client);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment