OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 | 5 |
6 #ifndef CHROME_BROWSER_CHROMEOS_DOM_UI_IMAGEBURNER_UI_H_ | 6 #ifndef CHROME_BROWSER_CHROMEOS_DOM_UI_IMAGEBURNER_UI_H_ |
7 #define CHROME_BROWSER_CHROMEOS_DOM_UI_IMAGEBURNER_UI_H_ | 7 #define CHROME_BROWSER_CHROMEOS_DOM_UI_IMAGEBURNER_UI_H_ |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "app/download_file_interface.h" | 12 #include "app/download_file_interface.h" |
13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
14 #include "base/file_util.h" | 14 #include "base/file_util.h" |
15 #include "base/scoped_ptr.h" | 15 #include "base/scoped_ptr.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "chrome/browser/chromeos/cros/burn_library.h" | 17 #include "chrome/browser/chromeos/cros/burn_library.h" |
18 #include "chrome/browser/chromeos/cros/cros_library.h" | 18 #include "chrome/browser/chromeos/cros/cros_library.h" |
19 #include "chrome/browser/chromeos/cros/mount_library.h" | 19 #include "chrome/browser/chromeos/cros/mount_library.h" |
20 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" | 20 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" |
21 #include "chrome/browser/dom_ui/dom_ui.h" | 21 #include "chrome/browser/dom_ui/dom_ui.h" |
22 #include "chrome/browser/download/download_item.h" | 22 #include "chrome/browser/download/download_item.h" |
23 #include "chrome/browser/download/download_manager.h" | 23 #include "chrome/browser/download/download_manager.h" |
24 #include "chrome/browser/download/download_util.h" | 24 #include "chrome/browser/download/download_util.h" |
25 #include "chrome/browser/tab_contents/tab_contents.h" | 25 #include "chrome/browser/tab_contents/tab_contents.h" |
26 #include "googleurl/src/gurl.h" | 26 #include "googleurl/src/gurl.h" |
27 #include "net/base/file_stream.h" | 27 #include "net/base/file_stream.h" |
28 | 28 |
| 29 template <typename T> struct DefaultSingletonTraits; |
| 30 |
29 static const std::string kPropertyPath = "path"; | 31 static const std::string kPropertyPath = "path"; |
30 static const std::string kPropertyTitle = "title"; | 32 static const std::string kPropertyTitle = "title"; |
31 static const std::string kPropertyDirectory = "isDirectory"; | 33 static const std::string kPropertyDirectory = "isDirectory"; |
32 static const std::string kImageBaseURL = | 34 static const std::string kImageBaseURL = |
33 "http://chrome-master.mtv.corp.google.com/chromeos/dev-channel/"; | 35 "http://chrome-master.mtv.corp.google.com/chromeos/dev-channel/"; |
34 static const std::string kImageFetcherName = "LATEST-x86-generic"; | 36 static const std::string kImageFetcherName = "LATEST-x86-generic"; |
35 static const std::string kImageFileName = "chromeos_image.bin.gz"; | 37 static const std::string kImageFileName = "chromeos_image.bin.gz"; |
36 static const std::string kTempImageFolderName = "chromeos_image"; | 38 static const std::string kTempImageFolderName = "chromeos_image"; |
37 | 39 |
38 class ImageBurnResourceManager; | 40 class ImageBurnResourceManager; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 ImageBurnResourceManager* resource_manager_; | 153 ImageBurnResourceManager* resource_manager_; |
152 | 154 |
153 friend class base::RefCountedThreadSafe<ImageBurnTaskProxy>; | 155 friend class base::RefCountedThreadSafe<ImageBurnTaskProxy>; |
154 | 156 |
155 DISALLOW_COPY_AND_ASSIGN(ImageBurnTaskProxy); | 157 DISALLOW_COPY_AND_ASSIGN(ImageBurnTaskProxy); |
156 }; | 158 }; |
157 | 159 |
158 class ImageBurnResourceManager : public DownloadManager::Observer, | 160 class ImageBurnResourceManager : public DownloadManager::Observer, |
159 public DownloadItem::Observer { | 161 public DownloadItem::Observer { |
160 public: | 162 public: |
161 ImageBurnResourceManager(); | 163 // Returns the singleton instance. |
162 ~ImageBurnResourceManager(); | 164 static ImageBurnResourceManager* GetInstance(); |
163 | 165 |
164 // DownloadItem::Observer interface | 166 // DownloadItem::Observer interface |
165 virtual void OnDownloadUpdated(DownloadItem* download); | 167 virtual void OnDownloadUpdated(DownloadItem* download); |
166 virtual void OnDownloadFileCompleted(DownloadItem* download); | 168 virtual void OnDownloadFileCompleted(DownloadItem* download); |
167 virtual void OnDownloadOpened(DownloadItem* download); | 169 virtual void OnDownloadOpened(DownloadItem* download); |
168 | 170 |
169 // DownloadManager::Observer interface | 171 // DownloadManager::Observer interface |
170 virtual void ModelChanged(); | 172 virtual void ModelChanged(); |
171 | 173 |
172 FilePath GetLocalImageDirPath(); | 174 FilePath GetLocalImageDirPath(); |
(...skipping 10 matching lines...) Expand all Loading... |
183 | 185 |
184 void ReportDownloadFinished(bool success); | 186 void ReportDownloadFinished(bool success); |
185 | 187 |
186 void CreateImageUrl(TabContents* tab_content, ImageBurnHandler* downloader); | 188 void CreateImageUrl(TabContents* tab_content, ImageBurnHandler* downloader); |
187 | 189 |
188 void ImageUrlFetched(bool success); | 190 void ImageUrlFetched(bool success); |
189 | 191 |
190 net::FileStream* CreateFileStream(FilePath* file_path); | 192 net::FileStream* CreateFileStream(FilePath* file_path); |
191 | 193 |
192 private: | 194 private: |
| 195 friend struct DefaultSingletonTraits<ImageBurnResourceManager>; |
| 196 |
| 197 ImageBurnResourceManager(); |
| 198 ~ImageBurnResourceManager(); |
| 199 |
193 FilePath local_image_dir_file_path_; | 200 FilePath local_image_dir_file_path_; |
194 FilePath image_fecher_local_path_; | 201 FilePath image_fecher_local_path_; |
195 bool image_download_started_; | 202 bool image_download_started_; |
196 bool image_download_finished_; | 203 bool image_download_finished_; |
197 bool burn_in_progress_; | 204 bool burn_in_progress_; |
198 DownloadManager* download_manager_; | 205 DownloadManager* download_manager_; |
199 bool download_item_observer_added_; | 206 bool download_item_observer_added_; |
200 DownloadItem* active_download_item_; | 207 DownloadItem* active_download_item_; |
201 scoped_ptr<GURL> image_url_; | 208 scoped_ptr<GURL> image_url_; |
202 GURL image_fetcher_url_; | 209 GURL image_fetcher_url_; |
203 bool image_url_fetching_requested_; | 210 bool image_url_fetching_requested_; |
204 bool image_url_fetched_; | 211 bool image_url_fetched_; |
205 std::vector<ImageBurnHandler*> downloaders_; | 212 std::vector<ImageBurnHandler*> downloaders_; |
206 | 213 |
207 | 214 |
208 DISALLOW_COPY_AND_ASSIGN(ImageBurnResourceManager); | 215 DISALLOW_COPY_AND_ASSIGN(ImageBurnResourceManager); |
209 }; | 216 }; |
210 | 217 |
211 class ImageBurnUI : public DOMUI { | 218 class ImageBurnUI : public DOMUI { |
212 public: | 219 public: |
213 explicit ImageBurnUI(TabContents* contents); | 220 explicit ImageBurnUI(TabContents* contents); |
214 | 221 |
215 private: | 222 private: |
216 DISALLOW_COPY_AND_ASSIGN(ImageBurnUI); | 223 DISALLOW_COPY_AND_ASSIGN(ImageBurnUI); |
217 }; | 224 }; |
218 #endif // CHROME_BROWSER_CHROMEOS_DOM_UI_IMAGEBURNER_UI_H_ | 225 #endif // CHROME_BROWSER_CHROMEOS_DOM_UI_IMAGEBURNER_UI_H_ |
219 | 226 |
OLD | NEW |