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/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/threading/worker_pool.h" | 10 #include "base/threading/worker_pool.h" |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 // The config file is already fetched. So start to fetch the image. | 357 // The config file is already fetched. So start to fetch the image. |
358 FetchImage(); | 358 FetchImage(); |
359 return; | 359 return; |
360 } | 360 } |
361 | 361 |
362 if (config_fetcher_.get()) | 362 if (config_fetcher_.get()) |
363 return; | 363 return; |
364 | 364 |
365 config_fetcher_.reset(net::URLFetcher::Create( | 365 config_fetcher_.reset(net::URLFetcher::Create( |
366 config_file_url_, net::URLFetcher::GET, this)); | 366 config_file_url_, net::URLFetcher::GET, this)); |
367 config_fetcher_->SetRequestContext(url_request_context_getter_); | 367 config_fetcher_->SetRequestContext(url_request_context_getter_.get()); |
368 config_fetcher_->Start(); | 368 config_fetcher_->Start(); |
369 } | 369 } |
370 | 370 |
371 void BurnManager::FetchImage() { | 371 void BurnManager::FetchImage() { |
372 if (state_machine_->download_finished()) { | 372 if (state_machine_->download_finished()) { |
373 DoBurn(); | 373 DoBurn(); |
374 return; | 374 return; |
375 } | 375 } |
376 | 376 |
377 if (state_machine_->download_started()) { | 377 if (state_machine_->download_started()) { |
378 // The image downloading is already started. Do nothing. | 378 // The image downloading is already started. Do nothing. |
379 return; | 379 return; |
380 } | 380 } |
381 | 381 |
382 tick_image_download_start_ = base::TimeTicks::Now(); | 382 tick_image_download_start_ = base::TimeTicks::Now(); |
383 bytes_image_download_progress_last_reported_ = 0; | 383 bytes_image_download_progress_last_reported_ = 0; |
384 image_fetcher_.reset(net::URLFetcher::Create(image_download_url_, | 384 image_fetcher_.reset(net::URLFetcher::Create(image_download_url_, |
385 net::URLFetcher::GET, | 385 net::URLFetcher::GET, |
386 this)); | 386 this)); |
387 image_fetcher_->SetRequestContext(url_request_context_getter_); | 387 image_fetcher_->SetRequestContext(url_request_context_getter_.get()); |
388 image_fetcher_->SaveResponseToFileAtPath( | 388 image_fetcher_->SaveResponseToFileAtPath( |
389 zip_image_file_path_, | 389 zip_image_file_path_, |
390 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); | 390 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); |
391 image_fetcher_->Start(); | 391 image_fetcher_->Start(); |
392 | 392 |
393 state_machine_->OnDownloadStarted(); | 393 state_machine_->OnDownloadStarted(); |
394 } | 394 } |
395 | 395 |
396 void BurnManager::CancelImageFetch() { | 396 void BurnManager::CancelImageFetch() { |
397 image_fetcher_.reset(); | 397 image_fetcher_.reset(); |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 // Note: in theory, this is not a part of notification, but cancelling | 645 // Note: in theory, this is not a part of notification, but cancelling |
646 // the running burning task. However, there is no good place to be in the | 646 // the running burning task. However, there is no good place to be in the |
647 // current code. | 647 // current code. |
648 // TODO(hidehiko): Clean this up after refactoring. | 648 // TODO(hidehiko): Clean this up after refactoring. |
649 OnError(IDS_IMAGEBURN_DEVICE_NOT_FOUND_ERROR); | 649 OnError(IDS_IMAGEBURN_DEVICE_NOT_FOUND_ERROR); |
650 } | 650 } |
651 } | 651 } |
652 | 652 |
653 } // namespace imageburner | 653 } // namespace imageburner |
654 } // namespace chromeos | 654 } // namespace chromeos |
OLD | NEW |