Fix C++ data pack writer.
Most data pak files are generated at build time using a Python script (see tools/grit/grit/format/data_pak.py), but the C++ data pack writer can also be used at runtime by the ThemeService (see ThemeService::SetTheme()). The Python pak writer was recently changed to support version 5 of the format that introduces a resource alias table to reduce the size of the final pak files, in the case of resource data duplication. This is mostly important for localized strings paks. While the C++ data pack reader and writer were updated to support this new format, the WritePack() method didn't try to find resource duplicates and build an appropriate alias table. This CL fixes the C++ writer, to detect resource data duplication and build an appropriate alias table when it is detected. After this patch, both the Python and C++ code should behave identically. + Fix slightly misleading comment documenting the header formats (using uint instead of int values in the description, the code is already correct). + Use ScopedFileWriter convenience class to simplify error handling and cleanup. + Use for '(const auto& item : collection)' to simplify scanning over maps. + Add a sanity check to fail if there are more than 2^16 resources to write (since the format only supports up to 65536 resources per pak file). BUG=None R=agrieve@chromium.org,asvitkine@chromium.org,sadrul@chromium.org Change-Id: Ic04eb68558026ff48835ed0e9e44ba539b3a52a8 Reviewed-on: https://chromium-review.googlesource.com/737636Reviewed-by:Alexei Svitkine <asvitkine@chromium.org> Reviewed-by:
Robert Flack <flackr@chromium.org> Reviewed-by:
Sadrul Chowdhury <sadrul@chromium.org> Reviewed-by:
agrieve <agrieve@chromium.org> Commit-Queue: David Turner <digit@chromium.org> Cr-Commit-Position: refs/heads/master@{#516316}
Showing
This diff is collapsed.
Please register or sign in to comment