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

Side by Side Diff: omaha_request_action.cc

Issue 6677146: AU: OmahaRequestAction: allow to be skipped. (Closed) Base URL: http://git.chromium.org/git/update_engine.git@master
Patch Set: fix include "" vs <> Created 9 years, 8 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 | « omaha_request_action.h ('k') | omaha_request_action_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) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 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/omaha_request_action.h" 5 #include "update_engine/omaha_request_action.h"
6 6
7 #include <inttypes.h> 7 #include <inttypes.h>
8 8
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 172
173 OmahaRequestAction::OmahaRequestAction(PrefsInterface* prefs, 173 OmahaRequestAction::OmahaRequestAction(PrefsInterface* prefs,
174 const OmahaRequestParams& params, 174 const OmahaRequestParams& params,
175 OmahaEvent* event, 175 OmahaEvent* event,
176 HttpFetcher* http_fetcher) 176 HttpFetcher* http_fetcher)
177 : prefs_(prefs), 177 : prefs_(prefs),
178 params_(params), 178 params_(params),
179 event_(event), 179 event_(event),
180 http_fetcher_(http_fetcher), 180 http_fetcher_(http_fetcher),
181 ping_active_days_(0), 181 ping_active_days_(0),
182 ping_roll_call_days_(0) {} 182 ping_roll_call_days_(0),
183 should_skip_(false) {}
183 184
184 OmahaRequestAction::~OmahaRequestAction() {} 185 OmahaRequestAction::~OmahaRequestAction() {}
185 186
186 // Calculates the value to use for the ping days parameter. 187 // Calculates the value to use for the ping days parameter.
187 int OmahaRequestAction::CalculatePingDays(const string& key) { 188 int OmahaRequestAction::CalculatePingDays(const string& key) {
188 int days = kNeverPinged; 189 int days = kNeverPinged;
189 int64_t last_ping = 0; 190 int64_t last_ping = 0;
190 if (prefs_->GetInt64(key, &last_ping) && last_ping >= 0) { 191 if (prefs_->GetInt64(key, &last_ping) && last_ping >= 0) {
191 days = (Time::Now() - Time::FromInternalValue(last_ping)).InDays(); 192 days = (Time::Now() - Time::FromInternalValue(last_ping)).InDays();
192 if (days < 0) { 193 if (days < 0) {
(...skipping 16 matching lines...) Expand all
209 return; 210 return;
210 } 211 }
211 // TODO(petkov): Figure a way to distinguish active use pings 212 // TODO(petkov): Figure a way to distinguish active use pings
212 // vs. roll call pings. Currently, the two pings are identical. A 213 // vs. roll call pings. Currently, the two pings are identical. A
213 // fix needs to change this code as well as UpdateLastPingDays. 214 // fix needs to change this code as well as UpdateLastPingDays.
214 ping_active_days_ = CalculatePingDays(kPrefsLastActivePingDay); 215 ping_active_days_ = CalculatePingDays(kPrefsLastActivePingDay);
215 ping_roll_call_days_ = CalculatePingDays(kPrefsLastRollCallPingDay); 216 ping_roll_call_days_ = CalculatePingDays(kPrefsLastRollCallPingDay);
216 } 217 }
217 218
218 void OmahaRequestAction::PerformAction() { 219 void OmahaRequestAction::PerformAction() {
220 if (should_skip_) {
221 processor_->ActionComplete(this, kActionCodeSuccess);
222 return;
223 }
219 http_fetcher_->set_delegate(this); 224 http_fetcher_->set_delegate(this);
220 InitPingDays(); 225 InitPingDays();
221 string request_post(FormatRequest(event_.get(), 226 string request_post(FormatRequest(event_.get(),
222 params_, 227 params_,
223 ping_active_days_, 228 ping_active_days_,
224 ping_roll_call_days_, 229 ping_roll_call_days_,
225 prefs_)); 230 prefs_));
226 http_fetcher_->SetPostData(request_post.data(), request_post.size()); 231 http_fetcher_->SetPostData(request_post.data(), request_post.size());
227 LOG(INFO) << "Posting an Omaha request to " << params_.update_url; 232 LOG(INFO) << "Posting an Omaha request to " << params_.update_url;
228 LOG(INFO) << "Request: " << request_post; 233 LOG(INFO) << "Request: " << request_post;
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 output_object.needs_admin = 458 output_object.needs_admin =
454 XmlGetProperty(updatecheck_node, "needsadmin") == "true"; 459 XmlGetProperty(updatecheck_node, "needsadmin") == "true";
455 output_object.prompt = XmlGetProperty(updatecheck_node, "Prompt") == "true"; 460 output_object.prompt = XmlGetProperty(updatecheck_node, "Prompt") == "true";
456 output_object.is_delta = 461 output_object.is_delta =
457 XmlGetProperty(updatecheck_node, "IsDelta") == "true"; 462 XmlGetProperty(updatecheck_node, "IsDelta") == "true";
458 output_object.deadline = XmlGetProperty(updatecheck_node, "deadline"); 463 output_object.deadline = XmlGetProperty(updatecheck_node, "deadline");
459 SetOutputObject(output_object); 464 SetOutputObject(output_object);
460 } 465 }
461 466
462 }; // namespace chromeos_update_engine 467 }; // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « omaha_request_action.h ('k') | omaha_request_action_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698