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

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

Issue 105853002: Implement a background downloader using BITS in Windows Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed error codes. Created 7 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 | « no previous file | chrome/browser/component_updater/background_downloader_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_BACKGROUND_DOWNLOADER_WIN_H_
6 #define CHROME_BROWSER_COMPONENT_UPDATER_BACKGROUND_DOWNLOADER_WIN_H_
7
8 #include "chrome/browser/component_updater/crx_downloader.h"
9
10 #include <windows.h>
11 #include <bits.h>
12
13 #include "base/strings/string16.h"
14 #include "base/timer/timer.h"
15 #include "base/win/scoped_comptr.h"
16
17 namespace component_updater {
18
19 // Implements a downloader in terms of the BITS service. The public interface
20 // of this class and the CrxDownloader overrides are expected to be called
21 // from the UI thread. The rest of the class code runs on the FILE thread in
22 // a single threaded apartment.
23 class BackgroundDownloader : public CrxDownloader {
24 protected:
25 friend class CrxDownloader;
26 BackgroundDownloader(scoped_ptr<CrxDownloader> successor,
27 net::URLRequestContextGetter* context_getter,
28 scoped_refptr<base::SequencedTaskRunner> task_runner,
29 const DownloadCallback& download_callback);
30 virtual ~BackgroundDownloader();
31
32 private:
33 // Overrides for CrxDownloader.
34 virtual void DoStartDownload(const GURL& url) OVERRIDE;
35
36 // Called asynchronously on the FILE thread at different stages during
37 // the download. |OnDownloading| can be called multiple times.
38 void BeginDownload(const GURL& url);
39 void OnDownloading();
40 void EndDownload(HRESULT hr);
41
42 // Handles the job state transitions to a final state.
43 void OnStateTransferred();
44 void OnStateError();
45 void OnStateCancelled();
46 void OnStateAcknowledged();
47
48 HRESULT QueueBitsJob(const GURL& url);
49 HRESULT CreateOrOpenJob(const GURL& url);
50 HRESULT InitializeNewJob(const GURL& url);
51
52 static HRESULT CleanupStaleJobs(
53 base::win::ScopedComPtr<IBackgroundCopyManager> bits_manager);
54
55 net::URLRequestContextGetter* context_getter_;
56 scoped_refptr<base::SequencedTaskRunner> task_runner_;
57
58 scoped_ptr<base::RepeatingTimer<BackgroundDownloader> > timer_;
59
60 base::win::ScopedComPtr<IBackgroundCopyManager> bits_manager_;
61 base::win::ScopedComPtr<IBackgroundCopyJob> job_;
62
63 bool is_completed_;
64
65 DISALLOW_COPY_AND_ASSIGN(BackgroundDownloader);
66 };
67
68 } // namespace component_updater
69
70 #endif // CHROME_BROWSER_COMPONENT_UPDATER_BACKGROUND_DOWNLOADER_WIN_H_
71
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/component_updater/background_downloader_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698