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

Side by Side Diff: third_party/WebKit/Source/modules/eventsource/EventSource.cpp

Issue 2567913002: Rename ActiveDOMObject to SuspendableObject (Closed)
Patch Set: Created 4 years 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) 2009, 2012 Ericsson AB. All rights reserved. 2 * Copyright (C) 2009, 2012 Ericsson AB. All rights reserved.
3 * Copyright (C) 2010 Apple Inc. All rights reserved. 3 * Copyright (C) 2010 Apple Inc. All rights reserved.
4 * Copyright (C) 2011, Code Aurora Forum. All rights reserved. 4 * Copyright (C) 2011, Code Aurora Forum. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 #include <memory> 59 #include <memory>
60 60
61 namespace blink { 61 namespace blink {
62 62
63 const unsigned long long EventSource::defaultReconnectDelay = 3000; 63 const unsigned long long EventSource::defaultReconnectDelay = 3000;
64 64
65 inline EventSource::EventSource(ExecutionContext* context, 65 inline EventSource::EventSource(ExecutionContext* context,
66 const KURL& url, 66 const KURL& url,
67 const EventSourceInit& eventSourceInit) 67 const EventSourceInit& eventSourceInit)
68 : ActiveScriptWrappable(this), 68 : ActiveScriptWrappable(this),
69 ActiveDOMObject(context), 69 SuspendableObject(context),
70 m_url(url), 70 m_url(url),
71 m_currentURL(url), 71 m_currentURL(url),
72 m_withCredentials(eventSourceInit.withCredentials()), 72 m_withCredentials(eventSourceInit.withCredentials()),
73 m_state(kConnecting), 73 m_state(kConnecting),
74 m_connectTimer(this, &EventSource::connectTimerFired), 74 m_connectTimer(this, &EventSource::connectTimerFired),
75 m_reconnectDelay(defaultReconnectDelay) {} 75 m_reconnectDelay(defaultReconnectDelay) {}
76 76
77 EventSource* EventSource::create(ExecutionContext* context, 77 EventSource* EventSource::create(ExecutionContext* context,
78 const String& url, 78 const String& url,
79 const EventSourceInit& eventSourceInit, 79 const EventSourceInit& eventSourceInit,
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 216
217 void EventSource::close() { 217 void EventSource::close() {
218 if (m_state == kClosed) { 218 if (m_state == kClosed) {
219 DCHECK(!m_loader); 219 DCHECK(!m_loader);
220 return; 220 return;
221 } 221 }
222 if (m_parser) 222 if (m_parser)
223 m_parser->stop(); 223 m_parser->stop();
224 224
225 // Stop trying to reconnect if EventSource was explicitly closed or if 225 // Stop trying to reconnect if EventSource was explicitly closed or if
226 // ActiveDOMObject::stop() was called. 226 // SuspendableObject::stop() was called.
227 if (m_connectTimer.isActive()) { 227 if (m_connectTimer.isActive()) {
228 m_connectTimer.stop(); 228 m_connectTimer.stop();
229 } 229 }
230 230
231 if (m_loader) { 231 if (m_loader) {
232 m_loader->cancel(); 232 m_loader->cancel();
233 m_loader = nullptr; 233 m_loader = nullptr;
234 } 234 }
235 235
236 m_state = kClosed; 236 m_state = kClosed;
237 } 237 }
238 238
239 const AtomicString& EventSource::interfaceName() const { 239 const AtomicString& EventSource::interfaceName() const {
240 return EventTargetNames::EventSource; 240 return EventTargetNames::EventSource;
241 } 241 }
242 242
243 ExecutionContext* EventSource::getExecutionContext() const { 243 ExecutionContext* EventSource::getExecutionContext() const {
244 return ActiveDOMObject::getExecutionContext(); 244 return SuspendableObject::getExecutionContext();
245 } 245 }
246 246
247 void EventSource::didReceiveResponse( 247 void EventSource::didReceiveResponse(
248 unsigned long, 248 unsigned long,
249 const ResourceResponse& response, 249 const ResourceResponse& response,
250 std::unique_ptr<WebDataConsumerHandle> handle) { 250 std::unique_ptr<WebDataConsumerHandle> handle) {
251 DCHECK(!handle); 251 DCHECK(!handle);
252 DCHECK_EQ(kConnecting, m_state); 252 DCHECK_EQ(kConnecting, m_state);
253 DCHECK(m_loader); 253 DCHECK(m_loader);
254 254
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 } 373 }
374 374
375 bool EventSource::hasPendingActivity() const { 375 bool EventSource::hasPendingActivity() const {
376 return m_state != kClosed; 376 return m_state != kClosed;
377 } 377 }
378 378
379 DEFINE_TRACE(EventSource) { 379 DEFINE_TRACE(EventSource) {
380 visitor->trace(m_parser); 380 visitor->trace(m_parser);
381 visitor->trace(m_loader); 381 visitor->trace(m_loader);
382 EventTargetWithInlineData::trace(visitor); 382 EventTargetWithInlineData::trace(visitor);
383 ActiveDOMObject::trace(visitor); 383 SuspendableObject::trace(visitor);
384 EventSourceParser::Client::trace(visitor); 384 EventSourceParser::Client::trace(visitor);
385 } 385 }
386 386
387 } // namespace blink 387 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698