| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 | 114 |
| 115 ServiceWorker* ServiceWorker::from(ExecutionContext* executionContext, PassOwnPt
r<WebServiceWorker::Handle> handle) | 115 ServiceWorker* ServiceWorker::from(ExecutionContext* executionContext, PassOwnPt
r<WebServiceWorker::Handle> handle) |
| 116 { | 116 { |
| 117 return getOrCreate(executionContext, handle); | 117 return getOrCreate(executionContext, handle); |
| 118 } | 118 } |
| 119 | 119 |
| 120 bool ServiceWorker::hasPendingActivity() const | 120 bool ServiceWorker::hasPendingActivity() const |
| 121 { | 121 { |
| 122 if (AbstractWorker::hasPendingActivity()) | |
| 123 return true; | |
| 124 if (m_wasStopped) | 122 if (m_wasStopped) |
| 125 return false; | 123 return false; |
| 126 return m_handle->serviceWorker()->state() != WebServiceWorkerStateRedundant; | 124 return m_handle->serviceWorker()->state() != WebServiceWorkerStateRedundant; |
| 127 } | 125 } |
| 128 | 126 |
| 129 void ServiceWorker::stop() | 127 void ServiceWorker::stop() |
| 130 { | 128 { |
| 131 m_wasStopped = true; | 129 m_wasStopped = true; |
| 132 } | 130 } |
| 133 | 131 |
| 134 ServiceWorker* ServiceWorker::getOrCreate(ExecutionContext* executionContext, Pa
ssOwnPtr<WebServiceWorker::Handle> handle) | 132 ServiceWorker* ServiceWorker::getOrCreate(ExecutionContext* executionContext, Pa
ssOwnPtr<WebServiceWorker::Handle> handle) |
| 135 { | 133 { |
| 136 if (!handle) | 134 if (!handle) |
| 137 return nullptr; | 135 return nullptr; |
| 138 | 136 |
| 139 ServiceWorker* existingWorker = static_cast<ServiceWorker*>(handle->serviceW
orker()->proxy()); | 137 ServiceWorker* existingWorker = static_cast<ServiceWorker*>(handle->serviceW
orker()->proxy()); |
| 140 if (existingWorker) { | 138 if (existingWorker) { |
| 141 ASSERT(existingWorker->getExecutionContext() == executionContext); | 139 ASSERT(existingWorker->getExecutionContext() == executionContext); |
| 142 return existingWorker; | 140 return existingWorker; |
| 143 } | 141 } |
| 144 | 142 |
| 145 ServiceWorker* newWorker = new ServiceWorker(executionContext, handle); | 143 ServiceWorker* newWorker = new ServiceWorker(executionContext, handle); |
| 146 newWorker->suspendIfNeeded(); | 144 newWorker->suspendIfNeeded(); |
| 147 return newWorker; | 145 return newWorker; |
| 148 } | 146 } |
| 149 | 147 |
| 150 ServiceWorker::ServiceWorker(ExecutionContext* executionContext, PassOwnPtr<WebS
erviceWorker::Handle> handle) | 148 ServiceWorker::ServiceWorker(ExecutionContext* executionContext, PassOwnPtr<WebS
erviceWorker::Handle> handle) |
| 151 : AbstractWorker(executionContext) | 149 : AbstractWorker(executionContext) |
| 150 , ActiveScriptWrappable(this) |
| 152 , m_handle(handle) | 151 , m_handle(handle) |
| 153 , m_wasStopped(false) | 152 , m_wasStopped(false) |
| 154 { | 153 { |
| 155 ASSERT(m_handle); | 154 ASSERT(m_handle); |
| 156 m_handle->serviceWorker()->setProxy(this); | 155 m_handle->serviceWorker()->setProxy(this); |
| 157 } | 156 } |
| 158 | 157 |
| 159 ServiceWorker::~ServiceWorker() | 158 ServiceWorker::~ServiceWorker() |
| 160 { | 159 { |
| 161 } | 160 } |
| 162 | 161 |
| 163 } // namespace blink | 162 } // namespace blink |
| OLD | NEW |