OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 CHROME_BROWSER_EXTENSIONS_EXTENSION_UPDATER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_UPDATER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_UPDATER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_UPDATER_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/ref_counted.h" | 12 #include "base/ref_counted.h" |
13 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
14 #include "base/scoped_temp_dir.h" | 14 #include "base/scoped_temp_dir.h" |
15 #include "base/task.h" | 15 #include "base/task.h" |
16 #include "base/time.h" | 16 #include "base/time.h" |
17 #include "base/timer.h" | 17 #include "base/timer.h" |
18 #include "chrome/browser/extensions/extensions_service.h" | 18 #include "chrome/browser/extensions/extensions_service.h" |
19 #include "chrome/browser/net/url_fetcher.h" | 19 #include "chrome/browser/net/url_fetcher.h" |
20 #include "chrome/common/extensions/update_manifest.h" | 20 #include "chrome/common/extensions/update_manifest.h" |
21 #include "googleurl/src/gurl.h" | 21 #include "googleurl/src/gurl.h" |
22 | 22 |
23 class Extension; | 23 class Extension; |
24 class ExtensionUpdaterTest; | 24 class ExtensionUpdaterTest; |
25 class MessageLoop; | |
26 class ExtensionUpdaterFileHandler; | 25 class ExtensionUpdaterFileHandler; |
27 class PrefService; | 26 class PrefService; |
28 | 27 |
29 // A class for doing auto-updates of installed Extensions. Used like this: | 28 // A class for doing auto-updates of installed Extensions. Used like this: |
30 // | 29 // |
31 // ExtensionUpdater* updater = new ExtensionUpdater(my_extensions_service, | 30 // ExtensionUpdater* updater = new ExtensionUpdater(my_extensions_service, |
32 // pref_service, | 31 // pref_service, |
33 // update_frequency_secs, | 32 // update_frequency_secs); |
34 // file_io_loop, | |
35 // io_loop); | |
36 // updater.Start(); | 33 // updater.Start(); |
37 // .... | 34 // .... |
38 // updater.Stop(); | 35 // updater.Stop(); |
39 class ExtensionUpdater | 36 class ExtensionUpdater |
40 : public URLFetcher::Delegate, | 37 : public URLFetcher::Delegate, |
41 public base::RefCountedThreadSafe<ExtensionUpdater> { | 38 public base::RefCountedThreadSafe<ExtensionUpdater> { |
42 public: | 39 public: |
43 // Holds a pointer to the passed |service|, using it for querying installed | 40 // Holds a pointer to the passed |service|, using it for querying installed |
44 // extensions and installing updated ones. The |frequency_seconds| parameter | 41 // extensions and installing updated ones. The |frequency_seconds| parameter |
45 // controls how often update checks are scheduled. | 42 // controls how often update checks are scheduled. |
46 ExtensionUpdater(ExtensionUpdateService* service, | 43 ExtensionUpdater(ExtensionUpdateService* service, |
47 PrefService* prefs, | 44 PrefService* prefs, |
48 int frequency_seconds, | 45 int frequency_seconds); |
49 MessageLoop* file_io_loop, | |
50 MessageLoop* io_loop); | |
51 | 46 |
52 virtual ~ExtensionUpdater(); | 47 virtual ~ExtensionUpdater(); |
53 | 48 |
54 // Starts the updater running. | 49 // Starts the updater running. |
55 void Start(); | 50 void Start(); |
56 | 51 |
57 // Stops the updater running, cancelling any outstanding update manifest and | 52 // Stops the updater running, cancelling any outstanding update manifest and |
58 // crx downloads. Does not cancel any in-progress installs. | 53 // crx downloads. Does not cancel any in-progress installs. |
59 void Stop(); | 54 void Stop(); |
60 | 55 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 166 |
172 // The extension currently being fetched (if any). | 167 // The extension currently being fetched (if any). |
173 ExtensionFetch current_extension_fetch_; | 168 ExtensionFetch current_extension_fetch_; |
174 | 169 |
175 // Pointer back to the service that owns this ExtensionUpdater. | 170 // Pointer back to the service that owns this ExtensionUpdater. |
176 ExtensionUpdateService* service_; | 171 ExtensionUpdateService* service_; |
177 | 172 |
178 base::OneShotTimer<ExtensionUpdater> timer_; | 173 base::OneShotTimer<ExtensionUpdater> timer_; |
179 int frequency_seconds_; | 174 int frequency_seconds_; |
180 | 175 |
181 // The MessageLoop where we should do file I/O. | |
182 MessageLoop* file_io_loop_; | |
183 | |
184 // The IO loop for IPC. | |
185 MessageLoop* io_loop_; | |
186 | |
187 PrefService* prefs_; | 176 PrefService* prefs_; |
188 | 177 |
189 scoped_refptr<ExtensionUpdaterFileHandler> file_handler_; | 178 scoped_refptr<ExtensionUpdaterFileHandler> file_handler_; |
190 bool blacklist_checks_enabled_; | 179 bool blacklist_checks_enabled_; |
191 | 180 |
192 DISALLOW_COPY_AND_ASSIGN(ExtensionUpdater); | 181 DISALLOW_COPY_AND_ASSIGN(ExtensionUpdater); |
193 }; | 182 }; |
194 | 183 |
195 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_UPDATER_H_ | 184 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_UPDATER_H_ |
OLD | NEW |