OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/printing/print_dialog_cloud.h" | 5 #include "chrome/browser/printing/print_dialog_cloud.h" |
6 | 6 |
7 | 7 |
8 #include "base/base64.h" | 8 #include "base/base64.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 664 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
665 scoped_refptr<base::RefCountedMemory> data; | 665 scoped_refptr<base::RefCountedMemory> data; |
666 int64 file_size = 0; | 666 int64 file_size = 0; |
667 if (file_util::GetFileSize(path_to_file, &file_size) && file_size != 0) { | 667 if (file_util::GetFileSize(path_to_file, &file_size) && file_size != 0) { |
668 std::string file_data; | 668 std::string file_data; |
669 if (file_size < kuint32max) { | 669 if (file_size < kuint32max) { |
670 file_data.reserve(static_cast<unsigned int>(file_size)); | 670 file_data.reserve(static_cast<unsigned int>(file_size)); |
671 } else { | 671 } else { |
672 DLOG(WARNING) << " print data file too large to reserve space"; | 672 DLOG(WARNING) << " print data file too large to reserve space"; |
673 } | 673 } |
674 if (file_util::ReadFileToString(path_to_file, &file_data)) { | 674 if (base::ReadFileToString(path_to_file, &file_data)) { |
675 data = base::RefCountedString::TakeString(&file_data); | 675 data = base::RefCountedString::TakeString(&file_data); |
676 } | 676 } |
677 } | 677 } |
678 // Proceed even for empty data to simplify testing. | 678 // Proceed even for empty data to simplify testing. |
679 BrowserThread::PostTask( | 679 BrowserThread::PostTask( |
680 BrowserThread::UI, FROM_HERE, | 680 BrowserThread::UI, FROM_HERE, |
681 base::Bind(&print_dialog_cloud::CreatePrintDialogForBytes, | 681 base::Bind(&print_dialog_cloud::CreatePrintDialogForBytes, |
682 browser_context, modal_parent, data, print_job_title, | 682 browser_context, modal_parent, data, print_job_title, |
683 print_ticket, file_type)); | 683 print_ticket, file_type)); |
684 if (delete_on_close) | 684 if (delete_on_close) |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
778 print_job_print_ticket, | 778 print_job_print_ticket, |
779 file_type, | 779 file_type, |
780 delete_on_close); | 780 delete_on_close); |
781 return true; | 781 return true; |
782 } | 782 } |
783 } | 783 } |
784 return false; | 784 return false; |
785 } | 785 } |
786 | 786 |
787 } // end namespace | 787 } // end namespace |
OLD | NEW |