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 #ifndef COMPONENTS_COMPONENT_UPDATER_BACKGROUND_DOWNLOADER_WIN_H_ | 5 #ifndef COMPONENTS_UPDATE_CLIENT_BACKGROUND_DOWNLOADER_WIN_H_ |
6 #define COMPONENTS_COMPONENT_UPDATER_BACKGROUND_DOWNLOADER_WIN_H_ | 6 #define COMPONENTS_UPDATE_CLIENT_BACKGROUND_DOWNLOADER_WIN_H_ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <bits.h> | 9 #include <bits.h> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "base/timer/timer.h" | 16 #include "base/timer/timer.h" |
17 #include "base/win/scoped_comptr.h" | 17 #include "base/win/scoped_comptr.h" |
18 #include "components/component_updater/crx_downloader.h" | 18 #include "components/update_client/crx_downloader.h" |
19 | 19 |
20 namespace base { | 20 namespace base { |
21 class FilePath; | 21 class FilePath; |
22 class MessageLoopProxy; | 22 class MessageLoopProxy; |
23 class SingleThreadTaskRunner; | 23 class SingleThreadTaskRunner; |
24 } | 24 } |
25 | 25 |
26 namespace component_updater { | 26 namespace update_client { |
27 | 27 |
28 // Implements a downloader in terms of the BITS service. The public interface | 28 // Implements a downloader in terms of the BITS service. The public interface |
29 // of this class and the CrxDownloader overrides are expected to be called | 29 // of this class and the CrxDownloader overrides are expected to be called |
30 // from the main thread. The rest of the class code runs on a single thread | 30 // from the main thread. The rest of the class code runs on a single thread |
31 // task runner. This task runner must be initialized to work with COM objects. | 31 // task runner. This task runner must be initialized to work with COM objects. |
32 // Instances of this class are created and destroyed in the main thread. | 32 // Instances of this class are created and destroyed in the main thread. |
33 // See the implementation of the class destructor for details regarding the | 33 // See the implementation of the class destructor for details regarding the |
34 // clean up of resources acquired in this class. | 34 // clean up of resources acquired in this class. |
35 class BackgroundDownloader : public CrxDownloader { | 35 class BackgroundDownloader : public CrxDownloader { |
36 protected: | 36 protected: |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 // Used to post responses back to the main thread. Initialized on the main | 87 // Used to post responses back to the main thread. Initialized on the main |
88 // loop but accessed from the task runner. | 88 // loop but accessed from the task runner. |
89 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | 89 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
90 | 90 |
91 net::URLRequestContextGetter* context_getter_; | 91 net::URLRequestContextGetter* context_getter_; |
92 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 92 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
93 | 93 |
94 // The timer and the BITS interface pointers have thread affinity. These | 94 // The timer and the BITS interface pointers have thread affinity. These |
95 // members are initialized on the task runner and they must be destroyed | 95 // members are initialized on the task runner and they must be destroyed |
96 // on the task runner. | 96 // on the task runner. |
97 scoped_ptr<base::RepeatingTimer<BackgroundDownloader> > timer_; | 97 scoped_ptr<base::RepeatingTimer<BackgroundDownloader>> timer_; |
98 | 98 |
99 base::win::ScopedComPtr<IBackgroundCopyManager> bits_manager_; | 99 base::win::ScopedComPtr<IBackgroundCopyManager> bits_manager_; |
100 base::win::ScopedComPtr<IBackgroundCopyJob> job_; | 100 base::win::ScopedComPtr<IBackgroundCopyJob> job_; |
101 | 101 |
102 // Contains the time when the download of the current url has started. | 102 // Contains the time when the download of the current url has started. |
103 base::Time download_start_time_; | 103 base::Time download_start_time_; |
104 | 104 |
105 // Contains the time when the BITS job is last seen making progress. | 105 // Contains the time when the BITS job is last seen making progress. |
106 base::Time job_stuck_begin_time_; | 106 base::Time job_stuck_begin_time_; |
107 | 107 |
108 // True if EndDownload was called. | 108 // True if EndDownload was called. |
109 bool is_completed_; | 109 bool is_completed_; |
110 | 110 |
111 // Contains the path of the downloaded file if the download was successful. | 111 // Contains the path of the downloaded file if the download was successful. |
112 base::FilePath response_; | 112 base::FilePath response_; |
113 | 113 |
114 DISALLOW_COPY_AND_ASSIGN(BackgroundDownloader); | 114 DISALLOW_COPY_AND_ASSIGN(BackgroundDownloader); |
115 }; | 115 }; |
116 | 116 |
117 } // namespace component_updater | 117 } // namespace update_client |
118 | 118 |
119 #endif // COMPONENTS_COMPONENT_UPDATER_BACKGROUND_DOWNLOADER_WIN_H_ | 119 #endif // COMPONENTS_UPDATE_CLIENT_BACKGROUND_DOWNLOADER_WIN_H_ |
OLD | NEW |