| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/plugin_download_helper.h" | 5 #include "chrome/browser/plugin_download_helper.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 | 9 |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "chrome/browser/net/url_request_tracking.h" | |
| 12 #include "net/base/io_buffer.h" | 11 #include "net/base/io_buffer.h" |
| 13 | 12 |
| 14 PluginDownloadUrlHelper::PluginDownloadUrlHelper( | 13 PluginDownloadUrlHelper::PluginDownloadUrlHelper( |
| 15 const std::string& download_url, | 14 const std::string& download_url, |
| 16 int source_child_unique_id, | |
| 17 gfx::NativeWindow caller_window, | 15 gfx::NativeWindow caller_window, |
| 18 PluginDownloadUrlHelper::DownloadDelegate* delegate) | 16 PluginDownloadUrlHelper::DownloadDelegate* delegate) |
| 19 : download_file_request_(NULL), | 17 : download_file_request_(NULL), |
| 20 download_file_buffer_(new net::IOBuffer(kDownloadFileBufferSize)), | 18 download_file_buffer_(new net::IOBuffer(kDownloadFileBufferSize)), |
| 21 download_file_caller_window_(caller_window), | 19 download_file_caller_window_(caller_window), |
| 22 download_url_(download_url), | 20 download_url_(download_url), |
| 23 download_source_child_unique_id_(source_child_unique_id), | |
| 24 delegate_(delegate) { | 21 delegate_(delegate) { |
| 25 memset(download_file_buffer_->data(), 0, kDownloadFileBufferSize); | 22 memset(download_file_buffer_->data(), 0, kDownloadFileBufferSize); |
| 26 download_file_.reset(new net::FileStream()); | 23 download_file_.reset(new net::FileStream()); |
| 27 } | 24 } |
| 28 | 25 |
| 29 PluginDownloadUrlHelper::~PluginDownloadUrlHelper() { | 26 PluginDownloadUrlHelper::~PluginDownloadUrlHelper() { |
| 30 if (download_file_request_) { | 27 if (download_file_request_) { |
| 31 delete download_file_request_; | 28 delete download_file_request_; |
| 32 download_file_request_ = NULL; | 29 download_file_request_ = NULL; |
| 33 } | 30 } |
| 34 } | 31 } |
| 35 | 32 |
| 36 void PluginDownloadUrlHelper::InitiateDownload( | 33 void PluginDownloadUrlHelper::InitiateDownload( |
| 37 net::URLRequestContext* request_context) { | 34 net::URLRequestContext* request_context) { |
| 38 download_file_request_ = new net::URLRequest(GURL(download_url_), this); | 35 download_file_request_ = new net::URLRequest(GURL(download_url_), this); |
| 39 chrome_browser_net::SetOriginPIDForRequest( | |
| 40 download_source_child_unique_id_, download_file_request_); | |
| 41 download_file_request_->set_context(request_context); | 36 download_file_request_->set_context(request_context); |
| 42 download_file_request_->Start(); | 37 download_file_request_->Start(); |
| 43 } | 38 } |
| 44 | 39 |
| 45 void PluginDownloadUrlHelper::OnAuthRequired( | 40 void PluginDownloadUrlHelper::OnAuthRequired( |
| 46 net::URLRequest* request, | 41 net::URLRequest* request, |
| 47 net::AuthChallengeInfo* auth_info) { | 42 net::AuthChallengeInfo* auth_info) { |
| 48 net::URLRequest::Delegate::OnAuthRequired(request, auth_info); | 43 net::URLRequest::Delegate::OnAuthRequired(request, auth_info); |
| 49 DownloadCompletedHelper(false); | 44 DownloadCompletedHelper(false); |
| 50 } | 45 } |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 ::SendMessage(download_file_caller_window_, WM_COPYDATA, NULL, | 172 ::SendMessage(download_file_caller_window_, WM_COPYDATA, NULL, |
| 178 reinterpret_cast<LPARAM>(&download_file_data)); | 173 reinterpret_cast<LPARAM>(&download_file_data)); |
| 179 } | 174 } |
| 180 } | 175 } |
| 181 | 176 |
| 182 // Don't access any members after this. | 177 // Don't access any members after this. |
| 183 delete this; | 178 delete this; |
| 184 } | 179 } |
| 185 | 180 |
| 186 #endif // OS_WIN | 181 #endif // OS_WIN |
| OLD | NEW |