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

Side by Side Diff: src/platform/update_engine/omaha_request_prep_action.cc

Issue 492008: AU: Try delta updates first, then full updates (Closed)
Patch Set: use mkstemp Created 11 years 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "update_engine/omaha_request_prep_action.h" 5 #include "update_engine/omaha_request_prep_action.h"
6 #include <sys/utsname.h> 6 #include <sys/utsname.h>
7 #include <errno.h> 7 #include <errno.h>
8 #include <string> 8 #include <string>
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "update_engine/utils.h" 10 #include "update_engine/utils.h"
11 11
12 using std::string; 12 using std::string;
13 13
14 // This gathers local system information and prepares info used by the 14 // This gathers local system information and prepares info used by the
15 // update check action. 15 // update check action.
16 16
17 namespace { 17 namespace {
18 const string OmahaIdPath() { 18 const string OmahaIdPath() {
19 return chromeos_update_engine::utils::kStatefulPartition + "/etc/omaha_id"; 19 return string(chromeos_update_engine::utils::kStatefulPartition) +
20 "/etc/omaha_id";
20 } 21 }
21 } // namespace {} 22 } // namespace {}
22 23
23 namespace chromeos_update_engine { 24 namespace chromeos_update_engine {
24 25
25 void OmahaRequestPrepAction::PerformAction() { 26 void OmahaRequestPrepAction::PerformAction() {
26 // TODO(adlr): honor force_full_update_ 27 // TODO(adlr): honor force_full_update_
27 ScopedActionCompleter completer(processor_, this); 28 ScopedActionCompleter completer(processor_, this);
28 string machine_id; 29 string machine_id;
29 TEST_AND_RETURN(GetMachineId(&machine_id)); 30 TEST_AND_RETURN(GetMachineId(&machine_id));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 bytes_read += rc; 83 bytes_read += rc;
83 } 84 }
84 string guid = GuidFromData(buf); 85 string guid = GuidFromData(buf);
85 TEST_AND_RETURN_FALSE( 86 TEST_AND_RETURN_FALSE(
86 utils::WriteFile(omaha_id_path.c_str(), guid.data(), guid.size())); 87 utils::WriteFile(omaha_id_path.c_str(), guid.data(), guid.size()));
87 *out_id = guid; 88 *out_id = guid;
88 return true; 89 return true;
89 } 90 }
90 91
91 std::string OmahaRequestPrepAction::GetLsbValue(const std::string& key) const { 92 std::string OmahaRequestPrepAction::GetLsbValue(const std::string& key) const {
92 string files[] = {utils::kStatefulPartition + "/etc/lsb-release", 93 string files[] = {string(utils::kStatefulPartition) + "/etc/lsb-release",
93 "/etc/lsb-release"}; 94 "/etc/lsb-release"};
94 for (unsigned int i = 0; i < arraysize(files); i++) { 95 for (unsigned int i = 0; i < arraysize(files); i++) {
95 string file_data; 96 string file_data;
96 if (!utils::ReadFileToString(root_ + files[i], &file_data)) 97 if (!utils::ReadFileToString(root_ + files[i], &file_data))
97 continue; 98 continue;
98 string::size_type pos = 0; 99 string::size_type pos = 0;
99 if (!utils::StringHasPrefix(file_data, key + "=")) { 100 if (!utils::StringHasPrefix(file_data, key + "=")) {
100 pos = file_data.find(string("\n") + key + "="); 101 pos = file_data.find(string("\n") + key + "=");
101 if (pos != string::npos) 102 if (pos != string::npos)
102 pos++; // advance past \n 103 pos++; // advance past \n
(...skipping 12 matching lines...) Expand all
115 116
116 std::string OmahaRequestPrepAction::GetMachineType() const { 117 std::string OmahaRequestPrepAction::GetMachineType() const {
117 struct utsname buf; 118 struct utsname buf;
118 string ret; 119 string ret;
119 if (uname(&buf) == 0) 120 if (uname(&buf) == 0)
120 ret = buf.machine; 121 ret = buf.machine;
121 return ret; 122 return ret;
122 } 123 }
123 124
124 } // namespace chromeos_update_engine 125 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « src/platform/update_engine/main.cc ('k') | src/platform/update_engine/omaha_response_handler_action.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698