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

Side by Side Diff: update_attempter.cc

Issue 5835004: AU: MultiHttpFetcher cleanup/rewrite (Closed) Base URL: http://git.chromium.org/git/update_engine.git@master
Patch Set: fixes for review/merge latest trunk Created 10 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 | Annotate | Revision Log
« no previous file with comments | « multi_range_http_fetcher.cc ('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 (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/update_attempter.h" 5 #include "update_engine/update_attempter.h"
6 6
7 // From 'man clock_gettime': feature test macro: _POSIX_C_SOURCE >= 199309L 7 // From 'man clock_gettime': feature test macro: _POSIX_C_SOURCE >= 199309L
8 #ifndef _POSIX_C_SOURCE 8 #ifndef _POSIX_C_SOURCE
9 #define _POSIX_C_SOURCE 199309L 9 #define _POSIX_C_SOURCE 199309L
10 #endif // _POSIX_C_SOURCE 10 #endif // _POSIX_C_SOURCE
11 #include <time.h> 11 #include <time.h>
12 12
13 #include <string> 13 #include <string>
14 #include <tr1/memory> 14 #include <tr1/memory>
15 #include <vector> 15 #include <vector>
16 16
17 #include <base/rand_util.h> 17 #include <base/rand_util.h>
18 #include <glib.h> 18 #include <glib.h>
19 #include <metrics/metrics_library.h> 19 #include <metrics/metrics_library.h>
20 20
21 #include "update_engine/dbus_service.h" 21 #include "update_engine/dbus_service.h"
22 #include "update_engine/download_action.h" 22 #include "update_engine/download_action.h"
23 #include "update_engine/filesystem_copier_action.h" 23 #include "update_engine/filesystem_copier_action.h"
24 #include "update_engine/libcurl_http_fetcher.h" 24 #include "update_engine/libcurl_http_fetcher.h"
25 #include "update_engine/multi_http_fetcher.h" 25 #include "update_engine/multi_range_http_fetcher.h"
26 #include "update_engine/omaha_request_action.h" 26 #include "update_engine/omaha_request_action.h"
27 #include "update_engine/omaha_request_params.h" 27 #include "update_engine/omaha_request_params.h"
28 #include "update_engine/omaha_response_handler_action.h" 28 #include "update_engine/omaha_response_handler_action.h"
29 #include "update_engine/postinstall_runner_action.h" 29 #include "update_engine/postinstall_runner_action.h"
30 #include "update_engine/prefs_interface.h" 30 #include "update_engine/prefs_interface.h"
31 #include "update_engine/update_check_scheduler.h" 31 #include "update_engine/update_check_scheduler.h"
32 32
33 using base::TimeDelta; 33 using base::TimeDelta;
34 using base::TimeTicks; 34 using base::TimeTicks;
35 using std::make_pair; 35 using std::make_pair;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 new FilesystemCopierAction(false, false)); 178 new FilesystemCopierAction(false, false));
179 shared_ptr<FilesystemCopierAction> kernel_filesystem_copier_action( 179 shared_ptr<FilesystemCopierAction> kernel_filesystem_copier_action(
180 new FilesystemCopierAction(true, false)); 180 new FilesystemCopierAction(true, false));
181 shared_ptr<OmahaRequestAction> download_started_action( 181 shared_ptr<OmahaRequestAction> download_started_action(
182 new OmahaRequestAction(prefs_, 182 new OmahaRequestAction(prefs_,
183 omaha_request_params_, 183 omaha_request_params_,
184 new OmahaEvent( 184 new OmahaEvent(
185 OmahaEvent::kTypeUpdateDownloadStarted), 185 OmahaEvent::kTypeUpdateDownloadStarted),
186 new LibcurlHttpFetcher(GetProxyResolver()))); 186 new LibcurlHttpFetcher(GetProxyResolver())));
187 shared_ptr<DownloadAction> download_action( 187 shared_ptr<DownloadAction> download_action(
188 new DownloadAction(prefs_, new MultiHttpFetcher<LibcurlHttpFetcher>( 188 new DownloadAction(prefs_, new MultiRangeHTTPFetcher(
189 GetProxyResolver()))); 189 new LibcurlHttpFetcher(GetProxyResolver()))));
190 shared_ptr<OmahaRequestAction> download_finished_action( 190 shared_ptr<OmahaRequestAction> download_finished_action(
191 new OmahaRequestAction(prefs_, 191 new OmahaRequestAction(prefs_,
192 omaha_request_params_, 192 omaha_request_params_,
193 new OmahaEvent( 193 new OmahaEvent(
194 OmahaEvent::kTypeUpdateDownloadFinished), 194 OmahaEvent::kTypeUpdateDownloadFinished),
195 new LibcurlHttpFetcher(GetProxyResolver()))); 195 new LibcurlHttpFetcher(GetProxyResolver())));
196 shared_ptr<FilesystemCopierAction> filesystem_verifier_action( 196 shared_ptr<FilesystemCopierAction> filesystem_verifier_action(
197 new FilesystemCopierAction(false, true)); 197 new FilesystemCopierAction(false, true));
198 shared_ptr<FilesystemCopierAction> kernel_filesystem_verifier_action( 198 shared_ptr<FilesystemCopierAction> kernel_filesystem_verifier_action(
199 new FilesystemCopierAction(true, true)); 199 new FilesystemCopierAction(true, true));
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 DeltaPerformer::ResetUpdateProgress(prefs_, false); 547 DeltaPerformer::ResetUpdateProgress(prefs_, false);
548 int64_t delta_failures; 548 int64_t delta_failures;
549 if (!prefs_->GetInt64(kPrefsDeltaUpdateFailures, &delta_failures) || 549 if (!prefs_->GetInt64(kPrefsDeltaUpdateFailures, &delta_failures) ||
550 delta_failures < 0) { 550 delta_failures < 0) {
551 delta_failures = 0; 551 delta_failures = 0;
552 } 552 }
553 prefs_->SetInt64(kPrefsDeltaUpdateFailures, ++delta_failures); 553 prefs_->SetInt64(kPrefsDeltaUpdateFailures, ++delta_failures);
554 } 554 }
555 555
556 void UpdateAttempter::SetupDownload() { 556 void UpdateAttempter::SetupDownload() {
557 MultiHttpFetcher<LibcurlHttpFetcher>* fetcher = 557 MultiRangeHTTPFetcher* fetcher =
558 dynamic_cast<MultiHttpFetcher<LibcurlHttpFetcher>*>( 558 dynamic_cast<MultiRangeHTTPFetcher*>(download_action_->http_fetcher());
559 download_action_->http_fetcher()); 559 fetcher->ClearRanges();
560 MultiHttpFetcher<LibcurlHttpFetcher>::RangesVect ranges;
561 if (response_handler_action_->install_plan().is_resume) { 560 if (response_handler_action_->install_plan().is_resume) {
562 // Resuming an update so fetch the update manifest metadata first. 561 // Resuming an update so fetch the update manifest metadata first.
563 int64_t manifest_metadata_size = 0; 562 int64_t manifest_metadata_size = 0;
564 prefs_->GetInt64(kPrefsManifestMetadataSize, &manifest_metadata_size); 563 prefs_->GetInt64(kPrefsManifestMetadataSize, &manifest_metadata_size);
565 ranges.push_back(make_pair(0, manifest_metadata_size)); 564 fetcher->AddRange(0, manifest_metadata_size);
566 // If there're remaining unprocessed data blobs, fetch them. Be careful not 565 // If there're remaining unprocessed data blobs, fetch them. Be careful not
567 // to request data beyond the end of the payload to avoid 416 HTTP response 566 // to request data beyond the end of the payload to avoid 416 HTTP response
568 // error codes. 567 // error codes.
569 int64_t next_data_offset = 0; 568 int64_t next_data_offset = 0;
570 prefs_->GetInt64(kPrefsUpdateStateNextDataOffset, &next_data_offset); 569 prefs_->GetInt64(kPrefsUpdateStateNextDataOffset, &next_data_offset);
571 uint64_t resume_offset = manifest_metadata_size + next_data_offset; 570 uint64_t resume_offset = manifest_metadata_size + next_data_offset;
572 if (resume_offset < response_handler_action_->install_plan().size) { 571 if (resume_offset < response_handler_action_->install_plan().size) {
573 ranges.push_back(make_pair(resume_offset, -1)); 572 fetcher->AddRange(resume_offset, -1);
574 } 573 }
575 } else { 574 } else {
576 ranges.push_back(make_pair(0, -1)); 575 fetcher->AddRange(0, -1);
577 } 576 }
578 fetcher->set_ranges(ranges);
579 } 577 }
580 578
581 } // namespace chromeos_update_engine 579 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « multi_range_http_fetcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698