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

Side by Side Diff: Source/core/dom/ScriptExecutionContext.cpp

Issue 18777003: Extract simpler classes for observing context lifecycle and observe Page lifecycle inNavigatorVibra… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebaselined~ Created 7 years, 5 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 | « Source/core/dom/ScriptExecutionContext.h ('k') | Source/core/page/Page.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 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2012 Google Inc. All Rights Reserved. 3 * Copyright (C) 2012 Google Inc. All Rights Reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 } 178 }
179 179
180 void ScriptExecutionContext::suspendActiveDOMObjectIfNeeded(ActiveDOMObject* obj ect) 180 void ScriptExecutionContext::suspendActiveDOMObjectIfNeeded(ActiveDOMObject* obj ect)
181 { 181 {
182 ASSERT(lifecycleNotifier()->contains(object)); 182 ASSERT(lifecycleNotifier()->contains(object));
183 // Ensure all ActiveDOMObjects are suspended also newly created ones. 183 // Ensure all ActiveDOMObjects are suspended also newly created ones.
184 if (m_activeDOMObjectsAreSuspended) 184 if (m_activeDOMObjectsAreSuspended)
185 object->suspend(m_reasonForSuspendingActiveDOMObjects); 185 object->suspend(m_reasonForSuspendingActiveDOMObjects);
186 } 186 }
187 187
188 void ScriptExecutionContext::wasObservedBy(ContextLifecycleObserver* observer, C ontextLifecycleObserver::Type as)
189 {
190 lifecycleNotifier()->addObserver(observer, as);
191 }
192
193 void ScriptExecutionContext::wasUnobservedBy(ContextLifecycleObserver* observer, ContextLifecycleObserver::Type as)
194 {
195 lifecycleNotifier()->removeObserver(observer, as);
196 }
197
198 void ScriptExecutionContext::closeMessagePorts() { 188 void ScriptExecutionContext::closeMessagePorts() {
199 HashSet<MessagePort*>::iterator messagePortsEnd = m_messagePorts.end(); 189 HashSet<MessagePort*>::iterator messagePortsEnd = m_messagePorts.end();
200 for (HashSet<MessagePort*>::iterator iter = m_messagePorts.begin(); iter != messagePortsEnd; ++iter) { 190 for (HashSet<MessagePort*>::iterator iter = m_messagePorts.begin(); iter != messagePortsEnd; ++iter) {
201 ASSERT((*iter)->scriptExecutionContext() == this); 191 ASSERT((*iter)->scriptExecutionContext() == this);
202 (*iter)->close(); 192 (*iter)->close();
203 } 193 }
204 } 194 }
205 195
206 bool ScriptExecutionContext::sanitizeScriptError(String& errorMessage, int& line Number, String& sourceURL, CachedScript* cachedScript) 196 bool ScriptExecutionContext::sanitizeScriptError(String& errorMessage, int& line Number, String& sourceURL, CachedScript* cachedScript)
207 { 197 {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 iter->value->didChangeAlignmentInterval(); 296 iter->value->didChangeAlignmentInterval();
307 } 297 }
308 298
309 double ScriptExecutionContext::timerAlignmentInterval() const 299 double ScriptExecutionContext::timerAlignmentInterval() const
310 { 300 {
311 return DOMTimer::visiblePageAlignmentInterval(); 301 return DOMTimer::visiblePageAlignmentInterval();
312 } 302 }
313 303
314 ContextLifecycleNotifier* ScriptExecutionContext::lifecycleNotifier() 304 ContextLifecycleNotifier* ScriptExecutionContext::lifecycleNotifier()
315 { 305 {
316 if (!m_lifecycleNotifier) 306 return static_cast<ContextLifecycleNotifier*>(LifecycleContext::lifecycleNot ifier());
317 m_lifecycleNotifier = const_cast<ScriptExecutionContext*>(this)->createL ifecycleNotifier();
318 return m_lifecycleNotifier.get();
319 } 307 }
320 308
321 PassOwnPtr<ContextLifecycleNotifier> ScriptExecutionContext::createLifecycleNoti fier() 309 PassOwnPtr<LifecycleNotifier> ScriptExecutionContext::createLifecycleNotifier()
322 { 310 {
323 return ContextLifecycleNotifier::create(this); 311 return ContextLifecycleNotifier::create(this);
324 } 312 }
325 313
326 ScriptExecutionContext::Task::~Task() 314 ScriptExecutionContext::Task::~Task()
327 { 315 {
328 } 316 }
329 317
330 void ScriptExecutionContext::setDatabaseContext(DatabaseContext* databaseContext ) 318 void ScriptExecutionContext::setDatabaseContext(DatabaseContext* databaseContext )
331 { 319 {
332 m_databaseContext = databaseContext; 320 m_databaseContext = databaseContext;
333 } 321 }
334 322
335 } // namespace WebCore 323 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/ScriptExecutionContext.h ('k') | Source/core/page/Page.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698