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

Side by Side Diff: chrome/browser/component_updater/component_unpacker.h

Issue 25883006: Support asynchronous patching operations in the component updater. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tests
Patch Set: New LKGR, Windows fixes. Created 7 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UNPACKER_H_ 5 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UNPACKER_H_
6 #define CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UNPACKER_H_ 6 #define CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UNPACKER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 #include "base/basictypes.h" 10 #include "base/callback.h"
11 #include "base/files/file_path.h"
12 11
13 class ComponentInstaller; 12 class ComponentInstaller;
14 class ComponentPatcher; 13 class ComponentPatcher;
15 14
16 // In charge of unpacking the component CRX package and verifying that it is 15 namespace base {
17 // well formed and the cryptographic signature is correct. If there is no 16 class FilePath;
18 // error the component specific installer will be invoked to proceed with 17 }
19 // the component installation or update.
20 //
21 // This class should be used only by the component updater. It is inspired
22 // and overlaps with code in the extension's SandboxedUnpacker.
23 // The main differences are:
24 // - The public key hash is full SHA256.
25 // - Does not use a sandboxed unpacker. A valid component is fully trusted.
26 // - The manifest can have different attributes and resources are not
27 // transcoded.
28 class ComponentUnpacker {
29 public:
30 // Possible error conditions.
31 // Add only to the bottom of this enum; the order must be kept stable.
32 enum Error {
33 kNone,
34 kInvalidParams,
35 kInvalidFile,
36 kUnzipPathError,
37 kUnzipFailed,
38 kNoManifest,
39 kBadManifest,
40 kBadExtension,
41 kInvalidId,
42 kInstallerError,
43 kIoError,
44 kDeltaVerificationFailure,
45 kDeltaBadCommands,
46 kDeltaUnsupportedCommand,
47 kDeltaOperationFailure,
48 kDeltaPatchProcessFailure,
49 kDeltaMissingExistingFile,
50 kFingerprintWriteFailed,
51 };
52 // Unpacks, verifies and calls the installer. |pk_hash| is the expected
53 // public key SHA256 hash. |path| is the current location of the CRX.
54 ComponentUnpacker(const std::vector<uint8>& pk_hash,
55 const base::FilePath& path,
56 const std::string& fingerprint,
57 ComponentPatcher* patcher,
58 ComponentInstaller* installer);
59 18
60 // If something went wrong during unpacking or installer invocation, the 19 namespace component_updater {
61 // destructor will delete the unpacked CRX files.
62 ~ComponentUnpacker();
63 20
64 Error error() const { return error_; } 21 // Possible error conditions.
65 22 // Add only to the bottom of this enum; the order must be kept stable.
66 int extended_error() const { return extended_error_; } 23 enum Error {
67 24 kNone,
68 private: 25 kInvalidParams,
69 base::FilePath unpack_path_; 26 kInvalidFile,
70 Error error_; 27 kUnzipPathError,
71 int extended_error_; // Provides additional error information. 28 kUnzipFailed,
29 kNoManifest,
30 kBadManifest,
31 kBadExtension,
32 kInvalidId,
33 kInstallerError,
34 kIoError,
35 kDeltaVerificationFailure,
36 kDeltaBadCommands,
37 kDeltaUnsupportedCommand,
38 kDeltaOperationFailure,
39 kDeltaPatchProcessFailure,
40 kDeltaMissingExistingFile,
41 kFingerprintWriteFailed,
72 }; 42 };
73 43
44 // Asynchronously unpacks, verifies and calls the installer. |pk_hash| is
45 // the expected public key SHA256 hash. |path| is the current location of
46 // the CRX. When done, runs |callback| with the error and extra error code.
47 // The callback will be run on the FILE thread.
48 void Unpack(const std::vector<uint8>& pk_hash,
49 const base::FilePath& path,
50 const std::string& fingerprint,
51 ComponentPatcher* patcher,
52 ComponentInstaller* installer,
53 const base::Callback<void(Error, int)>& callback);
54
55 } // namespace component_updater
74 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UNPACKER_H_ 56 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UNPACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698