Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 ASSERT(!m_requestInFlight); | 118 ASSERT(!m_requestInFlight); |
| 119 | 119 |
| 120 m_connectTimer.startOneShot(0, FROM_HERE); | 120 m_connectTimer.startOneShot(0, FROM_HERE); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void EventSource::connect() | 123 void EventSource::connect() |
| 124 { | 124 { |
| 125 ASSERT(m_state == CONNECTING); | 125 ASSERT(m_state == CONNECTING); |
| 126 ASSERT(!m_requestInFlight); | 126 ASSERT(!m_requestInFlight); |
| 127 | 127 |
| 128 ExecutionContext* executionContextLocal = executionContext(); | |
|
Inactive
2014/03/31 17:43:26
I don't really like the "*Local" naming. I guess y
maheshkk
2014/03/31 20:46:49
Thanks! changed it as per your suggestion.
| |
| 128 ResourceRequest request(m_url); | 129 ResourceRequest request(m_url); |
| 129 request.setHTTPMethod("GET"); | 130 request.setHTTPMethod("GET"); |
| 130 request.setHTTPHeaderField("Accept", "text/event-stream"); | 131 request.setHTTPHeaderField("Accept", "text/event-stream"); |
| 131 request.setHTTPHeaderField("Cache-Control", "no-cache"); | 132 request.setHTTPHeaderField("Cache-Control", "no-cache"); |
| 132 if (!m_lastEventId.isEmpty()) | 133 if (!m_lastEventId.isEmpty()) |
| 133 request.setHTTPHeaderField("Last-Event-ID", m_lastEventId); | 134 request.setHTTPHeaderField("Last-Event-ID", m_lastEventId); |
| 134 | 135 |
| 135 SecurityOrigin* origin = executionContext()->securityOrigin(); | 136 SecurityOrigin* origin = executionContextLocal->securityOrigin(); |
| 136 | 137 |
| 137 ThreadableLoaderOptions options; | 138 ThreadableLoaderOptions options; |
| 138 options.sniffContent = DoNotSniffContent; | 139 options.sniffContent = DoNotSniffContent; |
| 139 options.allowCredentials = (origin->canRequest(m_url) || m_withCredentials) ? AllowStoredCredentials : DoNotAllowStoredCredentials; | 140 options.allowCredentials = (origin->canRequest(m_url) || m_withCredentials) ? AllowStoredCredentials : DoNotAllowStoredCredentials; |
| 140 options.credentialsRequested = m_withCredentials ? ClientRequestedCredential s : ClientDidNotRequestCredentials; | 141 options.credentialsRequested = m_withCredentials ? ClientRequestedCredential s : ClientDidNotRequestCredentials; |
| 141 options.preflightPolicy = PreventPreflight; | 142 options.preflightPolicy = PreventPreflight; |
| 142 options.crossOriginRequestPolicy = UseAccessControl; | 143 options.crossOriginRequestPolicy = UseAccessControl; |
| 143 options.dataBufferingPolicy = DoNotBufferData; | 144 options.dataBufferingPolicy = DoNotBufferData; |
| 144 options.securityOrigin = origin; | 145 options.securityOrigin = origin; |
| 145 options.contentSecurityPolicyEnforcement = ContentSecurityPolicy::shouldBypa ssMainWorld(executionContext()) ? DoNotEnforceContentSecurityPolicy : EnforceCon nectSrcDirective; | 146 options.contentSecurityPolicyEnforcement = ContentSecurityPolicy::shouldBypa ssMainWorld(executionContextLocal) ? DoNotEnforceContentSecurityPolicy : Enforce ConnectSrcDirective; |
| 146 | 147 |
| 147 m_loader = ThreadableLoader::create(executionContext(), this, request, optio ns); | 148 m_loader = ThreadableLoader::create(*executionContextLocal, this, request, o ptions); |
| 148 | 149 |
| 149 if (m_loader) | 150 if (m_loader) |
| 150 m_requestInFlight = true; | 151 m_requestInFlight = true; |
| 151 } | 152 } |
| 152 | 153 |
| 153 void EventSource::networkRequestEnded() | 154 void EventSource::networkRequestEnded() |
| 154 { | 155 { |
| 155 if (!m_requestInFlight) | 156 if (!m_requestInFlight) |
| 156 return; | 157 return; |
| 157 | 158 |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 426 | 427 |
| 427 PassRefPtr<MessageEvent> EventSource::createMessageEvent() | 428 PassRefPtr<MessageEvent> EventSource::createMessageEvent() |
| 428 { | 429 { |
| 429 RefPtr<MessageEvent> event = MessageEvent::create(); | 430 RefPtr<MessageEvent> event = MessageEvent::create(); |
| 430 event->initMessageEvent(m_eventName.isEmpty() ? EventTypeNames::message : m_ eventName, false, false, SerializedScriptValue::create(String(m_data)), m_eventS treamOrigin, m_lastEventId, 0, nullptr); | 431 event->initMessageEvent(m_eventName.isEmpty() ? EventTypeNames::message : m_ eventName, false, false, SerializedScriptValue::create(String(m_data)), m_eventS treamOrigin, m_lastEventId, 0, nullptr); |
| 431 m_data.clear(); | 432 m_data.clear(); |
| 432 return event.release(); | 433 return event.release(); |
| 433 } | 434 } |
| 434 | 435 |
| 435 } // namespace WebCore | 436 } // namespace WebCore |
| OLD | NEW |