Index: chrome/browser/component_updater/component_patcher_operation.h |
diff --git a/chrome/browser/component_updater/component_patcher_operation.h b/chrome/browser/component_updater/component_patcher_operation.h |
index 3a1b6cfb6d1f087c88356fdeb64121a6e7be751e..ed52f68705d24d27c93b4d11aba590045c01e0af 100644 |
--- a/chrome/browser/component_updater/component_patcher_operation.h |
+++ b/chrome/browser/component_updater/component_patcher_operation.h |
@@ -12,9 +12,7 @@ |
#include "base/compiler_specific.h" |
#include "base/files/file_path.h" |
#include "base/memory/ref_counted.h" |
-#include "chrome/browser/component_updater/component_patcher.h" |
#include "chrome/browser/component_updater/component_unpacker.h" |
-#include "content/public/browser/utility_process_host_client.h" |
namespace base { |
class DictionaryValue; |
@@ -22,6 +20,16 @@ class DictionaryValue; |
namespace component_updater { |
+const char kOp[] = "op"; |
+const char kBsdiff[] = "bsdiff"; |
+const char kCourgette[] = "courgette"; |
+const char kInput[] = "input"; |
+const char kPatch[] = "patch"; |
+ |
+// The integer offset disambiguates between overlapping error ranges. |
+const int kCourgetteErrorOffset = 300; |
+const int kBsdiffErrorOffset = 600; |
+ |
class ComponentInstaller; |
class DeltaUpdateOp : public base::RefCountedThreadSafe<DeltaUpdateOp> { |
@@ -34,15 +42,12 @@ class DeltaUpdateOp : public base::RefCountedThreadSafe<DeltaUpdateOp> { |
const base::FilePath& input_dir, |
const base::FilePath& unpack_dir, |
ComponentInstaller* installer, |
- bool in_process, |
const ComponentUnpacker::Callback& callback, |
scoped_refptr<base::SequencedTaskRunner> task_runner); |
protected: |
virtual ~DeltaUpdateOp(); |
- bool InProcess(); |
- |
scoped_refptr<base::SequencedTaskRunner> GetTaskRunner(); |
std::string output_sha256_; |
@@ -71,7 +76,6 @@ class DeltaUpdateOp : public base::RefCountedThreadSafe<DeltaUpdateOp> { |
// callback. |
void DoneRunning(ComponentUnpacker::Error error, int extended_error); |
- bool in_process_; |
ComponentUnpacker::Callback callback_; |
scoped_refptr<base::SequencedTaskRunner> task_runner_; |
@@ -125,66 +129,16 @@ class DeltaUpdateOpCreate : public DeltaUpdateOp { |
DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOpCreate); |
}; |
-class DeltaUpdateOpPatchStrategy { |
- public: |
- virtual ~DeltaUpdateOpPatchStrategy(); |
- |
- // Returns an integer to add to error codes to disambiguate their source. |
- virtual int GetErrorOffset() const = 0; |
- |
- // Returns the "error code" that is expected in the successful install case. |
- virtual int GetSuccessCode() const = 0; |
- |
- // Returns an IPC message that will start patching if it is sent to a |
- // UtilityProcessClient. |
- virtual scoped_ptr<IPC::Message> GetPatchMessage( |
- base::FilePath input_abs_path, |
- base::FilePath patch_abs_path, |
- base::FilePath output_abs_path) = 0; |
- |
- // Does the actual patching operation, and returns an error code. |
- virtual int Patch(base::FilePath input_abs_path, |
- base::FilePath patch_abs_path, |
- base::FilePath output_abs_path) = 0; |
-}; |
- |
-class DeltaUpdateOpPatch; |
- |
-class DeltaUpdateOpPatchHost : public content::UtilityProcessHostClient { |
- public: |
- DeltaUpdateOpPatchHost(scoped_refptr<DeltaUpdateOpPatch> patcher, |
- scoped_refptr<base::SequencedTaskRunner> task_runner); |
- |
- void StartProcess(scoped_ptr<IPC::Message> message); |
- |
- private: |
- virtual ~DeltaUpdateOpPatchHost(); |
- |
- void OnPatchSucceeded(); |
- |
- void OnPatchFailed(int error_code); |
- |
- // Overrides of content::UtilityProcessHostClient. |
- virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
- |
- virtual void OnProcessCrashed(int exit_code) OVERRIDE; |
- |
- scoped_refptr<DeltaUpdateOpPatch> patcher_; |
- scoped_refptr<base::SequencedTaskRunner> task_runner_; |
-}; |
- |
// Both 'bsdiff' and 'courgette' operations take an existing file on disk, |
// and a bsdiff- or Courgette-format patch file provided in the delta update |
// package, and run bsdiff or Courgette to construct an output file in the |
// unpacking directory. |
-class DeltaUpdateOpPatch : public DeltaUpdateOp { |
+class DeltaUpdateOpPatchInProcess : public DeltaUpdateOp { |
public: |
- explicit DeltaUpdateOpPatch(scoped_ptr<DeltaUpdateOpPatchStrategy> strategy); |
- |
- void DonePatching(ComponentUnpacker::Error error, int error_code); |
+ explicit DeltaUpdateOpPatchInProcess(const std::string& operation); |
private: |
- virtual ~DeltaUpdateOpPatch(); |
+ virtual ~DeltaUpdateOpPatchInProcess(); |
// Overrides of DeltaUpdateOp. |
virtual ComponentUnpacker::Error DoParseArguments( |
@@ -194,19 +148,25 @@ class DeltaUpdateOpPatch : public DeltaUpdateOp { |
virtual void DoRun(const ComponentUnpacker::Callback& callback) OVERRIDE; |
- ComponentUnpacker::Callback callback_; |
+ std::string operation_; |
base::FilePath patch_abs_path_; |
base::FilePath input_abs_path_; |
- scoped_ptr<DeltaUpdateOpPatchStrategy> strategy_; |
- scoped_refptr<DeltaUpdateOpPatchHost> host_; |
- DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOpPatch); |
+ DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOpPatchInProcess); |
}; |
-// Factory functions to create DeltaUpdateOp instances. |
-DeltaUpdateOp* CreateDeltaUpdateOp(const base::DictionaryValue& command); |
+// Factory class for DeltaUpdateOp. |
+class DeltaUpdateOpFactory { |
+ public: |
+ virtual ~DeltaUpdateOpFactory(); |
+ |
+ // Create a DeltaUpdateOp for |operation|. |
+ virtual DeltaUpdateOp* CreateDeltaUpdateOp( |
+ const std::string& operation) const = 0; |
+}; |
-DeltaUpdateOp* CreateDeltaUpdateOp(const std::string& operation); |
+// Creates an in-process DeltaUpdateOpFactory. |
+DeltaUpdateOpFactory* CreateInProcessDeltaUpdateOpFactory(); |
} // namespace component_updater |