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

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: cpu'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
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 HRESULT InstallJobObserver();
53 HRESULT RemoveJobObserver();
54
55 static HRESULT CleanupStaleJobs(
56 base::win::ScopedComPtr<IBackgroundCopyManager> bits_manager);
57
58 net::URLRequestContextGetter* context_getter_;
59 scoped_refptr<base::SequencedTaskRunner> task_runner_;
60
61 scoped_ptr<base::OneShotTimer<BackgroundDownloader> > timer_;
62
63 base::win::ScopedComPtr<IBackgroundCopyManager> bits_manager_;
64
65 base::win::ScopedComPtr<IBackgroundCopyJob> job_;
66 base::win::ScopedComPtr<IBackgroundCopyCallback> job_observer_;
67
68 bool is_completed_;
69
70 DISALLOW_COPY_AND_ASSIGN(BackgroundDownloader);
71 };
72
73 } // namespace component_updater
74
75 #endif // CHROME_BROWSER_COMPONENT_UPDATER_BACKGROUND_DOWNLOADER_WIN_H_
76
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698