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

Side by Side Diff: android_webview/browser/global_tile_manager.h

Issue 226363004: Global GPU memory manager for android webview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unnecessary code Created 6 years, 7 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef ANDROID_WEBVIEW_BROWSER_GLOBAL_TILE_MANAGER_H_
6 #define ANDROID_WEBVIEW_BROWSER_GLOBAL_TILE_MANAGER_H_
7
8 #include <list>
9 #include "android_webview/browser/tile_resource_consumer.h"
10 #include "base/basictypes.h"
11 #include "base/lazy_instance.h"
12 #include "base/synchronization/lock.h"
13
14 namespace android_webview {
15
16 // A global tile manager to keep track of the number of tile resources. Each
17 // tile needs file descriptors (typically 2) and there is a soft limit of 1024
18 // file descriptors per Android process. The GlobalTileManager does not keep
19 // track of how many tiles each individual view is actually using. The purpose
20 // of GlobalTileManager is to behave gracefully (as in not crashing) when the
21 // embedder of webview creates a lot of webviews and draw them at the same time.
22 class GlobalTileManager {
23
24 private:
25 typedef std::list<TileResourceConsumer*> ListType;
boliu 2014/04/28 22:22:15 newline below
hush (inactive) 2014/04/30 20:50:17 Done.
26 public:
27 typedef ListType::iterator Key;
28 static GlobalTileManager* GetInstance();
29
30 // Requests the |num_of_tiles| from the available global pool. Returns the
31 // actual number of tiles granted to the requester. If |is_starved| is true,
32 // the GlobalTileManager will evict tiles allocated to other
33 // requesters.
34 size_t RequestTiles(size_t old_num_of_tiles, size_t new_num_of_tiles,
boliu 2014/04/28 22:22:15 c++ has a different new line wrap style, either al
hush (inactive) 2014/04/30 20:50:17 Pretty cool. Just did git cl format. On 2014/04/28
35 bool is_starved, Key key);
36
37 Key PushBack(TileResourceConsumer* tile_resource_consumer);
38
39 // |key| must be already in manager. Move renderer corresponding to |key| to
40 // most recent.
41 void DidDrawGL(Key key);
42
43 void Remove(Key key);
boliu 2014/04/28 22:22:15 newline below
hush (inactive) 2014/04/30 20:50:17 Done.
44 private:
45 friend struct base::DefaultLazyInstanceTraits<GlobalTileManager>;
46 GlobalTileManager();
47 ~GlobalTileManager();
boliu 2014/04/28 22:22:15 new line below
hush (inactive) 2014/04/30 20:50:17 Done.
48 // Continues evicting the least recently drawn views until freeing up at least
49 // amount of memory specified by |desired_policy| to draw a view specified
50 // by |key|.
51 // Returns the amount of memory that was actually evicted.
52 // This function is called when a requester is starved.
53 size_t EvictUntilSatisfied(size_t desired_num_tiles, Key key);
54
55 size_t allocated_tiles_;
boliu 2014/04/28 22:22:15 total_allocated_tiles_
hush (inactive) 2014/04/30 20:50:17 Done.
56 ListType mru_list_;
57 // The list of inactive views is from inactive_views_ to mru_list_end().
58 Key inactive_views_;
59
boliu 2014/04/28 22:22:15 This class lives on UI, right? Add a SequenceCheck
hush (inactive) 2014/04/30 20:50:17 yes it does. But I don't understand "sequenceCheck
boliu 2014/05/01 00:37:40 Yes. Let's try not depending on BrowserThreads in
60 DISALLOW_COPY_AND_ASSIGN(GlobalTileManager);
61 };
62
63 } // namespace android_webview
64
65 #endif
boliu 2014/04/28 22:22:15 comment on endif
hush (inactive) 2014/04/30 20:50:17 Done.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698