OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/update_client/background_downloader_win.h" | 5 #include "components/update_client/background_downloader_win.h" |
6 | 6 |
7 #include <atlbase.h> | 7 #include <atlbase.h> |
8 #include <atlcom.h> | 8 #include <atlcom.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 | 10 |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 this, &BackgroundDownloader::OnTimer); | 437 this, &BackgroundDownloader::OnTimer); |
438 } | 438 } |
439 | 439 |
440 void BackgroundDownloader::OnTimer() { | 440 void BackgroundDownloader::OnTimer() { |
441 DCHECK(thread_checker_.CalledOnValidThread()); | 441 DCHECK(thread_checker_.CalledOnValidThread()); |
442 task_runner()->PostTask( | 442 task_runner()->PostTask( |
443 FROM_HERE, | 443 FROM_HERE, |
444 base::Bind(&BackgroundDownloader::OnDownloading, base::Unretained(this))); | 444 base::Bind(&BackgroundDownloader::OnDownloading, base::Unretained(this))); |
445 } | 445 } |
446 | 446 |
| 447 bool BackgroundDownloader::TimerIsRunning() const { |
| 448 return timer_.get() && timer_->IsRunning(); |
| 449 } |
| 450 |
447 void BackgroundDownloader::DoStartDownload(const GURL& url) { | 451 void BackgroundDownloader::DoStartDownload(const GURL& url) { |
448 DCHECK(thread_checker_.CalledOnValidThread()); | 452 DCHECK(thread_checker_.CalledOnValidThread()); |
449 task_runner()->PostTask(FROM_HERE, | 453 task_runner()->PostTask(FROM_HERE, |
450 base::Bind(&BackgroundDownloader::BeginDownload, | 454 base::Bind(&BackgroundDownloader::BeginDownload, |
451 base::Unretained(this), url)); | 455 base::Unretained(this), url)); |
452 } | 456 } |
453 | 457 |
454 // Called one time when this class is asked to do a download. | 458 // Called one time when this class is asked to do a download. |
455 void BackgroundDownloader::BeginDownload(const GURL& url) { | 459 void BackgroundDownloader::BeginDownload(const GURL& url) { |
456 DCHECK(task_runner()->RunsTasksOnCurrentThread()); | 460 DCHECK(task_runner()->RunsTasksOnCurrentThread()); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 main_task_runner()->PostTask( | 563 main_task_runner()->PostTask( |
560 FROM_HERE, | 564 FROM_HERE, |
561 base::Bind(&BackgroundDownloader::StartTimer, base::Unretained(this))); | 565 base::Bind(&BackgroundDownloader::StartTimer, base::Unretained(this))); |
562 } | 566 } |
563 | 567 |
564 // Completes the BITS download, picks up the file path of the response, and | 568 // Completes the BITS download, picks up the file path of the response, and |
565 // notifies the CrxDownloader. The function should be called only once. | 569 // notifies the CrxDownloader. The function should be called only once. |
566 void BackgroundDownloader::EndDownload(HRESULT error) { | 570 void BackgroundDownloader::EndDownload(HRESULT error) { |
567 DCHECK(task_runner()->RunsTasksOnCurrentThread()); | 571 DCHECK(task_runner()->RunsTasksOnCurrentThread()); |
568 | 572 |
569 DCHECK(!timer_->IsRunning()); | 573 DCHECK(!TimerIsRunning()); |
570 | 574 |
571 const base::Time download_end_time(base::Time::Now()); | 575 const base::Time download_end_time(base::Time::Now()); |
572 const base::TimeDelta download_time = | 576 const base::TimeDelta download_time = |
573 download_end_time >= download_start_time_ | 577 download_end_time >= download_start_time_ |
574 ? download_end_time - download_start_time_ | 578 ? download_end_time - download_start_time_ |
575 : base::TimeDelta(); | 579 : base::TimeDelta(); |
576 | 580 |
577 int64_t downloaded_bytes = -1; | 581 int64_t downloaded_bytes = -1; |
578 int64_t total_bytes = -1; | 582 int64_t total_bytes = -1; |
579 GetJobByteCount(job_.get(), &downloaded_bytes, &total_bytes); | 583 GetJobByteCount(job_.get(), &downloaded_bytes, &total_bytes); |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 | 874 |
871 for (auto cookie : cookies) { | 875 for (auto cookie : cookies) { |
872 hr = git->RevokeInterfaceFromGlobal(cookie); | 876 hr = git->RevokeInterfaceFromGlobal(cookie); |
873 DCHECK(SUCCEEDED(hr)); | 877 DCHECK(SUCCEEDED(hr)); |
874 } | 878 } |
875 | 879 |
876 return S_OK; | 880 return S_OK; |
877 } | 881 } |
878 | 882 |
879 } // namespace update_client | 883 } // namespace update_client |
OLD | NEW |