summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorsorin@chromium.org <sorin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-21 20:41:36 +0000
committersorin@chromium.org <sorin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-21 20:41:36 +0000
commite3e696d3e883f38577252e1a1a6a98ae89dea079 (patch)
treeb5adbe01ec71c10c5f2d37bff9161acc40da2455 /extensions
parent0ad74fd43800b179bc3d50847f695d4a902c79ca (diff)
downloadchromium_src-e3e696d3e883f38577252e1a1a6a98ae89dea079.zip
chromium_src-e3e696d3e883f38577252e1a1a6a98ae89dea079.tar.gz
chromium_src-e3e696d3e883f38577252e1a1a6a98ae89dea079.tar.bz2
Differential updates for components. We are adding support for delivering delta updates for Chrome components. Initial platform support for the patcher is Windows only. The update response includes both the full update and, if available, the differential update. The differential update is tried first, then the full update, if needed.
BUG=245318 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=207805 Review URL: https://chromiumcodereview.appspot.com/15908002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207917 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions')
-rw-r--r--extensions/common/crx_file.cc17
-rw-r--r--extensions/common/crx_file.h4
2 files changed, 19 insertions, 2 deletions
diff --git a/extensions/common/crx_file.cc b/extensions/common/crx_file.cc
index 4f50962..73e7f7b 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;
diff --git a/extensions/common/crx_file.h b/extensions/common/crx_file.h
index cb450af..3ac8189 100644
--- a/extensions/common/crx_file.h
+++ b/extensions/common/crx_file.h
@@ -60,6 +60,10 @@ class CrxFile {
// Returns the header structure for writing out to a CRX file.
const Header& header() const { return header_; }
+ // Checks a valid |header| to determine whether or not the CRX represents a
+ // differential CRX.
+ static bool HeaderIsDelta(const Header& header);
+
private:
Header header_;