-
Notifications
You must be signed in to change notification settings - Fork 938
Implement BundleCache for IDB and memory. #3170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
9602712
Renaming interfaces without leading I
wu-hui c5e783e
Initial commit of bundle reading - for web only.
wu-hui 5e7fb89
Tests only run when it is not Node.
wu-hui 1ee1615
Fix redundant imports
wu-hui 18f0be1
Fix missing textencoder
wu-hui aa455bf
Remove generator.
wu-hui 78248cd
Support bundle reader for Node
wu-hui 83160a1
Fix rebase errors.
wu-hui 24e10cb
Remote 'only'
wu-hui 9d6edc5
Merge branch 'wuandy/Bundles' into wuandy/BundleReaderNode
wu-hui 4cbe608
Merge branch 'wuandy/Bundles' into wuandy/BundleReaderNode
wu-hui 4313e51
Added more comments, and more tests for Node.
wu-hui 296cfc4
Implement BundleCache.
wu-hui de1d162
Address comments and remove hacking.
wu-hui 1775298
Drop custom reader type.
wu-hui f572812
Merge branch 'wuandy/BundleReaderNode' into wuandy/BundlePersistence
wu-hui 2dde827
Address comments.
wu-hui 6eafb6f
Remove validation and use assertion.
wu-hui a09a67f
Merge branch 'wuandy/BundleReaderNode' into wuandy/BundlePersistence
wu-hui 5b152df
Merge branch 'wuandy/Bundles' into wuandy/BundlePersistence
wu-hui 06e3e77
Address more comments.
wu-hui File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -18,7 +18,6 @@ | |
import { DatabaseId, DatabaseInfo } from '../core/database_info'; | ||
import { | ||
ByteStreamReader, | ||
ByteStreamReadResult, | ||
Platform, | ||
toByteStreamReader | ||
} from '../platform/platform'; | ||
|
@@ -30,6 +29,7 @@ import { NoopConnectivityMonitor } from '../remote/connectivity_monitor_noop'; | |
import { BrowserConnectivityMonitor } from './browser_connectivity_monitor'; | ||
import { WebChannelConnection } from './webchannel_connection'; | ||
import { debugAssert } from '../util/assert'; | ||
import { BundleSource } from '../util/bundle_reader'; | ||
|
||
// Implements the Platform API for browsers and some browser-like environments | ||
// (including ReactNative). | ||
|
@@ -103,28 +103,20 @@ export class BrowserPlatform implements Platform { | |
* On web, a `ReadableStream` is wrapped around by a `ByteStreamReader`. | ||
*/ | ||
toByteStreamReader( | ||
source: Uint8Array | ArrayBuffer | ReadableStream<Uint8Array> | ||
source: BundleSource, | ||
bytesPerRead: number | ||
): ByteStreamReader { | ||
if (source instanceof Uint8Array) { | ||
return toByteStreamReader(source); | ||
return toByteStreamReader(source, bytesPerRead); | ||
} | ||
if (source instanceof ArrayBuffer) { | ||
return toByteStreamReader(new Uint8Array(source)); | ||
return toByteStreamReader(new Uint8Array(source), bytesPerRead); | ||
} | ||
if (source instanceof ReadableStream) { | ||
const reader = source.getReader(); | ||
return new (class implements ByteStreamReader { | ||
read(): Promise<ByteStreamReadResult> { | ||
return reader.read(); | ||
} | ||
|
||
cancel(reason?: string): Promise<void> { | ||
return reader.cancel(reason); | ||
} | ||
})(); | ||
return source.getReader(); | ||
} | ||
throw new Error( | ||
'Source of `toByteStreamReader` has to be Uint8Array, ArrayBuffer or ReadableStream' | ||
'Source of `toByteStreamReader` has to be a ArrayBuffer or ReadableStream' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s/a/an/ |
||
); | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space before
(
.Your indent also seems slightly off. We usually indent by four spaces (not 6), but I do see some counterexamples in our sources (both 6 and 0 exists, but 6 is an outlier).