OLD | NEW |
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 21 matching lines...) Expand all Loading... |
32 | 32 |
33 #include "platform/RuntimeEnabledFeatures.h" | 33 #include "platform/RuntimeEnabledFeatures.h" |
34 #include "wtf/Assertions.h" | 34 #include "wtf/Assertions.h" |
35 | 35 |
36 namespace blink { | 36 namespace blink { |
37 | 37 |
38 static DocumentLifecycle::DeprecatedTransition* s_deprecatedTransitionStack = 0; | 38 static DocumentLifecycle::DeprecatedTransition* s_deprecatedTransitionStack = 0; |
39 | 39 |
40 // TODO(skyostil): Come up with a better way to store cross-frame lifecycle | 40 // TODO(skyostil): Come up with a better way to store cross-frame lifecycle |
41 // related data to avoid this being a global setting. | 41 // related data to avoid this being a global setting. |
42 static unsigned s_preventThrottlingCount = 0; | 42 static unsigned s_allowThrottlingCount = 0; |
43 | 43 |
44 DocumentLifecycle::Scope::Scope(DocumentLifecycle& lifecycle, State finalState) | 44 DocumentLifecycle::Scope::Scope(DocumentLifecycle& lifecycle, State finalState) |
45 : m_lifecycle(lifecycle) | 45 : m_lifecycle(lifecycle) |
46 , m_finalState(finalState) | 46 , m_finalState(finalState) |
47 { | 47 { |
48 } | 48 } |
49 | 49 |
50 DocumentLifecycle::Scope::~Scope() | 50 DocumentLifecycle::Scope::~Scope() |
51 { | 51 { |
52 m_lifecycle.advanceTo(m_finalState); | 52 m_lifecycle.advanceTo(m_finalState); |
53 } | 53 } |
54 | 54 |
55 DocumentLifecycle::DeprecatedTransition::DeprecatedTransition(State from, State
to) | 55 DocumentLifecycle::DeprecatedTransition::DeprecatedTransition(State from, State
to) |
56 : m_previous(s_deprecatedTransitionStack) | 56 : m_previous(s_deprecatedTransitionStack) |
57 , m_from(from) | 57 , m_from(from) |
58 , m_to(to) | 58 , m_to(to) |
59 { | 59 { |
60 s_deprecatedTransitionStack = this; | 60 s_deprecatedTransitionStack = this; |
61 } | 61 } |
62 | 62 |
63 DocumentLifecycle::DeprecatedTransition::~DeprecatedTransition() | 63 DocumentLifecycle::DeprecatedTransition::~DeprecatedTransition() |
64 { | 64 { |
65 s_deprecatedTransitionStack = m_previous; | 65 s_deprecatedTransitionStack = m_previous; |
66 } | 66 } |
67 | 67 |
68 DocumentLifecycle::PreventThrottlingScope::PreventThrottlingScope(DocumentLifecy
cle& lifecycle) | 68 DocumentLifecycle::AllowThrottlingScope::AllowThrottlingScope(DocumentLifecycle&
lifecycle) |
69 { | 69 { |
70 s_preventThrottlingCount++; | 70 s_allowThrottlingCount++; |
71 } | 71 } |
72 | 72 |
73 DocumentLifecycle::PreventThrottlingScope::~PreventThrottlingScope() | 73 DocumentLifecycle::AllowThrottlingScope::~AllowThrottlingScope() |
74 { | 74 { |
75 ASSERT(s_preventThrottlingCount > 0); | 75 ASSERT(s_allowThrottlingCount > 0); |
76 s_preventThrottlingCount--; | 76 s_allowThrottlingCount--; |
77 } | 77 } |
78 | 78 |
79 DocumentLifecycle::DocumentLifecycle() | 79 DocumentLifecycle::DocumentLifecycle() |
80 : m_state(Uninitialized) | 80 : m_state(Uninitialized) |
81 , m_detachCount(0) | 81 , m_detachCount(0) |
82 { | 82 { |
83 } | 83 } |
84 | 84 |
85 DocumentLifecycle::~DocumentLifecycle() | 85 DocumentLifecycle::~DocumentLifecycle() |
86 { | 86 { |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 ASSERT(state == VisualUpdatePending || state == StyleClean || state == Layou
tClean); | 276 ASSERT(state == VisualUpdatePending || state == StyleClean || state == Layou
tClean); |
277 if (m_state <= state) | 277 if (m_state <= state) |
278 return; | 278 return; |
279 ASSERT_WITH_MESSAGE(canRewindTo(state), | 279 ASSERT_WITH_MESSAGE(canRewindTo(state), |
280 "Cannot rewind document lifecycle from %s to %s.", stateAsDebugString(m_
state), stateAsDebugString(state)); | 280 "Cannot rewind document lifecycle from %s to %s.", stateAsDebugString(m_
state), stateAsDebugString(state)); |
281 m_state = state; | 281 m_state = state; |
282 } | 282 } |
283 | 283 |
284 bool DocumentLifecycle::throttlingAllowed() const | 284 bool DocumentLifecycle::throttlingAllowed() const |
285 { | 285 { |
286 return !s_preventThrottlingCount; | 286 return s_allowThrottlingCount; |
287 } | 287 } |
288 | 288 |
289 #if ENABLE(ASSERT) | 289 #if ENABLE(ASSERT) |
290 #define DEBUG_STRING_CASE(StateName) \ | 290 #define DEBUG_STRING_CASE(StateName) \ |
291 case StateName: return #StateName | 291 case StateName: return #StateName |
292 | 292 |
293 const char* DocumentLifecycle::stateAsDebugString(const State state) | 293 const char* DocumentLifecycle::stateAsDebugString(const State state) |
294 { | 294 { |
295 switch (state) { | 295 switch (state) { |
296 DEBUG_STRING_CASE(Uninitialized); | 296 DEBUG_STRING_CASE(Uninitialized); |
(...skipping 19 matching lines...) Expand all Loading... |
316 DEBUG_STRING_CASE(Stopped); | 316 DEBUG_STRING_CASE(Stopped); |
317 DEBUG_STRING_CASE(Disposed); | 317 DEBUG_STRING_CASE(Disposed); |
318 } | 318 } |
319 | 319 |
320 ASSERT_NOT_REACHED(); | 320 ASSERT_NOT_REACHED(); |
321 return "Unknown"; | 321 return "Unknown"; |
322 } | 322 } |
323 #endif | 323 #endif |
324 | 324 |
325 } // namespace blink | 325 } // namespace blink |
OLD | NEW |