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

Side by Side Diff: Source/core/fetch/ResourceLoadPriorityOptimizer.h

Issue 131233003: Refactor ResourceLoadPriorityOptimizer to avoid walking render tree (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Use esprehn's suggestion. Created 6 years, 11 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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 18 matching lines...) Expand all
29 */ 29 */
30 30
31 #ifndef ResourceLoadPriorityOptimizer_h 31 #ifndef ResourceLoadPriorityOptimizer_h
32 #define ResourceLoadPriorityOptimizer_h 32 #define ResourceLoadPriorityOptimizer_h
33 33
34 #include "core/fetch/ImageResource.h" 34 #include "core/fetch/ImageResource.h"
35 #include "core/fetch/ResourcePtr.h" 35 #include "core/fetch/ResourcePtr.h"
36 #include "platform/geometry/LayoutRect.h" 36 #include "platform/geometry/LayoutRect.h"
37 37
38 #include "wtf/HashMap.h" 38 #include "wtf/HashMap.h"
39 #include "wtf/HashSet.h"
39 #include "wtf/OwnPtr.h" 40 #include "wtf/OwnPtr.h"
40 41
41 namespace WebCore { 42 namespace WebCore {
42 43
43 class ResourceLoadPriorityOptimizer { 44 class ResourceLoadPriorityOptimizer {
44 public: 45 public:
45 enum VisibilityStatus { 46 enum VisibilityStatus {
46 NotVisible, 47 NotVisible,
47 Visible, 48 Visible,
48 }; 49 };
50 void notifyImageResourceVisibility(ImageResource*, VisibilityStatus);
51 void updateAllImageResourcePriorities();
52 void addRenderObject(RenderObject*);
53 void removeRenderObject(RenderObject*);
54
55 private:
49 ResourceLoadPriorityOptimizer(); 56 ResourceLoadPriorityOptimizer();
50 ~ResourceLoadPriorityOptimizer(); 57 ~ResourceLoadPriorityOptimizer();
51 void notifyImageResourceVisibility(ImageResource*, VisibilityStatus);
52 58
53 private:
54 void updateImageResourcesWithLoadPriority(); 59 void updateImageResourcesWithLoadPriority();
55 60
56 struct ResourceAndVisibility { 61 struct ResourceAndVisibility {
57 ResourceAndVisibility(ImageResource*, VisibilityStatus); 62 ResourceAndVisibility(ImageResource*, VisibilityStatus);
58 ~ResourceAndVisibility(); 63 ~ResourceAndVisibility();
59 ResourcePtr<ImageResource> imageResource; 64 ResourcePtr<ImageResource> imageResource;
60 VisibilityStatus status; 65 VisibilityStatus status;
61 }; 66 };
62 67
63 typedef HashMap<unsigned long, OwnPtr<ResourceAndVisibility> > ImageResource Map; 68 typedef HashMap<unsigned long, OwnPtr<ResourceAndVisibility> > ImageResource Map;
64 ImageResourceMap m_imageResources; 69 ImageResourceMap m_imageResources;
70
71 typedef HashSet<RenderObject*> RenderObjectSet;
72 RenderObjectSet m_objectCache;
73
74 friend ResourceLoadPriorityOptimizer* resourceLoadPriorityOptimizer();
esprehn 2014/01/15 01:27:45 Can this just be a static thing instead? Why does
shatch 2014/01/15 19:28:52 Done.
65 }; 75 };
66 76
77 ResourceLoadPriorityOptimizer* resourceLoadPriorityOptimizer();
78
67 } 79 }
68 80
69 #endif 81 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698