OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 "base/files/file_util.h" | 5 #include "base/files/file_util.h" |
6 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h" | 6 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h" |
7 #include "chrome/browser/extensions/api/image_writer_private/operation_manager.h
" | 7 #include "chrome/browser/extensions/api/image_writer_private/operation_manager.h
" |
8 #include "chrome/browser/extensions/api/image_writer_private/write_from_url_oper
ation.h" | 8 #include "chrome/browser/extensions/api/image_writer_private/write_from_url_oper
ation.h" |
9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
10 #include "net/url_request/url_fetcher.h" | 10 #include "net/url_request/url_fetcher.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 download_continuation_ = continuation; | 81 download_continuation_ = continuation; |
82 | 82 |
83 SetStage(image_writer_api::STAGE_DOWNLOAD); | 83 SetStage(image_writer_api::STAGE_DOWNLOAD); |
84 | 84 |
85 // Store the URL fetcher on this object so that it is destroyed before this | 85 // Store the URL fetcher on this object so that it is destroyed before this |
86 // object is. | 86 // object is. |
87 url_fetcher_ = net::URLFetcher::Create(url_, net::URLFetcher::GET, this); | 87 url_fetcher_ = net::URLFetcher::Create(url_, net::URLFetcher::GET, this); |
88 | 88 |
89 url_fetcher_->SetRequestContext(request_context_); | 89 url_fetcher_->SetRequestContext(request_context_); |
90 url_fetcher_->SaveResponseToFileAtPath( | 90 url_fetcher_->SaveResponseToFileAtPath( |
91 image_path_, | 91 image_path_, BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE)); |
92 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); | |
93 | 92 |
94 AddCleanUpFunction( | 93 AddCleanUpFunction( |
95 base::Bind(&WriteFromUrlOperation::DestroyUrlFetcher, this)); | 94 base::Bind(&WriteFromUrlOperation::DestroyUrlFetcher, this)); |
96 | 95 |
97 url_fetcher_->Start(); | 96 url_fetcher_->Start(); |
98 } | 97 } |
99 | 98 |
100 void WriteFromUrlOperation::DestroyUrlFetcher() { url_fetcher_.reset(); } | 99 void WriteFromUrlOperation::DestroyUrlFetcher() { url_fetcher_.reset(); } |
101 | 100 |
102 void WriteFromUrlOperation::OnURLFetchUploadProgress( | 101 void WriteFromUrlOperation::OnURLFetchUploadProgress( |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 if (IsCancelled()) { | 181 if (IsCancelled()) { |
183 return; | 182 return; |
184 } | 183 } |
185 | 184 |
186 SetProgress(kProgressComplete); | 185 SetProgress(kProgressComplete); |
187 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, continuation); | 186 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, continuation); |
188 } | 187 } |
189 | 188 |
190 } // namespace image_writer | 189 } // namespace image_writer |
191 } // namespace extensions | 190 } // namespace extensions |
OLD | NEW |