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 | 9 |
10 #include <stdint.h> | 10 #include <stdint.h> |
11 #include <functional> | 11 #include <functional> |
12 #include <iomanip> | 12 #include <iomanip> |
13 #include <limits> | 13 #include <limits> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/bind.h" | 16 #include "base/bind.h" |
17 #include "base/bind_helpers.h" | 17 #include "base/bind_helpers.h" |
18 #include "base/files/file_util.h" | 18 #include "base/files/file_util.h" |
| 19 #include "base/macros.h" |
19 #include "base/single_thread_task_runner.h" | 20 #include "base/single_thread_task_runner.h" |
20 #include "base/strings/sys_string_conversions.h" | 21 #include "base/strings/sys_string_conversions.h" |
21 #include "base/thread_task_runner_handle.h" | 22 #include "base/thread_task_runner_handle.h" |
22 #include "base/win/scoped_co_mem.h" | 23 #include "base/win/scoped_co_mem.h" |
23 #include "components/update_client/utils.h" | 24 #include "components/update_client/utils.h" |
24 #include "ui/base/win/atl_module.h" | 25 #include "ui/base/win/atl_module.h" |
25 #include "url/gurl.h" | 26 #include "url/gurl.h" |
26 | 27 |
27 using base::win::ScopedCoMem; | 28 using base::win::ScopedCoMem; |
28 using base::win::ScopedComPtr; | 29 using base::win::ScopedComPtr; |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 DCHECK(thread_checker_.CalledOnValidThread()); | 404 DCHECK(thread_checker_.CalledOnValidThread()); |
404 | 405 |
405 // The following objects have thread affinity and can't be destroyed on the | 406 // The following objects have thread affinity and can't be destroyed on the |
406 // main thread. The resources managed by these objects are acquired at the | 407 // main thread. The resources managed by these objects are acquired at the |
407 // beginning of a download and released at the end of the download. Most of | 408 // beginning of a download and released at the end of the download. Most of |
408 // the time, when this destructor is called, these resources have been already | 409 // the time, when this destructor is called, these resources have been already |
409 // disposed by. Releasing the ownership here is a NOP. However, if the browser | 410 // disposed by. Releasing the ownership here is a NOP. However, if the browser |
410 // is shutting down while a download is in progress, the timer is active and | 411 // is shutting down while a download is in progress, the timer is active and |
411 // the interface pointers are valid. Releasing the ownership means leaking | 412 // the interface pointers are valid. Releasing the ownership means leaking |
412 // these objects and their associated resources. | 413 // these objects and their associated resources. |
413 timer_.release(); | 414 ignore_result(timer_.release()); |
414 bits_manager_.Detach(); | 415 bits_manager_.Detach(); |
415 job_.Detach(); | 416 job_.Detach(); |
416 } | 417 } |
417 | 418 |
418 void BackgroundDownloader::DoStartDownload(const GURL& url) { | 419 void BackgroundDownloader::DoStartDownload(const GURL& url) { |
419 DCHECK(thread_checker_.CalledOnValidThread()); | 420 DCHECK(thread_checker_.CalledOnValidThread()); |
420 | 421 |
421 task_runner_->PostTask(FROM_HERE, | 422 task_runner_->PostTask(FROM_HERE, |
422 base::Bind(&BackgroundDownloader::BeginDownload, | 423 base::Bind(&BackgroundDownloader::BeginDownload, |
423 base::Unretained(this), url)); | 424 base::Unretained(this), url)); |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 // must match as a job only contains one file. | 754 // must match as a job only contains one file. |
754 DCHECK(progress.Completed); | 755 DCHECK(progress.Completed); |
755 DCHECK_EQ(progress.BytesTotal, progress.BytesTransferred); | 756 DCHECK_EQ(progress.BytesTotal, progress.BytesTransferred); |
756 | 757 |
757 response_ = base::FilePath(local_name); | 758 response_ = base::FilePath(local_name); |
758 | 759 |
759 return S_OK; | 760 return S_OK; |
760 } | 761 } |
761 | 762 |
762 } // namespace update_client | 763 } // namespace update_client |
OLD | NEW |