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

Side by Side Diff: android_webview/browser/browser_view_renderer.cc

Issue 545663002: Cleanups in GlobalTileManager and BrowserViewRenderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: just cleanups Created 6 years, 3 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
« no previous file with comments | « no previous file | android_webview/browser/global_tile_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "android_webview/browser/browser_view_renderer.h" 5 #include "android_webview/browser/browser_view_renderer.h"
6 6
7 #include "android_webview/browser/browser_view_renderer_client.h" 7 #include "android_webview/browser/browser_view_renderer_client.h"
8 #include "android_webview/browser/shared_renderer_state.h" 8 #include "android_webview/browser/shared_renderer_state.h"
9 #include "android_webview/common/aw_switches.h" 9 #include "android_webview/common/aw_switches.h"
10 #include "android_webview/public/browser/draw_gl.h" 10 #include "android_webview/public/browser/draw_gl.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // Currently the logic in this class relies on |compositor_| remaining 144 // Currently the logic in this class relies on |compositor_| remaining
145 // NULL until the DidInitializeCompositor() call, hence it is not set here. 145 // NULL until the DidInitializeCompositor() call, hence it is not set here.
146 } 146 }
147 147
148 BrowserViewRenderer::~BrowserViewRenderer() { 148 BrowserViewRenderer::~BrowserViewRenderer() {
149 content::SynchronousCompositor::SetClientForWebContents(web_contents_, NULL); 149 content::SynchronousCompositor::SetClientForWebContents(web_contents_, NULL);
150 // OnDetachedFromWindow should be called before the destructor, so the memory 150 // OnDetachedFromWindow should be called before the destructor, so the memory
151 // policy should have already been updated. 151 // policy should have already been updated.
152 } 152 }
153 153
154 // This function updates the cached memory policy in shared renderer state, as 154 // This function updates the resource allocation in GlobalTileManager.
155 // well as the tile resource allocation in GlobalTileManager.
156 void BrowserViewRenderer::TrimMemory(const int level, const bool visible) { 155 void BrowserViewRenderer::TrimMemory(const int level, const bool visible) {
157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 156 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
158 // Constants from Android ComponentCallbacks2. 157 // Constants from Android ComponentCallbacks2.
159 enum { 158 enum {
160 TRIM_MEMORY_RUNNING_LOW = 10, 159 TRIM_MEMORY_RUNNING_LOW = 10,
161 TRIM_MEMORY_UI_HIDDEN = 20, 160 TRIM_MEMORY_UI_HIDDEN = 20,
162 TRIM_MEMORY_BACKGROUND = 40, 161 TRIM_MEMORY_BACKGROUND = 40,
163 }; 162 };
164 163
165 // Not urgent enough. TRIM_MEMORY_UI_HIDDEN is treated specially because 164 // Not urgent enough. TRIM_MEMORY_UI_HIDDEN is treated specially because
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 num_bytes_ = new_policy.bytes_limit; 212 num_bytes_ = new_policy.bytes_limit;
214 213
215 GlobalTileManager* manager = GlobalTileManager::GetInstance(); 214 GlobalTileManager* manager = GlobalTileManager::GetInstance();
216 215
217 // The following line will call BrowserViewRenderer::SetTilesNum(). 216 // The following line will call BrowserViewRenderer::SetTilesNum().
218 manager->RequestTiles(new_policy.num_resources_limit, tile_manager_key_); 217 manager->RequestTiles(new_policy.num_resources_limit, tile_manager_key_);
219 } 218 }
220 219
221 void BrowserViewRenderer::SetNumTiles(size_t num_tiles, 220 void BrowserViewRenderer::SetNumTiles(size_t num_tiles,
222 bool effective_immediately) { 221 bool effective_immediately) {
223 if (num_tiles == num_tiles_)
224 return;
225 num_tiles_ = num_tiles; 222 num_tiles_ = num_tiles;
226 223
227 memory_policy_.num_resources_limit = num_tiles_; 224 memory_policy_.num_resources_limit = num_tiles_;
228 memory_policy_.bytes_limit = num_bytes_; 225 memory_policy_.bytes_limit = num_bytes_;
229 226
230 if (effective_immediately) 227 if (effective_immediately)
231 EnforceMemoryPolicyImmediately(memory_policy_); 228 EnforceMemoryPolicyImmediately(memory_policy_);
232 } 229 }
233 230
234 void BrowserViewRenderer::EnforceMemoryPolicyImmediately( 231 void BrowserViewRenderer::EnforceMemoryPolicyImmediately(
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 base::StringAppendF(&str, 812 base::StringAppendF(&str,
816 "surface width height: [%d %d] ", 813 "surface width height: [%d %d] ",
817 draw_info->width, 814 draw_info->width,
818 draw_info->height); 815 draw_info->height);
819 base::StringAppendF(&str, "is_layer: %d ", draw_info->is_layer); 816 base::StringAppendF(&str, "is_layer: %d ", draw_info->is_layer);
820 } 817 }
821 return str; 818 return str;
822 } 819 }
823 820
824 } // namespace android_webview 821 } // namespace android_webview
OLDNEW
« no previous file with comments | « no previous file | android_webview/browser/global_tile_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698