Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1764)

Unified Diff: chrome/browser/local_discovery/privet_url_fetcher.cc

Issue 72033002: Added the ability to set the upload file path (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/local_discovery/privet_url_fetcher.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « chrome/browser/local_discovery/privet_url_fetcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698