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) |
|
sof
2015/08/14 06:17:55
nit: this null check is redundant.
peria
2015/08/14 07:36:14
Done.
| |
| 107 return nullptr; | 107 return nullptr; |
| 108 | 108 |
| 109 RefPtrWillBeRawPtr<ServiceWorker> serviceWorker = getOrCreate(executionConte xt, worker); | 109 return getOrCreate(executionContext, worker); |
| 110 return serviceWorker.release(); | |
| 111 } | 110 } |
| 112 | 111 |
| 113 bool ServiceWorker::hasPendingActivity() const | 112 bool ServiceWorker::hasPendingActivity() const |
| 114 { | 113 { |
| 115 if (AbstractWorker::hasPendingActivity()) | 114 if (AbstractWorker::hasPendingActivity()) |
| 116 return true; | 115 return true; |
| 117 if (m_wasStopped) | 116 if (m_wasStopped) |
| 118 return false; | 117 return false; |
| 119 return m_outerWorker->state() != WebServiceWorkerStateRedundant; | 118 return m_outerWorker->state() != WebServiceWorkerStateRedundant; |
| 120 } | 119 } |
| 121 | 120 |
| 122 void ServiceWorker::stop() | 121 void ServiceWorker::stop() |
| 123 { | 122 { |
| 124 m_wasStopped = true; | 123 m_wasStopped = true; |
| 125 } | 124 } |
| 126 | 125 |
| 127 PassRefPtrWillBeRawPtr<ServiceWorker> ServiceWorker::getOrCreate(ExecutionContex t* executionContext, WebServiceWorker* outerWorker) | 126 ServiceWorker* ServiceWorker::getOrCreate(ExecutionContext* executionContext, We bServiceWorker* outerWorker) |
| 128 { | 127 { |
| 129 if (!outerWorker) | 128 if (!outerWorker) |
| 130 return nullptr; | 129 return nullptr; |
| 131 | 130 |
| 132 ServiceWorker* existingServiceWorker = static_cast<ServiceWorker*>(outerWork er->proxy()); | 131 ServiceWorker* existingServiceWorker = static_cast<ServiceWorker*>(outerWork er->proxy()); |
| 133 if (existingServiceWorker) { | 132 if (existingServiceWorker) { |
| 134 ASSERT(existingServiceWorker->executionContext() == executionContext); | 133 ASSERT(existingServiceWorker->executionContext() == executionContext); |
| 135 return existingServiceWorker; | 134 return existingServiceWorker; |
| 136 } | 135 } |
| 137 | 136 |
| 138 RefPtrWillBeRawPtr<ServiceWorker> worker = adoptRefWillBeNoop(new ServiceWor ker(executionContext, adoptPtr(outerWorker))); | 137 ServiceWorker* worker = new ServiceWorker(executionContext, adoptPtr(outerWo rker)); |
| 139 worker->suspendIfNeeded(); | 138 worker->suspendIfNeeded(); |
| 140 return worker.release(); | 139 return worker; |
| 141 } | 140 } |
| 142 | 141 |
| 143 ServiceWorker::ServiceWorker(ExecutionContext* executionContext, PassOwnPtr<WebS erviceWorker> worker) | 142 ServiceWorker::ServiceWorker(ExecutionContext* executionContext, PassOwnPtr<WebS erviceWorker> worker) |
| 144 : AbstractWorker(executionContext) | 143 : AbstractWorker(executionContext) |
| 145 , m_outerWorker(worker) | 144 , m_outerWorker(worker) |
| 146 , m_wasStopped(false) | 145 , m_wasStopped(false) |
| 147 { | 146 { |
| 148 ASSERT(m_outerWorker); | 147 ASSERT(m_outerWorker); |
| 149 m_outerWorker->setProxy(this); | 148 m_outerWorker->setProxy(this); |
| 150 } | 149 } |
| 151 | 150 |
| 152 ServiceWorker::~ServiceWorker() | 151 ServiceWorker::~ServiceWorker() |
| 153 { | 152 { |
| 154 } | 153 } |
| 155 | 154 |
| 156 } // namespace blink | 155 } // namespace blink |
| OLD | NEW |