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

Side by Side Diff: components/update_client/component_patcher.cc

Issue 808773005: Move most of the component updater artifacts to update_client. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "components/component_updater/component_patcher.h" 5 #include "components/update_client/component_patcher.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
14 #include "base/json/json_file_value_serializer.h" 14 #include "base/json/json_file_value_serializer.h"
15 #include "base/location.h" 15 #include "base/location.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "base/values.h" 17 #include "base/values.h"
18 #include "components/component_updater/component_patcher_operation.h" 18 #include "components/update_client/component_patcher_operation.h"
19 #include "components/component_updater/component_updater_service.h"
20 19
21 namespace component_updater { 20 namespace update_client {
22 21
23 namespace { 22 namespace {
24 23
25 // Deserialize the commands file (present in delta update packages). The top 24 // Deserialize the commands file (present in delta update packages). The top
26 // level must be a list. 25 // level must be a list.
27 base::ListValue* ReadCommands(const base::FilePath& unpack_path) { 26 base::ListValue* ReadCommands(const base::FilePath& unpack_path) {
28 const base::FilePath commands = 27 const base::FilePath commands =
29 unpack_path.Append(FILE_PATH_LITERAL("commands.json")); 28 unpack_path.Append(FILE_PATH_LITERAL("commands.json"));
30 if (!base::PathExists(commands)) 29 if (!base::PathExists(commands))
31 return NULL; 30 return NULL;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 std::string operation; 87 std::string operation;
89 if (command_args->GetString(kOp, &operation)) { 88 if (command_args->GetString(kOp, &operation)) {
90 current_operation_ = 89 current_operation_ =
91 CreateDeltaUpdateOp(operation, out_of_process_patcher_); 90 CreateDeltaUpdateOp(operation, out_of_process_patcher_);
92 } 91 }
93 92
94 if (!current_operation_.get()) { 93 if (!current_operation_.get()) {
95 DonePatching(ComponentUnpacker::kDeltaUnsupportedCommand, 0); 94 DonePatching(ComponentUnpacker::kDeltaUnsupportedCommand, 0);
96 return; 95 return;
97 } 96 }
98 current_operation_->Run(command_args, 97 current_operation_->Run(command_args, input_dir_, unpack_dir_, installer_,
99 input_dir_,
100 unpack_dir_,
101 installer_,
102 base::Bind(&ComponentPatcher::DonePatchingFile, 98 base::Bind(&ComponentPatcher::DonePatchingFile,
103 scoped_refptr<ComponentPatcher>(this)), 99 scoped_refptr<ComponentPatcher>(this)),
104 task_runner_); 100 task_runner_);
105 } 101 }
106 102
107 void ComponentPatcher::DonePatchingFile(ComponentUnpacker::Error error, 103 void ComponentPatcher::DonePatchingFile(ComponentUnpacker::Error error,
108 int extended_error) { 104 int extended_error) {
109 if (error != ComponentUnpacker::kNone) { 105 if (error != ComponentUnpacker::kNone) {
110 DonePatching(error, extended_error); 106 DonePatching(error, extended_error);
111 } else { 107 } else {
112 ++next_command_; 108 ++next_command_;
113 PatchNextFile(); 109 PatchNextFile();
114 } 110 }
115 } 111 }
116 112
117 void ComponentPatcher::DonePatching(ComponentUnpacker::Error error, 113 void ComponentPatcher::DonePatching(ComponentUnpacker::Error error,
118 int extended_error) { 114 int extended_error) {
119 current_operation_ = NULL; 115 current_operation_ = NULL;
120 task_runner_->PostTask(FROM_HERE, 116 task_runner_->PostTask(FROM_HERE,
121 base::Bind(callback_, error, extended_error)); 117 base::Bind(callback_, error, extended_error));
122 callback_.Reset(); 118 callback_.Reset();
123 } 119 }
124 120
125 } // namespace component_updater 121 } // namespace update_client
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698