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

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

Issue 2835803002: Refactor the UpdateEngine and its actions in the component updater. (Closed)
Patch Set: feedback up to #6 Created 3 years, 7 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
« no previous file with comments | « components/update_client/utils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/update_client/utils.h" 5 #include "components/update_client/utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
11 #include <cmath> 11 #include <cmath>
12 #include <cstring> 12 #include <cstring>
13 #include <map> 13 #include <map>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/callback.h" 16 #include "base/callback.h"
17 #include "base/files/file_path.h" 17 #include "base/files/file_path.h"
18 #include "base/files/file_util.h" 18 #include "base/files/file_util.h"
19 #include "base/files/memory_mapped_file.h" 19 #include "base/files/memory_mapped_file.h"
20 #include "base/guid.h" 20 #include "base/guid.h"
21 #include "base/strings/string_number_conversions.h" 21 #include "base/strings/string_number_conversions.h"
22 #include "base/strings/string_piece.h" 22 #include "base/strings/string_piece.h"
23 #include "base/strings/string_util.h" 23 #include "base/strings/string_util.h"
24 #include "base/strings/stringprintf.h" 24 #include "base/strings/stringprintf.h"
25 #include "base/sys_info.h" 25 #include "base/sys_info.h"
26 #include "build/build_config.h" 26 #include "build/build_config.h"
27 #include "components/crx_file/id_util.h" 27 #include "components/crx_file/id_util.h"
28 #include "components/data_use_measurement/core/data_use_user_data.h" 28 #include "components/data_use_measurement/core/data_use_user_data.h"
29 #include "components/update_client/component.h"
29 #include "components/update_client/configurator.h" 30 #include "components/update_client/configurator.h"
30 #include "components/update_client/crx_update_item.h" 31 #include "components/update_client/crx_update_item.h"
31 #include "components/update_client/update_client.h" 32 #include "components/update_client/update_client.h"
32 #include "components/update_client/update_client_errors.h" 33 #include "components/update_client/update_client_errors.h"
33 #include "components/update_client/update_query_params.h" 34 #include "components/update_client/update_query_params.h"
34 #include "components/update_client/updater_state.h" 35 #include "components/update_client/updater_state.h"
35 #include "crypto/secure_hash.h" 36 #include "crypto/secure_hash.h"
36 #include "crypto/sha2.h" 37 #include "crypto/sha2.h"
37 #include "net/base/load_flags.h" 38 #include "net/base/load_flags.h"
38 #include "net/url_request/url_fetcher.h" 39 #include "net/url_request/url_fetcher.h"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 // Network errors are small negative numbers. 232 // Network errors are small negative numbers.
232 const int error = fetcher.GetStatus().error(); 233 const int error = fetcher.GetStatus().error();
233 return error ? error : -1; 234 return error ? error : -1;
234 } 235 }
235 236
236 default: 237 default:
237 return -1; 238 return -1;
238 } 239 }
239 } 240 }
240 241
241 bool HasDiffUpdate(const CrxUpdateItem* update_item) { 242 bool HasDiffUpdate(const Component& component) {
242 return !update_item->crx_diffurls.empty(); 243 return !component.crx_diffurls().empty();
243 } 244 }
244 245
245 bool IsHttpServerError(int status_code) { 246 bool IsHttpServerError(int status_code) {
246 return 500 <= status_code && status_code < 600; 247 return 500 <= status_code && status_code < 600;
247 } 248 }
248 249
249 bool DeleteFileAndEmptyParentDirectory(const base::FilePath& filepath) { 250 bool DeleteFileAndEmptyParentDirectory(const base::FilePath& filepath) {
250 if (!base::DeleteFile(filepath, false)) 251 if (!base::DeleteFile(filepath, false))
251 return false; 252 return false;
252 253
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 [](const GURL& url) { return !url.SchemeIsCryptographic(); }), 341 [](const GURL& url) { return !url.SchemeIsCryptographic(); }),
341 urls->end()); 342 urls->end());
342 } 343 }
343 344
344 CrxInstaller::Result InstallFunctionWrapper(base::Callback<bool()> callback) { 345 CrxInstaller::Result InstallFunctionWrapper(base::Callback<bool()> callback) {
345 return CrxInstaller::Result(callback.Run() ? InstallError::NONE 346 return CrxInstaller::Result(callback.Run() ? InstallError::NONE
346 : InstallError::GENERIC_ERROR); 347 : InstallError::GENERIC_ERROR);
347 } 348 }
348 349
349 } // namespace update_client 350 } // namespace update_client
OLDNEW
« no previous file with comments | « components/update_client/utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698