Chromium Code Reviews| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 return m_outerWorker->url().string(); | 106 return m_outerWorker->url().string(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 const AtomicString& ServiceWorker::state() const | 109 const AtomicString& ServiceWorker::state() const |
| 110 { | 110 { |
| 111 DEFINE_STATIC_LOCAL(AtomicString, unknown, ("unknown", AtomicString::Constru ctFromLiteral)); | 111 DEFINE_STATIC_LOCAL(AtomicString, unknown, ("unknown", AtomicString::Constru ctFromLiteral)); |
| 112 DEFINE_STATIC_LOCAL(AtomicString, parsed, ("parsed", AtomicString::Construct FromLiteral)); | 112 DEFINE_STATIC_LOCAL(AtomicString, parsed, ("parsed", AtomicString::Construct FromLiteral)); |
| 113 DEFINE_STATIC_LOCAL(AtomicString, installing, ("installing", AtomicString::C onstructFromLiteral)); | 113 DEFINE_STATIC_LOCAL(AtomicString, installing, ("installing", AtomicString::C onstructFromLiteral)); |
| 114 DEFINE_STATIC_LOCAL(AtomicString, installed, ("installed", AtomicString::Con structFromLiteral)); | 114 DEFINE_STATIC_LOCAL(AtomicString, installed, ("installed", AtomicString::Con structFromLiteral)); |
| 115 DEFINE_STATIC_LOCAL(AtomicString, activating, ("activating", AtomicString::C onstructFromLiteral)); | 115 DEFINE_STATIC_LOCAL(AtomicString, activating, ("activating", AtomicString::C onstructFromLiteral)); |
| 116 DEFINE_STATIC_LOCAL(AtomicString, active, ("active", AtomicString::Construct FromLiteral)); | 116 DEFINE_STATIC_LOCAL(AtomicString, active, ("activated", AtomicString::Constr uctFromLiteral)); |
|
jsbell
2014/07/01 16:16:48
Rename the variable as well, for consistency?
xiang
2014/07/02 05:10:43
OK.
| |
| 117 DEFINE_STATIC_LOCAL(AtomicString, deactivated, ("deactivated", AtomicString: :ConstructFromLiteral)); | 117 DEFINE_STATIC_LOCAL(AtomicString, redundant, ("redundant", AtomicString::Con structFromLiteral)); |
| 118 | 118 |
| 119 switch (m_outerWorker->state()) { | 119 switch (m_outerWorker->state()) { |
| 120 case blink::WebServiceWorkerStateUnknown: | 120 case blink::WebServiceWorkerStateUnknown: |
| 121 // The web platform should never see this internal state | 121 // The web platform should never see this internal state |
| 122 ASSERT_NOT_REACHED(); | 122 ASSERT_NOT_REACHED(); |
| 123 return unknown; | 123 return unknown; |
| 124 case blink::WebServiceWorkerStateParsed: | 124 case blink::WebServiceWorkerStateParsed: |
| 125 return parsed; | 125 return parsed; |
| 126 case blink::WebServiceWorkerStateInstalling: | 126 case blink::WebServiceWorkerStateInstalling: |
| 127 return installing; | 127 return installing; |
| 128 case blink::WebServiceWorkerStateInstalled: | 128 case blink::WebServiceWorkerStateInstalled: |
| 129 return installed; | 129 return installed; |
| 130 case blink::WebServiceWorkerStateActivating: | 130 case blink::WebServiceWorkerStateActivating: |
| 131 return activating; | 131 return activating; |
| 132 case blink::WebServiceWorkerStateActive: | 132 case blink::WebServiceWorkerStateActive: |
| 133 return active; | 133 return active; |
| 134 case blink::WebServiceWorkerStateDeactivated: | 134 case blink::WebServiceWorkerStateRedundant: |
| 135 return deactivated; | 135 return redundant; |
| 136 default: | 136 default: |
| 137 ASSERT_NOT_REACHED(); | 137 ASSERT_NOT_REACHED(); |
| 138 return nullAtom; | 138 return nullAtom; |
| 139 } | 139 } |
| 140 } | 140 } |
| 141 | 141 |
| 142 PassRefPtr<ServiceWorker> ServiceWorker::from(ExecutionContext* executionContext , WebType* worker) | 142 PassRefPtr<ServiceWorker> ServiceWorker::from(ExecutionContext* executionContext , WebType* worker) |
| 143 { | 143 { |
| 144 if (!worker) | 144 if (!worker) |
| 145 return PassRefPtr<ServiceWorker>(); | 145 return PassRefPtr<ServiceWorker>(); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 setProxyState(RegisterPromisePending); | 205 setProxyState(RegisterPromisePending); |
| 206 promise.then(ThenFunction::create(this)); | 206 promise.then(ThenFunction::create(this)); |
| 207 } | 207 } |
| 208 | 208 |
| 209 bool ServiceWorker::hasPendingActivity() const | 209 bool ServiceWorker::hasPendingActivity() const |
| 210 { | 210 { |
| 211 if (AbstractWorker::hasPendingActivity()) | 211 if (AbstractWorker::hasPendingActivity()) |
| 212 return true; | 212 return true; |
| 213 if (m_proxyState == ContextStopped) | 213 if (m_proxyState == ContextStopped) |
| 214 return false; | 214 return false; |
| 215 return m_outerWorker->state() != blink::WebServiceWorkerStateDeactivated; | 215 return m_outerWorker->state() != blink::WebServiceWorkerStateRedundant; |
| 216 } | 216 } |
| 217 | 217 |
| 218 void ServiceWorker::stop() | 218 void ServiceWorker::stop() |
| 219 { | 219 { |
| 220 setProxyState(ContextStopped); | 220 setProxyState(ContextStopped); |
| 221 } | 221 } |
| 222 | 222 |
| 223 PassRefPtr<ServiceWorker> ServiceWorker::create(ExecutionContext* executionConte xt, PassOwnPtr<blink::WebServiceWorker> outerWorker) | 223 PassRefPtr<ServiceWorker> ServiceWorker::create(ExecutionContext* executionConte xt, PassOwnPtr<blink::WebServiceWorker> outerWorker) |
| 224 { | 224 { |
| 225 RefPtr<ServiceWorker> worker = adoptRef(new ServiceWorker(executionContext, outerWorker)); | 225 RefPtr<ServiceWorker> worker = adoptRef(new ServiceWorker(executionContext, outerWorker)); |
| 226 worker->suspendIfNeeded(); | 226 worker->suspendIfNeeded(); |
| 227 return worker.release(); | 227 return worker.release(); |
| 228 } | 228 } |
| 229 | 229 |
| 230 ServiceWorker::ServiceWorker(ExecutionContext* executionContext, PassOwnPtr<blin k::WebServiceWorker> worker) | 230 ServiceWorker::ServiceWorker(ExecutionContext* executionContext, PassOwnPtr<blin k::WebServiceWorker> worker) |
| 231 : AbstractWorker(executionContext) | 231 : AbstractWorker(executionContext) |
| 232 , WebServiceWorkerProxy(this) | 232 , WebServiceWorkerProxy(this) |
| 233 , m_outerWorker(worker) | 233 , m_outerWorker(worker) |
| 234 , m_proxyState(Initial) | 234 , m_proxyState(Initial) |
| 235 { | 235 { |
| 236 ScriptWrappable::init(this); | 236 ScriptWrappable::init(this); |
| 237 ASSERT(m_outerWorker); | 237 ASSERT(m_outerWorker); |
| 238 m_outerWorker->setProxy(this); | 238 m_outerWorker->setProxy(this); |
| 239 } | 239 } |
| 240 | 240 |
| 241 } // namespace WebCore | 241 } // namespace WebCore |
| OLD | NEW |