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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 case WebServiceWorkerStateActivated: | 94 case WebServiceWorkerStateActivated: |
| 95 return "activated"; | 95 return "activated"; |
| 96 case WebServiceWorkerStateRedundant: | 96 case WebServiceWorkerStateRedundant: |
| 97 return "redundant"; | 97 return "redundant"; |
| 98 default: | 98 default: |
| 99 ASSERT_NOT_REACHED(); | 99 ASSERT_NOT_REACHED(); |
| 100 return nullAtom; | 100 return nullAtom; |
| 101 } | 101 } |
| 102 } | 102 } |
| 103 | 103 |
| 104 PassRefPtrWillBeRawPtr<ServiceWorker> ServiceWorker::from(ExecutionContext* exec utionContext, WebServiceWorker* worker) | 104 ServiceWorker* ServiceWorker::from(ExecutionContext* executionContext, WebServic eWorker* worker) |
| 105 { | 105 { |
| 106 if (!worker) | 106 if (!worker) |
| 107 return nullptr; | 107 return nullptr; |
| 108 | 108 |
| 109 RefPtrWillBeRawPtr<ServiceWorker> serviceWorker = getOrCreate(executionConte xt, worker); | 109 ServiceWorker* serviceWorker = getOrCreate(executionContext, worker); |
| 110 return serviceWorker.release(); | 110 return serviceWorker; |
|
haraken
2015/08/13 07:58:49
return getOrCreate(executionContext, worker);
| |
| 111 } | 111 } |
| 112 | 112 |
| 113 bool ServiceWorker::hasPendingActivity() const | 113 bool ServiceWorker::hasPendingActivity() const |
| 114 { | 114 { |
| 115 if (AbstractWorker::hasPendingActivity()) | 115 if (AbstractWorker::hasPendingActivity()) |
| 116 return true; | 116 return true; |
| 117 if (m_wasStopped) | 117 if (m_wasStopped) |
| 118 return false; | 118 return false; |
| 119 return m_outerWorker->state() != WebServiceWorkerStateRedundant; | 119 return m_outerWorker->state() != WebServiceWorkerStateRedundant; |
| 120 } | 120 } |
| 121 | 121 |
| 122 void ServiceWorker::stop() | 122 void ServiceWorker::stop() |
| 123 { | 123 { |
| 124 m_wasStopped = true; | 124 m_wasStopped = true; |
| 125 } | 125 } |
| 126 | 126 |
| 127 PassRefPtrWillBeRawPtr<ServiceWorker> ServiceWorker::getOrCreate(ExecutionContex t* executionContext, WebServiceWorker* outerWorker) | 127 ServiceWorker* ServiceWorker::getOrCreate(ExecutionContext* executionContext, We bServiceWorker* outerWorker) |
| 128 { | 128 { |
| 129 if (!outerWorker) | 129 if (!outerWorker) |
| 130 return nullptr; | 130 return nullptr; |
| 131 | 131 |
| 132 ServiceWorker* existingServiceWorker = static_cast<ServiceWorker*>(outerWork er->proxy()); | 132 ServiceWorker* existingServiceWorker = static_cast<ServiceWorker*>(outerWork er->proxy()); |
| 133 if (existingServiceWorker) { | 133 if (existingServiceWorker) { |
| 134 ASSERT(existingServiceWorker->executionContext() == executionContext); | 134 ASSERT(existingServiceWorker->executionContext() == executionContext); |
| 135 return existingServiceWorker; | 135 return existingServiceWorker; |
| 136 } | 136 } |
| 137 | 137 |
| 138 RefPtrWillBeRawPtr<ServiceWorker> worker = adoptRefWillBeNoop(new ServiceWor ker(executionContext, adoptPtr(outerWorker))); | 138 ServiceWorker* worker = new ServiceWorker(executionContext, adoptPtr(outerWo rker)); |
| 139 worker->suspendIfNeeded(); | 139 worker->suspendIfNeeded(); |
| 140 return worker.release(); | 140 return worker; |
| 141 } | 141 } |
| 142 | 142 |
| 143 ServiceWorker::ServiceWorker(ExecutionContext* executionContext, PassOwnPtr<WebS erviceWorker> worker) | 143 ServiceWorker::ServiceWorker(ExecutionContext* executionContext, PassOwnPtr<WebS erviceWorker> worker) |
| 144 : AbstractWorker(executionContext) | 144 : AbstractWorker(executionContext) |
| 145 , m_outerWorker(worker) | 145 , m_outerWorker(worker) |
| 146 , m_wasStopped(false) | 146 , m_wasStopped(false) |
| 147 { | 147 { |
| 148 ASSERT(m_outerWorker); | 148 ASSERT(m_outerWorker); |
| 149 m_outerWorker->setProxy(this); | 149 m_outerWorker->setProxy(this); |
| 150 } | 150 } |
| 151 | 151 |
| 152 ServiceWorker::~ServiceWorker() | 152 ServiceWorker::~ServiceWorker() |
| 153 { | 153 { |
| 154 } | 154 } |
| 155 | 155 |
| 156 } // namespace blink | 156 } // namespace blink |
| OLD | NEW |