| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/chromeos/imageburner/burn_manager.h" | 5 #include "chrome/browser/chromeos/imageburner/burn_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/chromeos/system/statistics_provider.h" | 12 #include "chrome/browser/chromeos/system/statistics_provider.h" |
| 13 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
| 14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 15 #include "content/public/common/url_fetcher.h" | 15 #include "net/url_request/url_fetcher.h" |
| 16 #include "net/url_request/url_request_status.h" | 16 #include "net/url_request/url_request_status.h" |
| 17 | 17 |
| 18 using content::BrowserThread; | 18 using content::BrowserThread; |
| 19 | 19 |
| 20 namespace chromeos { | 20 namespace chromeos { |
| 21 namespace imageburner { | 21 namespace imageburner { |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 // Name for hwid in machine statistics. | 25 // Name for hwid in machine statistics. |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 void BurnManager::FetchConfigFile(Delegate* delegate) { | 274 void BurnManager::FetchConfigFile(Delegate* delegate) { |
| 275 if (config_file_fetched_) { | 275 if (config_file_fetched_) { |
| 276 delegate->OnConfigFileFetched(true, image_file_name_, image_download_url_); | 276 delegate->OnConfigFileFetched(true, image_file_name_, image_download_url_); |
| 277 return; | 277 return; |
| 278 } | 278 } |
| 279 downloaders_.push_back(delegate->AsWeakPtr()); | 279 downloaders_.push_back(delegate->AsWeakPtr()); |
| 280 | 280 |
| 281 if (config_fetcher_.get()) | 281 if (config_fetcher_.get()) |
| 282 return; | 282 return; |
| 283 | 283 |
| 284 config_fetcher_.reset(content::URLFetcher::Create( | 284 config_fetcher_.reset(net::URLFetcher::Create( |
| 285 config_file_url_, net::URLFetcher::GET, this)); | 285 config_file_url_, net::URLFetcher::GET, this)); |
| 286 config_fetcher_->SetRequestContext( | 286 config_fetcher_->SetRequestContext( |
| 287 g_browser_process->system_request_context()); | 287 g_browser_process->system_request_context()); |
| 288 config_fetcher_->Start(); | 288 config_fetcher_->Start(); |
| 289 } | 289 } |
| 290 | 290 |
| 291 void BurnManager::FetchImage(const GURL& image_url, const FilePath& file_path) { | 291 void BurnManager::FetchImage(const GURL& image_url, const FilePath& file_path) { |
| 292 tick_image_download_start_ = base::TimeTicks::Now(); | 292 tick_image_download_start_ = base::TimeTicks::Now(); |
| 293 bytes_image_download_progress_last_reported_ = 0; | 293 bytes_image_download_progress_last_reported_ = 0; |
| 294 image_fetcher_.reset(content::URLFetcher::Create(image_url, | 294 image_fetcher_.reset(net::URLFetcher::Create(image_url, |
| 295 net::URLFetcher::GET, | 295 net::URLFetcher::GET, |
| 296 this)); | 296 this)); |
| 297 image_fetcher_->SetRequestContext( | 297 image_fetcher_->SetRequestContext( |
| 298 g_browser_process->system_request_context()); | 298 g_browser_process->system_request_context()); |
| 299 image_fetcher_->SaveResponseToFileAtPath( | 299 image_fetcher_->SaveResponseToFileAtPath( |
| 300 file_path, | 300 file_path, |
| 301 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); | 301 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); |
| 302 image_fetcher_->Start(); | 302 image_fetcher_->Start(); |
| 303 } | 303 } |
| 304 | 304 |
| 305 void BurnManager::CancelImageFetch() { | 305 void BurnManager::CancelImageFetch() { |
| 306 image_fetcher_.reset(); | 306 image_fetcher_.reset(); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 downloaders_[i]->OnConfigFileFetched(fetched, | 369 downloaders_[i]->OnConfigFileFetched(fetched, |
| 370 image_file_name_, | 370 image_file_name_, |
| 371 image_download_url_); | 371 image_download_url_); |
| 372 } | 372 } |
| 373 } | 373 } |
| 374 downloaders_.clear(); | 374 downloaders_.clear(); |
| 375 } | 375 } |
| 376 | 376 |
| 377 } // namespace imageburner | 377 } // namespace imageburner |
| 378 } // namespace chromeos | 378 } // namespace chromeos |
| OLD | NEW |