|
Lines 143-163
static BKSProcessAssertionFlags flagsForState(AssertionState assertionState)
a/Source/WebKit2/UIProcess/ios/ProcessAssertionIOS.mm_sec1
|
| 143 |
} |
143 |
} |
| 144 |
} |
144 |
} |
| 145 |
|
145 |
|
| 146 |
ProcessAssertion::ProcessAssertion(pid_t pid, AssertionState assertionState) |
146 |
ProcessAssertion::ProcessAssertion(pid_t pid, AssertionState assertionState, std::function<void()> invalidationCallback) |
|
|
147 |
: m_assertionState(assertionState) |
| 147 |
{ |
148 |
{ |
| 148 |
m_assertionState = assertionState; |
|
|
| 149 |
|
| 150 |
BKSProcessAssertionAcquisitionHandler handler = ^(BOOL acquired) { |
149 |
BKSProcessAssertionAcquisitionHandler handler = ^(BOOL acquired) { |
| 151 |
if (!acquired) { |
150 |
if (!acquired) { |
| 152 |
LOG_ERROR("Unable to acquire assertion for process %d", pid); |
151 |
LOG_ALWAYS_ERROR(true, "Unable to acquire assertion for process %d", pid); |
| 153 |
ASSERT_NOT_REACHED(); |
152 |
ASSERT_NOT_REACHED(); |
|
|
153 |
m_validity = Validity::No; |
| 154 |
invalidationCallback(); |
| 154 |
} |
155 |
} |
| 155 |
}; |
156 |
}; |
| 156 |
m_assertion = adoptNS([[BKSProcessAssertion alloc] initWithPID:pid flags:flagsForState(assertionState) reason:BKSProcessAssertionReasonExtension name:@"Web content visible" withHandler:handler]); |
157 |
m_assertion = adoptNS([[BKSProcessAssertion alloc] initWithPID:pid flags:flagsForState(assertionState) reason:BKSProcessAssertionReasonExtension name:@"Web content visible" withHandler:handler]); |
|
|
158 |
m_assertion.get().invalidationHandler = ^() { |
| 159 |
m_validity = Validity::No; |
| 160 |
invalidationCallback(); |
| 161 |
}; |
| 157 |
} |
162 |
} |
| 158 |
|
163 |
|
| 159 |
ProcessAssertion::~ProcessAssertion() |
164 |
ProcessAssertion::~ProcessAssertion() |
| 160 |
{ |
165 |
{ |
|
|
166 |
m_assertion.get().invalidationHandler = nil; |
| 167 |
|
| 161 |
if (ProcessAssertionClient* client = this->client()) |
168 |
if (ProcessAssertionClient* client = this->client()) |
| 162 |
[[WKProcessAssertionBackgroundTaskManager shared] removeClient:*client]; |
169 |
[[WKProcessAssertionBackgroundTaskManager shared] removeClient:*client]; |
| 163 |
[m_assertion invalidate]; |
170 |
[m_assertion invalidate]; |
|
Lines 174-180
void ProcessAssertion::setState(AssertionState assertionState)
a/Source/WebKit2/UIProcess/ios/ProcessAssertionIOS.mm_sec2
|
| 174 |
|
181 |
|
| 175 |
void ProcessAndUIAssertion::updateRunInBackgroundCount() |
182 |
void ProcessAndUIAssertion::updateRunInBackgroundCount() |
| 176 |
{ |
183 |
{ |
| 177 |
bool shouldHoldBackgroundAssertion = state() != AssertionState::Suspended; |
184 |
bool shouldHoldBackgroundAssertion = validity() != Validity::No && state() != AssertionState::Suspended; |
| 178 |
|
185 |
|
| 179 |
if (shouldHoldBackgroundAssertion) { |
186 |
if (shouldHoldBackgroundAssertion) { |
| 180 |
if (!m_isHoldingBackgroundAssertion) |
187 |
if (!m_isHoldingBackgroundAssertion) |
|
Lines 188-194
void ProcessAndUIAssertion::updateRunInBackgroundCount()
a/Source/WebKit2/UIProcess/ios/ProcessAssertionIOS.mm_sec3
|
| 188 |
} |
195 |
} |
| 189 |
|
196 |
|
| 190 |
ProcessAndUIAssertion::ProcessAndUIAssertion(pid_t pid, AssertionState assertionState) |
197 |
ProcessAndUIAssertion::ProcessAndUIAssertion(pid_t pid, AssertionState assertionState) |
| 191 |
: ProcessAssertion(pid, assertionState) |
198 |
: ProcessAssertion(pid, assertionState, [this] { updateRunInBackgroundCount(); }) |
| 192 |
{ |
199 |
{ |
| 193 |
updateRunInBackgroundCount(); |
200 |
updateRunInBackgroundCount(); |
| 194 |
} |
201 |
} |
|
Lines 219-225
void ProcessAndUIAssertion::setClient(ProcessAssertionClient& newClient)
a/Source/WebKit2/UIProcess/ios/ProcessAssertionIOS.mm_sec4
|
| 219 |
|
226 |
|
| 220 |
namespace WebKit { |
227 |
namespace WebKit { |
| 221 |
|
228 |
|
| 222 |
ProcessAssertion::ProcessAssertion(pid_t, AssertionState assertionState) |
229 |
ProcessAssertion::ProcessAssertion(pid_t, AssertionState assertionState, std::function<void()>) |
| 223 |
: m_assertionState(assertionState) |
230 |
: m_assertionState(assertionState) |
| 224 |
{ |
231 |
{ |
| 225 |
} |
232 |
} |