Index: chrome/browser/local_discovery/privet_url_fetcher.cc |
diff --git a/chrome/browser/local_discovery/privet_url_fetcher.cc b/chrome/browser/local_discovery/privet_url_fetcher.cc |
index f85a531f0d3065ed87307f12d1eed5e0d5e9db1f..529e1837fd728d4e6130cbd88b02627c3447c2ab 100644 |
--- a/chrome/browser/local_discovery/privet_url_fetcher.cc |
+++ b/chrome/browser/local_discovery/privet_url_fetcher.cc |
@@ -10,6 +10,7 @@ |
#include "base/rand_util.h" |
#include "chrome/browser/browser_process.h" |
#include "chrome/browser/local_discovery/privet_constants.h" |
+#include "content/public/browser/browser_thread.h" |
#include "net/http/http_status_code.h" |
#include "net/url_request/url_request_status.h" |
@@ -65,8 +66,19 @@ void PrivetURLFetcher::Try() { |
token); |
// URLFetcher requires us to set upload data for POST requests. |
- if (request_type_ == net::URLFetcher::POST) |
- url_fetcher_->SetUploadData(upload_content_type_, upload_data_); |
+ if (request_type_ == net::URLFetcher::POST) { |
+ if (!upload_file_path_.empty()) { |
+ url_fetcher_->SetUploadFilePath( |
+ upload_content_type_, |
+ upload_file_path_, |
+ 0 /*offset*/, |
+ kuint64max /*length*/, |
+ content::BrowserThread::GetMessageLoopProxyForThread( |
+ content::BrowserThread::FILE)); |
+ } else { |
+ url_fetcher_->SetUploadData(upload_content_type_, upload_data_); |
+ } |
+ } |
url_fetcher_->Start(); |
} else { |
@@ -86,10 +98,19 @@ void PrivetURLFetcher::Start() { |
void PrivetURLFetcher::SetUploadData(const std::string& upload_content_type, |
const std::string& upload_data) { |
+ DCHECK(upload_file_path_.empty()); |
upload_content_type_ = upload_content_type; |
upload_data_ = upload_data; |
} |
+void PrivetURLFetcher::SetUploadFilePath( |
+ const std::string& upload_content_type, |
+ const base::FilePath& upload_file_path) { |
+ DCHECK(upload_data_.empty()); |
+ upload_content_type_ = upload_content_type; |
+ upload_file_path_ = upload_file_path; |
+} |
+ |
void PrivetURLFetcher::OnURLFetchComplete(const net::URLFetcher* source) { |
if (source->GetStatus().status() != net::URLRequestStatus::SUCCESS || |
source->GetResponseCode() == net::HTTP_SERVICE_UNAVAILABLE) { |