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

Side by Side Diff: utils.cc

Issue 3173041: Add 10 minute random fuzz to automatic update check event schedule. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: review comments Created 10 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « utils.h ('k') | utils_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium OS 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 "update_engine/utils.h" 5 #include "update_engine/utils.h"
6 6
7 #include <sys/mount.h> 7 #include <sys/mount.h>
8 #include <sys/resource.h> 8 #include <sys/resource.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
11 #include <dirent.h> 11 #include <dirent.h>
12 #include <errno.h> 12 #include <errno.h>
13 #include <fcntl.h> 13 #include <fcntl.h>
14 #include <stdio.h> 14 #include <stdio.h>
15 #include <stdlib.h> 15 #include <stdlib.h>
16 #include <string.h> 16 #include <string.h>
17 #include <unistd.h> 17 #include <unistd.h>
18 18
19 #include <algorithm> 19 #include <algorithm>
20 20
21 #include "base/file_path.h" 21 #include "base/file_path.h"
22 #include "base/file_util.h" 22 #include "base/file_util.h"
23 #include "base/rand_util.h"
23 #include "base/string_util.h" 24 #include "base/string_util.h"
24 #include "base/logging.h" 25 #include "base/logging.h"
25 #include "update_engine/file_writer.h" 26 #include "update_engine/file_writer.h"
26 #include "update_engine/omaha_request_params.h" 27 #include "update_engine/omaha_request_params.h"
27 #include "update_engine/subprocess.h" 28 #include "update_engine/subprocess.h"
28 29
29 using std::min; 30 using std::min;
30 using std::string; 31 using std::string;
31 using std::vector; 32 using std::vector;
32 33
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 LOG(INFO) << "Setting process priority to " << prio; 451 LOG(INFO) << "Setting process priority to " << prio;
451 TEST_AND_RETURN_FALSE(setpriority(PRIO_PROCESS, 0, prio) == 0); 452 TEST_AND_RETURN_FALSE(setpriority(PRIO_PROCESS, 0, prio) == 0);
452 return true; 453 return true;
453 } 454 }
454 455
455 int ComparePriorities(ProcessPriority priority_lhs, 456 int ComparePriorities(ProcessPriority priority_lhs,
456 ProcessPriority priority_rhs) { 457 ProcessPriority priority_rhs) {
457 return static_cast<int>(priority_rhs) - static_cast<int>(priority_lhs); 458 return static_cast<int>(priority_rhs) - static_cast<int>(priority_lhs);
458 } 459 }
459 460
461 int FuzzInt(int value, unsigned int range) {
462 int min = value - range / 2;
463 int max = value + range - range / 2;
464 return base::RandInt(min, max);
465 }
466
460 const char* const kStatefulPartition = "/mnt/stateful_partition"; 467 const char* const kStatefulPartition = "/mnt/stateful_partition";
461 468
462 } // namespace utils 469 } // namespace utils
463 470
464 } // namespace chromeos_update_engine 471 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « utils.h ('k') | utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698