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

Side by Side Diff: chrome/browser/component_updater/background_downloader_win.cc

Issue 138973003: Race condition in component_updater::BackgroundDowloader (follow up) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 | « chrome/browser/component_updater/background_downloader_win.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/component_updater/background_downloader_win.h" 5 #include "chrome/browser/component_updater/background_downloader_win.h"
6 6
7 #include <atlbase.h> 7 #include <atlbase.h>
8 #include <atlcom.h> 8 #include <atlcom.h>
9 9
10 #include <functional> 10 #include <functional>
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 download_metrics.url = url(); 518 download_metrics.url = url();
519 download_metrics.downloader = DownloadMetrics::kBits; 519 download_metrics.downloader = DownloadMetrics::kBits;
520 download_metrics.error = SUCCEEDED(error) ? 0 : error; 520 download_metrics.error = SUCCEEDED(error) ? 0 : error;
521 download_metrics.bytes_downloaded = bytes_downloaded; 521 download_metrics.bytes_downloaded = bytes_downloaded;
522 download_metrics.bytes_total = bytes_total; 522 download_metrics.bytes_total = bytes_total;
523 download_metrics.download_time_ms = download_time.InMilliseconds(); 523 download_metrics.download_time_ms = download_time.InMilliseconds();
524 524
525 // Clean up stale jobs before invoking the callback. 525 // Clean up stale jobs before invoking the callback.
526 CleanupStaleJobs(bits_manager_); 526 CleanupStaleJobs(bits_manager_);
527 527
528 bits_manager_ = NULL;
529
528 Result result; 530 Result result;
529 result.error = error; 531 result.error = error;
530 result.response = response; 532 result.response = response;
531 BrowserThread::PostTask( 533 BrowserThread::PostTask(
532 BrowserThread::UI, 534 BrowserThread::UI,
533 FROM_HERE, 535 FROM_HERE,
534 base::Bind(&BackgroundDownloader::OnDownloadComplete, 536 base::Bind(&BackgroundDownloader::OnDownloadComplete,
535 base::Unretained(this), 537 base::Unretained(this),
536 is_handled, 538 is_handled,
537 result, 539 result,
538 download_metrics)); 540 download_metrics));
539 541
540 bits_manager_ = NULL;
541
542 // Once the task is posted to the the UI thread, this object may be deleted 542 // Once the task is posted to the the UI thread, this object may be deleted
543 // by its owner. It is not safe to access members of this object on the 543 // by its owner. It is not safe to access members of this object on the
544 // FILE thread from this point on. The timer is stopped and all BITS 544 // FILE thread from this point on. The timer is stopped and all BITS
545 // interface pointers have been released. 545 // interface pointers have been released.
546 } 546 }
547 547
548 // Called when the BITS job has been transferred successfully. Completes the 548 // Called when the BITS job has been transferred successfully. Completes the
549 // BITS job by removing it from the BITS queue and making the download 549 // BITS job by removing it from the BITS queue and making the download
550 // available to the caller. 550 // available to the caller.
551 void BackgroundDownloader::OnStateTransferred() { 551 void BackgroundDownloader::OnStateTransferred() {
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 } 700 }
701 701
702 bool BackgroundDownloader::IsStuck() { 702 bool BackgroundDownloader::IsStuck() {
703 const base::TimeDelta job_stuck_timeout( 703 const base::TimeDelta job_stuck_timeout(
704 base::TimeDelta::FromMinutes(kJobStuckTimeoutMin)); 704 base::TimeDelta::FromMinutes(kJobStuckTimeoutMin));
705 return job_stuck_begin_time_ + job_stuck_timeout < base::Time::Now(); 705 return job_stuck_begin_time_ + job_stuck_timeout < base::Time::Now();
706 } 706 }
707 707
708 } // namespace component_updater 708 } // namespace component_updater
709 709
OLDNEW
« no previous file with comments | « chrome/browser/component_updater/background_downloader_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698