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

Side by Side Diff: Source/core/css/FontFaceSet.h

Issue 27571005: Replace Timers used in ActiveDOMObject with AsyncMethodRunner (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 2 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 | Source/core/css/FontFaceSet.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 met: 5 * modification, are permitted provided that the following conditions are met:
6 * 6 *
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 14 matching lines...) Expand all
25 25
26 #ifndef FontFaceSet_h 26 #ifndef FontFaceSet_h
27 #define FontFaceSet_h 27 #define FontFaceSet_h
28 28
29 #include "bindings/v8/ScriptPromise.h" 29 #include "bindings/v8/ScriptPromise.h"
30 #include "core/css/FontFace.h" 30 #include "core/css/FontFace.h"
31 #include "core/dom/ActiveDOMObject.h" 31 #include "core/dom/ActiveDOMObject.h"
32 #include "core/events/EventListener.h" 32 #include "core/events/EventListener.h"
33 #include "core/events/EventTarget.h" 33 #include "core/events/EventTarget.h"
34 #include "core/events/ThreadLocalEventNames.h" 34 #include "core/events/ThreadLocalEventNames.h"
35 #include "platform/Timer.h" 35 #include "platform/AsyncMethodRunner.h"
36 #include "wtf/PassRefPtr.h" 36 #include "wtf/PassRefPtr.h"
37 #include "wtf/RefCounted.h" 37 #include "wtf/RefCounted.h"
38 #include "wtf/Vector.h" 38 #include "wtf/Vector.h"
39 39
40 // Mac OS X 10.6 SDK defines check() macro that interfares with our check() meth od 40 // Mac OS X 10.6 SDK defines check() macro that interfares with our check() meth od
41 #ifdef check 41 #ifdef check
42 #undef check 42 #undef check
43 #endif 43 #endif
44 44
45 namespace WebCore { 45 namespace WebCore {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 virtual const AtomicString& interfaceName() const OVERRIDE; 79 virtual const AtomicString& interfaceName() const OVERRIDE;
80 80
81 Document* document() const; 81 Document* document() const;
82 82
83 void didLayout(); 83 void didLayout();
84 void beginFontLoading(FontFace*); 84 void beginFontLoading(FontFace*);
85 void fontLoaded(FontFace*); 85 void fontLoaded(FontFace*);
86 void loadError(FontFace*); 86 void loadError(FontFace*);
87 void scheduleResolve(LoadFontPromiseResolver*); 87 void scheduleResolve(LoadFontPromiseResolver*);
88 88
89 // ActiveDOMObject
90 virtual void suspend() OVERRIDE;
91 virtual void resume() OVERRIDE;
92 virtual void stop() OVERRIDE;
93
89 private: 94 private:
90 class FontLoadHistogram { 95 class FontLoadHistogram {
91 public: 96 public:
92 FontLoadHistogram() : m_count(0), m_recorded(false) { } 97 FontLoadHistogram() : m_count(0), m_recorded(false) { }
93 void incrementCount() { m_count++; } 98 void incrementCount() { m_count++; }
94 void record(); 99 void record();
95 100
96 private: 101 private:
97 int m_count; 102 int m_count;
98 bool m_recorded; 103 bool m_recorded;
99 }; 104 };
100 105
101 FontFaceSet(Document*); 106 FontFaceSet(Document*);
102 107
103 void scheduleEvent(PassRefPtr<Event>); 108 void scheduleEvent(PassRefPtr<Event>);
104 void queueDoneEvent(FontFace*); 109 void queueDoneEvent(FontFace*);
105 void firePendingEvents(); 110 void firePendingEvents();
106 void resolvePendingLoadPromises(); 111 void resolvePendingLoadPromises();
107 void fireDoneEventIfPossible(); 112 void fireDoneEventIfPossible();
108 bool resolveFontStyle(const String&, Font&); 113 bool resolveFontStyle(const String&, Font&);
109 void timerFired(Timer<FontFaceSet>*); 114 void handlePendingEventsAndPromisesSoon();
115 void handlePendingEventsAndPromises();
110 116
111 unsigned m_loadingCount; 117 unsigned m_loadingCount;
112 Vector<RefPtr<Event> > m_pendingEvents; 118 Vector<RefPtr<Event> > m_pendingEvents;
113 Vector<RefPtr<LoadFontPromiseResolver> > m_pendingLoadResolvers; 119 Vector<RefPtr<LoadFontPromiseResolver> > m_pendingLoadResolvers;
114 Vector<OwnPtr<FontsReadyPromiseResolver> > m_readyResolvers; 120 Vector<OwnPtr<FontsReadyPromiseResolver> > m_readyResolvers;
115 FontFaceArray m_loadedFonts; 121 FontFaceArray m_loadedFonts;
116 FontFaceArray m_failedFonts; 122 FontFaceArray m_failedFonts;
117 bool m_shouldFireDoneEvent; 123 bool m_shouldFireDoneEvent;
118 Timer<FontFaceSet> m_timer; 124
125 AsyncMethodRunner<FontFaceSet> m_asyncRunner;
126
119 FontLoadHistogram m_histogram; 127 FontLoadHistogram m_histogram;
120 }; 128 };
121 129
122 } // namespace WebCore 130 } // namespace WebCore
123 131
124 #endif // FontFaceSet_h 132 #endif // FontFaceSet_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/css/FontFaceSet.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698