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

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: trybots and Josh's feedback. 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
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 #include <windows.h>
cpu_(ooo_6.6-7.5) 2013/12/05 19:32:43 I think you need a space between 8 and 9, I am not
Sorin Jianu 2013/12/05 22:34:36 Done.
10 #include <bits.h>
11 #include "base/strings/string16.h"
12 #include "base/timer/timer.h"
13 #include "base/win/scoped_comptr.h"
14
15 namespace component_updater {
16
17 // Implements a downloader in terms of the BITS service. The public interface
18 // of this class and the CrxDownloader overrides are expected to be called
19 // from the UI thread. The rest of the class code runs on the FILE thread in
20 // a single threaded apartment.
21 class BackgroundDownloader : public CrxDownloader {
22 protected:
23 friend class CrxDownloader;
24 BackgroundDownloader(scoped_ptr<CrxDownloader> successor,
25 net::URLRequestContextGetter* context_getter,
26 scoped_refptr<base::SequencedTaskRunner> task_runner,
27 const DownloadCallback& download_callback);
28 virtual ~BackgroundDownloader();
29
30 private:
31 // Overrides for CrxDownloader.
32 virtual void DoStartDownload(const GURL& url) OVERRIDE;
33
34 // Called asynchronously on the FILE thread at different stages during
35 // the download. |OnDownloading| can be called multiple times.
36 void BeginDownload(const GURL& url);
37 void OnDownloading();
38 void EndDownload(HRESULT hr);
39
40 // Handles the job state transitions to a final state.
41 void OnStateTransferred();
42 void OnStateError();
43 void OnStateCancelled();
44 void OnStateAcknowledged();
45
46 HRESULT QueueBitsJob(const GURL& url);
47 HRESULT CreateOrOpenJob(const GURL& url);
48 HRESULT InitializeNewJob(const GURL& url);
49
50 HRESULT InstallJobObserver();
51 HRESULT RemoveJobObserver();
52
53 static HRESULT CleanupStaleJobs(
54 base::win::ScopedComPtr<IBackgroundCopyManager> bits_manager);
55
56 net::URLRequestContextGetter* context_getter_;
57 scoped_refptr<base::SequencedTaskRunner> task_runner_;
58
59 scoped_ptr<base::OneShotTimer<BackgroundDownloader> > timer_;
60
61 base::win::ScopedComPtr<IBackgroundCopyManager> bits_manager_;
62
63 base::win::ScopedComPtr<IBackgroundCopyJob> job_;
64 base::win::ScopedComPtr<IBackgroundCopyCallback> job_observer_;
65
66 bool is_completed_;
67
68 DISALLOW_COPY_AND_ASSIGN(BackgroundDownloader);
69 };
70
71 } // namespace component_updater
72
73 #endif // CHROME_BROWSER_COMPONENT_UPDATER_BACKGROUND_DOWNLOADER_WIN_H_
74
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698