Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
NativeIO: Add quota to sync Blink interface
This CL adds implements NativeIO's quota management system for synchronous calls in Blink. Blink requests capacity from the browser process. This CL does not change how capacity is granted by the browser process. The IPC call to the browser for requesting capacity is synchronous if and only if NativeIO's synchronous interface is being used. The design doc for NativeIO's quota system is here: https://docs.google.com/document/d/1wUrtCOsyH3qGwKuqLhV9AJD-bDAjAzfPL5r1GT8H4IY Bug: 1137788 Change-Id: If306e77bdaa66e34c28a633601608de307875c67
- Loading branch information
1 parent
50adeb0
commit 4448bdc
Showing
11 changed files
with
220 additions
and
70 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
native-io/capacity_allocation_sync_basic.tentative.https.any.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// META: title=NativeIO API: Acquiring, displaying and releasing capacity. | ||
// META: global=dedicatedworker | ||
|
||
'use strict'; | ||
|
||
test(testCase => { | ||
const available_capacity = storageFoundation.getRemainingCapacitySync(); | ||
assert_equals(available_capacity, 0); | ||
}, 'The starting capacity of a NativeIOFileManager is 0'); | ||
|
||
test(testCase => { | ||
const requested_capacity = 4; | ||
const granted_capacity = storageFoundation.requestCapacitySync(requested_capacity); | ||
const available_capacity = storageFoundation.getRemainingCapacitySync(); | ||
assert_equals(available_capacity, granted_capacity); | ||
testCase.add_cleanup(() => { | ||
storageFoundation.releaseCapacitySync(available_capacity); | ||
}); | ||
}, 'getRemainingCapacitySync() reports the capacity granted by ' + | ||
'requestCapacitySync()'); | ||
|
||
test(testCase => { | ||
const requested_capacity = 4; | ||
const granted_capacity = storageFoundation.requestCapacitySync(requested_capacity); | ||
storageFoundation.releaseCapacitySync(granted_capacity); | ||
const available_capacity = storageFoundation.getRemainingCapacitySync(); | ||
assert_equals(available_capacity, 0); | ||
}, 'getRemainingCapacitySync() reports zero after a releaseCapacitySync() ' + | ||
'matching the capacity granted by a requestCapacitySync().'); | ||
|
||
test(testCase => { | ||
const requested_capacity = 4; | ||
const granted_capacity = storageFoundation.requestCapacitySync(requested_capacity); | ||
assert_greater_than_equal(granted_capacity, requested_capacity); | ||
testCase.add_cleanup(() => { | ||
storageFoundation.releaseCapacitySync(granted_capacity); | ||
}); | ||
}, 'requestCapacitySync() grants the requested capacity for small requests'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
native-io/setLength_capacity_allocation_sync.tentative.https.any.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// META: title=NativeIO API: SetLength respects the allocated capacities. | ||
// META: global=dedicatedworker | ||
|
||
test(testCase => { | ||
const file = storageFoundation.openSync('test_file'); | ||
testCase.add_cleanup(() => { | ||
file.close(); | ||
storageFoundation.deleteSync('test_file'); | ||
}); | ||
assert_throws_dom('QuotaExceededError', () => {file.setLength(4)}); | ||
}, 'setLength() fails without any capacity request.'); | ||
|
||
test(testCase => { | ||
const file = storageFoundation.openSync('test_file'); | ||
|
||
const granted_capacity = storageFoundation.requestCapacitySync(4); | ||
assert_greater_than_equal(granted_capacity, 2); | ||
testCase.add_cleanup(() => { | ||
file.close(); | ||
storageFoundation.deleteSync('test_file'); | ||
storageFoundation.releaseCapacitySync(1); | ||
}); | ||
|
||
file.setLength(granted_capacity - 1); | ||
}, 'setLength() succeeds when given the granted capacity - 1'); | ||
|
||
test(testCase => { | ||
const file = storageFoundation.openSync('test_file'); | ||
|
||
const granted_capacity = storageFoundation.requestCapacitySync(4); | ||
assert_greater_than_equal(granted_capacity, 1); | ||
testCase.add_cleanup(() => { | ||
file.close(); | ||
storageFoundation.deleteSync('test_file'); | ||
}); | ||
|
||
file.setLength(granted_capacity); | ||
}, 'setLength() succeeds when given the granted capacity'); | ||
|
||
test(testCase => { | ||
const file = storageFoundation.openSync('test_file'); | ||
|
||
const granted_capacity = storageFoundation.requestCapacitySync(4); | ||
assert_greater_than_equal(granted_capacity, 0); | ||
testCase.add_cleanup(() => { | ||
file.close(); | ||
storageFoundation.deleteSync('test_file'); | ||
storageFoundation.releaseCapacitySync(granted_capacity); | ||
}); | ||
|
||
assert_throws_dom('QuotaExceededError', | ||
() => {file.setLength(granted_capacity + 1)}); | ||
}, 'setLength() fails when given the granted capacity + 1'); |
Oops, something went wrong.