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

Side by Side Diff: chrome/browser/local_discovery/privet_http_impl.cc

Issue 552703002: Fix compilation on Windows with enable_printing=2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mon Sep 8 17:26:04 PDT 2014 Created 6 years, 3 months 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
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 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/rand_util.h" 12 #include "base/rand_util.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "chrome/browser/local_discovery/privet_constants.h" 16 #include "chrome/browser/local_discovery/privet_constants.h"
17 #include "components/cloud_devices/common/printer_description.h" 17 #include "components/cloud_devices/common/printer_description.h"
18 #include "net/base/url_util.h" 18 #include "net/base/url_util.h"
19 #include "printing/pwg_raster_settings.h" 19 #include "printing/pwg_raster_settings.h"
20 #include "printing/units.h" 20 #include "printing/units.h"
21 #include "ui/gfx/text_elider.h" 21 #include "ui/gfx/text_elider.h"
22 #include "url/gurl.h" 22 #include "url/gurl.h"
23 23
24 #if defined(ENABLE_FULL_PRINTING)
25 #include "chrome/browser/local_discovery/pwg_raster_converter.h"
26 #endif // ENABLE_FULL_PRINTING
27
24 using namespace cloud_devices::printer; 28 using namespace cloud_devices::printer;
25 29
26 namespace cloud_print { 30 namespace cloud_print {
27 extern const char kContentTypeJSON[]; 31 extern const char kContentTypeJSON[];
28 } 32 }
29 33
30 namespace local_discovery { 34 namespace local_discovery {
31 35
32 namespace { 36 namespace {
33 const char kUrlPlaceHolder[] = "http://host/"; 37 const char kUrlPlaceHolder[] = "http://host/";
34 const char kPrivetRegisterActionArgName[] = "action"; 38 const char kPrivetRegisterActionArgName[] = "action";
35 const char kPrivetRegisterUserArgName[] = "user"; 39 const char kPrivetRegisterUserArgName[] = "user";
36 40
41 const int kPrivetCancelationTimeoutSeconds = 3;
42
43 #if defined(ENABLE_FULL_PRINTING)
37 const char kPrivetURLKeyUserName[] = "user_name"; 44 const char kPrivetURLKeyUserName[] = "user_name";
38 const char kPrivetURLKeyClientName[] = "client_name"; 45 const char kPrivetURLKeyClientName[] = "client_name";
39 const char kPrivetURLKeyJobname[] = "job_name"; 46 const char kPrivetURLKeyJobname[] = "job_name";
40 const char kPrivetURLKeyOffline[] = "offline"; 47 const char kPrivetURLKeyOffline[] = "offline";
41 const char kPrivetURLValueOffline[] = "1"; 48 const char kPrivetURLValueOffline[] = "1";
42 const char kPrivetURLValueClientName[] = "Chrome"; 49 const char kPrivetURLValueClientName[] = "Chrome";
43 50
44 const char kPrivetContentTypePDF[] = "application/pdf"; 51 const char kPrivetContentTypePDF[] = "application/pdf";
45 const char kPrivetContentTypePWGRaster[] = "image/pwg-raster"; 52 const char kPrivetContentTypePWGRaster[] = "image/pwg-raster";
46 const char kPrivetContentTypeAny[] = "*/*"; 53 const char kPrivetContentTypeAny[] = "*/*";
47 54
48 const char kPrivetKeyJobID[] = "job_id"; 55 const char kPrivetKeyJobID[] = "job_id";
49 56
50 const int kPrivetCancelationTimeoutSeconds = 3;
51
52 const int kPrivetLocalPrintMaxRetries = 2; 57 const int kPrivetLocalPrintMaxRetries = 2;
53
54 const int kPrivetLocalPrintDefaultTimeout = 5; 58 const int kPrivetLocalPrintDefaultTimeout = 5;
55 59
56 const size_t kPrivetLocalPrintMaxJobNameLength = 64; 60 const size_t kPrivetLocalPrintMaxJobNameLength = 64;
61 #endif // ENABLE_FULL_PRINTING
57 62
58 GURL CreatePrivetURL(const std::string& path) { 63 GURL CreatePrivetURL(const std::string& path) {
59 GURL url(kUrlPlaceHolder); 64 GURL url(kUrlPlaceHolder);
60 GURL::Replacements replacements; 65 GURL::Replacements replacements;
61 replacements.SetPathStr(path); 66 replacements.SetPathStr(path);
62 return url.ReplaceComponents(replacements); 67 return url.ReplaceComponents(replacements);
63 } 68 }
64 69
65 GURL CreatePrivetRegisterURL(const std::string& action, 70 GURL CreatePrivetRegisterURL(const std::string& action,
66 const std::string& user) { 71 const std::string& user) {
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 458
454 bool PrivetDataReadOperationImpl::OnRawData(PrivetURLFetcher* fetcher, 459 bool PrivetDataReadOperationImpl::OnRawData(PrivetURLFetcher* fetcher,
455 bool is_file, 460 bool is_file,
456 const std::string& data_str, 461 const std::string& data_str,
457 const base::FilePath& file_path) { 462 const base::FilePath& file_path) {
458 ResponseType type = (is_file) ? RESPONSE_TYPE_FILE : RESPONSE_TYPE_STRING; 463 ResponseType type = (is_file) ? RESPONSE_TYPE_FILE : RESPONSE_TYPE_STRING;
459 callback_.Run(type, data_str, file_path); 464 callback_.Run(type, data_str, file_path);
460 return true; 465 return true;
461 } 466 }
462 467
468 #if defined(ENABLE_FULL_PRINTING)
463 PrivetLocalPrintOperationImpl::PrivetLocalPrintOperationImpl( 469 PrivetLocalPrintOperationImpl::PrivetLocalPrintOperationImpl(
464 PrivetHTTPClient* privet_client, 470 PrivetHTTPClient* privet_client,
465 PrivetLocalPrintOperation::Delegate* delegate) 471 PrivetLocalPrintOperation::Delegate* delegate)
466 : privet_client_(privet_client), 472 : privet_client_(privet_client),
467 delegate_(delegate), 473 delegate_(delegate),
468 use_pdf_(false), 474 use_pdf_(false),
469 has_extended_workflow_(false), 475 has_extended_workflow_(false),
470 started_(false), 476 started_(false),
471 offline_(false), 477 offline_(false),
472 dpi_(printing::kDefaultPdfDpi), 478 dpi_(printing::kDefaultPdfDpi),
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 818
813 void PrivetLocalPrintOperationImpl::SetPageSize(const gfx::Size& page_size) { 819 void PrivetLocalPrintOperationImpl::SetPageSize(const gfx::Size& page_size) {
814 DCHECK(!started_); 820 DCHECK(!started_);
815 page_size_ = page_size; 821 page_size_ = page_size;
816 } 822 }
817 823
818 void PrivetLocalPrintOperationImpl::SetPWGRasterConverterForTesting( 824 void PrivetLocalPrintOperationImpl::SetPWGRasterConverterForTesting(
819 scoped_ptr<PWGRasterConverter> pwg_raster_converter) { 825 scoped_ptr<PWGRasterConverter> pwg_raster_converter) {
820 pwg_raster_converter_ = pwg_raster_converter.Pass(); 826 pwg_raster_converter_ = pwg_raster_converter.Pass();
821 } 827 }
828 #endif // ENABLE_FULL_PRINTING
822 829
823 PrivetHTTPClientImpl::PrivetHTTPClientImpl( 830 PrivetHTTPClientImpl::PrivetHTTPClientImpl(
824 const std::string& name, 831 const std::string& name,
825 const net::HostPortPair& host_port, 832 const net::HostPortPair& host_port,
826 net::URLRequestContextGetter* request_context) 833 net::URLRequestContextGetter* request_context)
827 : name_(name), request_context_(request_context), host_port_(host_port) {} 834 : name_(name), request_context_(request_context), host_port_(host_port) {}
828 835
829 PrivetHTTPClientImpl::~PrivetHTTPClientImpl() { 836 PrivetHTTPClientImpl::~PrivetHTTPClientImpl() {
830 } 837 }
831 838
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 scoped_ptr<PrivetJSONOperation> 921 scoped_ptr<PrivetJSONOperation>
915 PrivetV1HTTPClientImpl::CreateCapabilitiesOperation( 922 PrivetV1HTTPClientImpl::CreateCapabilitiesOperation(
916 const PrivetJSONOperation::ResultCallback& callback) { 923 const PrivetJSONOperation::ResultCallback& callback) {
917 return scoped_ptr<PrivetJSONOperation>(new PrivetJSONOperationImpl( 924 return scoped_ptr<PrivetJSONOperation>(new PrivetJSONOperationImpl(
918 info_client(), kPrivetCapabilitiesPath, "", callback)); 925 info_client(), kPrivetCapabilitiesPath, "", callback));
919 } 926 }
920 927
921 scoped_ptr<PrivetLocalPrintOperation> 928 scoped_ptr<PrivetLocalPrintOperation>
922 PrivetV1HTTPClientImpl::CreateLocalPrintOperation( 929 PrivetV1HTTPClientImpl::CreateLocalPrintOperation(
923 PrivetLocalPrintOperation::Delegate* delegate) { 930 PrivetLocalPrintOperation::Delegate* delegate) {
931 #if defined(ENABLE_FULL_PRINTING)
924 return scoped_ptr<PrivetLocalPrintOperation>( 932 return scoped_ptr<PrivetLocalPrintOperation>(
925 new PrivetLocalPrintOperationImpl(info_client(), delegate)); 933 new PrivetLocalPrintOperationImpl(info_client(), delegate));
934 #else
935 return scoped_ptr<PrivetLocalPrintOperation>();
936 #endif // ENABLE_FULL_PRINTING
926 } 937 }
927 938
928 } // namespace local_discovery 939 } // 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