Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Unified Diff: extensions/common/crx_file.cc

Issue 15908002: Differential updates for components. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Sync to LKGR revision 207804. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/common/crx_file.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/common/crx_file.cc
diff --git a/extensions/common/crx_file.cc b/extensions/common/crx_file.cc
index 4f50962a5df65be3b789f4d95ac1dc0c2265e0f5..73e7f7b73d6b778f6f59286882726aa005ebf38b 100644
--- a/extensions/common/crx_file.cc
+++ b/extensions/common/crx_file.cc
@@ -11,6 +11,9 @@ namespace {
// The current version of the crx format.
static const uint32 kCurrentVersion = 2;
+// The current version of the crx diff format.
+static const uint32 kCurrentDiffVersion = 0;
+
// The maximum size the crx parser will tolerate for a public key.
static const uint32 kMaxPublicKeySize = 1 << 16;
@@ -21,6 +24,7 @@ static const uint32 kMaxSignatureSize = 1 << 16;
// The magic string embedded in the header.
const char kCrxFileHeaderMagic[] = "Cr24";
+const char kCrxDiffFileHeaderMagic[] = "CrOD";
scoped_ptr<CrxFile> CrxFile::Parse(const CrxFile::Header& header,
CrxFile::Error* error) {
@@ -45,12 +49,21 @@ scoped_ptr<CrxFile> CrxFile::Create(const uint32 key_size,
CrxFile::CrxFile(const Header& header) : header_(header) {
}
+bool CrxFile::HeaderIsDelta(const CrxFile::Header& header) {
+ return !strncmp(kCrxDiffFileHeaderMagic, header.magic, sizeof(header.magic));
+}
+
bool CrxFile::HeaderIsValid(const CrxFile::Header& header,
CrxFile::Error* error) {
bool valid = false;
- if (strncmp(kCrxFileHeaderMagic, header.magic, sizeof(header.magic)))
+ bool diffCrx = false;
+ if (!strncmp(kCrxDiffFileHeaderMagic, header.magic, sizeof(header.magic)))
+ diffCrx = true;
+ if (strncmp(kCrxFileHeaderMagic, header.magic, sizeof(header.magic)) &&
+ !diffCrx)
*error = kWrongMagic;
- else if (header.version != kCurrentVersion)
+ else if (header.version != kCurrentVersion
+ && !(diffCrx && header.version == kCurrentDiffVersion))
*error = kInvalidVersion;
else if (header.key_size > kMaxPublicKeySize)
*error = kInvalidKeyTooLarge;
« no previous file with comments | « extensions/common/crx_file.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698