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

Side by Side Diff: chrome/browser/local_discovery/privet_http_impl.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/browser/local_discovery/privet_http_impl.h" 5 #include "chrome/browser/local_discovery/privet_http_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 482
483 if (offline_) { 483 if (offline_) {
484 url = net::AppendQueryParameter(url, 484 url = net::AppendQueryParameter(url,
485 kPrivetURLKeyOffline, 485 kPrivetURLKeyOffline,
486 kPrivetURLValueOffline); 486 kPrivetURLValueOffline);
487 } 487 }
488 488
489 url_fetcher_= privet_client_->CreateURLFetcher( 489 url_fetcher_= privet_client_->CreateURLFetcher(
490 url, net::URLFetcher::POST, this); 490 url, net::URLFetcher::POST, this);
491 491
492 DCHECK(!data_.empty()); 492 std::string content_type =
493 url_fetcher_->SetUploadData( 493 use_pdf_ ? kPrivetContentTypePDF : kPrivetContentTypePWGRaster;
494 use_pdf_ ? kPrivetContentTypePDF : kPrivetContentTypePWGRaster, 494
495 data_); 495 DCHECK(!data_.empty() || !data_file_.empty());
496
497 if (!data_file_.empty()) {
498 url_fetcher_->SetUploadFilePath(
gene 2013/11/14 00:52:14 nit: fit on one line
Noam Samuel 2013/11/14 19:05:57 Done.
499 content_type,
500 data_file_);
501 } else {
502 url_fetcher_->SetUploadData(
gene 2013/11/14 00:52:14 nit: fit on one line
Noam Samuel 2013/11/14 19:05:57 Done.
503 content_type,
504 data_);
505 }
496 506
497 url_fetcher_->Start(); 507 url_fetcher_->Start();
498 } 508 }
499 509
500 void PrivetLocalPrintOperationImpl::OnCapabilitiesResponse( 510 void PrivetLocalPrintOperationImpl::OnCapabilitiesResponse(
501 bool has_error, 511 bool has_error,
502 const base::DictionaryValue* value) { 512 const base::DictionaryValue* value) {
503 if (has_error) { 513 if (has_error) {
504 delegate_->OnPrivetPrintingError(this, 200); 514 delegate_->OnPrivetPrintingError(this, 200);
505 return; 515 return;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 } 616 }
607 617
608 void PrivetLocalPrintOperationImpl::OnNeedPrivetToken( 618 void PrivetLocalPrintOperationImpl::OnNeedPrivetToken(
609 PrivetURLFetcher* fetcher, 619 PrivetURLFetcher* fetcher,
610 const PrivetURLFetcher::TokenCallback& callback) { 620 const PrivetURLFetcher::TokenCallback& callback) {
611 privet_client_->RefreshPrivetToken(callback); 621 privet_client_->RefreshPrivetToken(callback);
612 } 622 }
613 623
614 void PrivetLocalPrintOperationImpl::SendData(const std::string& data) { 624 void PrivetLocalPrintOperationImpl::SendData(const std::string& data) {
615 DCHECK(started_); 625 DCHECK(started_);
626 DCHECK(data_file_.empty());
616 data_ = data; 627 data_ = data;
617 628
618 if (has_extended_workflow_ && !ticket_.empty()) { 629 SendDataInternal();
619 DoCreatejob(); 630 }
620 } else { 631
621 DoSubmitdoc(); 632 void PrivetLocalPrintOperationImpl::SendDataFile(
622 } 633 const base::FilePath& data_file) {
634 DCHECK(started_);
635 DCHECK(data_.empty());
636 data_file_ = data_file;
637
638 SendDataInternal();
623 } 639 }
624 640
625 void PrivetLocalPrintOperationImpl::SetTicket(const std::string& ticket) { 641 void PrivetLocalPrintOperationImpl::SetTicket(const std::string& ticket) {
626 DCHECK(!started_); 642 DCHECK(!started_);
627 ticket_ = ticket; 643 ticket_ = ticket;
628 } 644 }
629 645
630 void PrivetLocalPrintOperationImpl::SetUsername(const std::string& user) { 646 void PrivetLocalPrintOperationImpl::SetUsername(const std::string& user) {
631 DCHECK(!started_); 647 DCHECK(!started_);
632 user_= user; 648 user_= user;
633 } 649 }
634 650
635 void PrivetLocalPrintOperationImpl::SetJobname(const std::string& jobname) { 651 void PrivetLocalPrintOperationImpl::SetJobname(const std::string& jobname) {
636 DCHECK(!started_); 652 DCHECK(!started_);
637 jobname_ = jobname; 653 jobname_ = jobname;
638 } 654 }
639 655
640 void PrivetLocalPrintOperationImpl::SetOffline(bool offline) { 656 void PrivetLocalPrintOperationImpl::SetOffline(bool offline) {
641 DCHECK(!started_); 657 DCHECK(!started_);
642 offline_ = offline; 658 offline_ = offline;
643 } 659 }
644 660
661 void PrivetLocalPrintOperationImpl::SendDataInternal() {
662 if (has_extended_workflow_ && !ticket_.empty()) {
663 DoCreatejob();
664 } else {
665 DoSubmitdoc();
666 }
667 }
668
645 PrivetHTTPClientImpl::PrivetHTTPClientImpl( 669 PrivetHTTPClientImpl::PrivetHTTPClientImpl(
646 const std::string& name, 670 const std::string& name,
647 const net::HostPortPair& host_port, 671 const net::HostPortPair& host_port,
648 net::URLRequestContextGetter* request_context) 672 net::URLRequestContextGetter* request_context)
649 : name_(name), 673 : name_(name),
650 fetcher_factory_(request_context), 674 fetcher_factory_(request_context),
651 host_port_(host_port) { 675 host_port_(host_port) {
652 } 676 }
653 677
654 PrivetHTTPClientImpl::~PrivetHTTPClientImpl() { 678 PrivetHTTPClientImpl::~PrivetHTTPClientImpl() {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 TokenCallbackVector token_callbacks; 764 TokenCallbackVector token_callbacks;
741 token_callbacks_.swap(token_callbacks); 765 token_callbacks_.swap(token_callbacks);
742 766
743 for (TokenCallbackVector::iterator i = token_callbacks.begin(); 767 for (TokenCallbackVector::iterator i = token_callbacks.begin();
744 i != token_callbacks.end(); i++) { 768 i != token_callbacks.end(); i++) {
745 i->Run(token); 769 i->Run(token);
746 } 770 }
747 } 771 }
748 772
749 } // namespace local_discovery 773 } // namespace local_discovery
OLDNEW
« no previous file with comments | « chrome/browser/local_discovery/privet_http_impl.h ('k') | chrome/browser/local_discovery/privet_http_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698