|
Lines 143-159
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_ERROR("Unable to acquire assertion for process %d", pid); |
| 153 |
ASSERT_NOT_REACHED(); |
152 |
ASSERT_NOT_REACHED(); |
|
|
153 |
invalidationCallback(); |
| 154 |
} |
154 |
} |
| 155 |
}; |
155 |
}; |
| 156 |
m_assertion = adoptNS([[BKSProcessAssertion alloc] initWithPID:pid flags:flagsForState(assertionState) reason:BKSProcessAssertionReasonExtension name:@"Web content visible" withHandler:handler]); |
156 |
m_assertion = adoptNS([[BKSProcessAssertion alloc] initWithPID:pid flags:flagsForState(assertionState) reason:BKSProcessAssertionReasonExtension name:@"Web content visible" withHandler:handler]); |
|
|
157 |
m_assertion.get().invalidationHandler = ^() { |
| 158 |
invalidationCallback(); |
| 159 |
}; |
| 157 |
} |
160 |
} |
| 158 |
|
161 |
|
| 159 |
ProcessAssertion::~ProcessAssertion() |
162 |
ProcessAssertion::~ProcessAssertion() |
|
Lines 173-179
void ProcessAssertion::setState(AssertionState assertionState)
a/Source/WebKit2/UIProcess/ios/ProcessAssertionIOS.mm_sec2
|
| 173 |
} |
176 |
} |
| 174 |
|
177 |
|
| 175 |
ProcessAndUIAssertion::ProcessAndUIAssertion(pid_t pid, AssertionState assertionState) |
178 |
ProcessAndUIAssertion::ProcessAndUIAssertion(pid_t pid, AssertionState assertionState) |
| 176 |
: ProcessAssertion(pid, assertionState) |
179 |
: ProcessAssertion(pid, assertionState, [this] { setState(AssertionState::Suspended); }) |
| 177 |
{ |
180 |
{ |
| 178 |
if (assertionState != AssertionState::Suspended) |
181 |
if (assertionState != AssertionState::Suspended) |
| 179 |
[[WKProcessAssertionBackgroundTaskManager shared] incrementNeedsToRunInBackgroundCount]; |
182 |
[[WKProcessAssertionBackgroundTaskManager shared] incrementNeedsToRunInBackgroundCount]; |
|
Lines 209-215
void ProcessAndUIAssertion::setClient(ProcessAssertionClient& newClient)
a/Source/WebKit2/UIProcess/ios/ProcessAssertionIOS.mm_sec3
|
| 209 |
|
212 |
|
| 210 |
namespace WebKit { |
213 |
namespace WebKit { |
| 211 |
|
214 |
|
| 212 |
ProcessAssertion::ProcessAssertion(pid_t, AssertionState assertionState) |
215 |
ProcessAssertion::ProcessAssertion(pid_t, AssertionState assertionState, std::function<void()>) |
| 213 |
: m_assertionState(assertionState) |
216 |
: m_assertionState(assertionState) |
| 214 |
{ |
217 |
{ |
| 215 |
} |
218 |
} |