diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-16 23:58:27 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-16 23:58:27 +0000 |
commit | b5ab398db97d13c76d332c6567c23a575858f8c4 (patch) | |
tree | 54a5771b49afbb92470d92b82bcac1a78d10f2f8 /printing | |
parent | 77bd2cefb7f0f8f437b47b3d6a3dd458b8d4fe2e (diff) | |
download | chromium_src-b5ab398db97d13c76d332c6567c23a575858f8c4.zip chromium_src-b5ab398db97d13c76d332c6567c23a575858f8c4.tar.gz chromium_src-b5ab398db97d13c76d332c6567c23a575858f8c4.tar.bz2 |
Make SharedMemory use uint32 instead of size_t. This removes the remaining size_t's from the IPC code.
Review URL: http://codereview.chromium.org/581001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39164 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing')
-rw-r--r-- | printing/emf_win.cc | 15 | ||||
-rw-r--r-- | printing/emf_win.h | 6 | ||||
-rw-r--r-- | printing/emf_win_unittest.cc | 4 | ||||
-rw-r--r-- | printing/pdf_metafile_mac.cc | 14 | ||||
-rw-r--r-- | printing/pdf_metafile_mac.h | 12 | ||||
-rw-r--r-- | printing/pdf_metafile_mac_unittest.cc | 2 | ||||
-rw-r--r-- | printing/pdf_ps_metafile_cairo.cc | 8 | ||||
-rw-r--r-- | printing/pdf_ps_metafile_cairo.h | 8 | ||||
-rw-r--r-- | printing/pdf_ps_metafile_cairo_unittest.cc | 4 | ||||
-rw-r--r-- | printing/printed_document.cc | 4 | ||||
-rw-r--r-- | printing/printed_document.h | 2 |
11 files changed, 39 insertions, 40 deletions
diff --git a/printing/emf_win.cc b/printing/emf_win.cc index 42380443..f69d4fa 100644 --- a/printing/emf_win.cc +++ b/printing/emf_win.cc @@ -24,10 +24,9 @@ bool Emf::CreateDc(HDC sibling, const RECT* rect) { return hdc_ != NULL; } -bool Emf::CreateFromData(const void* buffer, size_t size) { +bool Emf::CreateFromData(const void* buffer, uint32 size) { DCHECK(!emf_ && !hdc_); - emf_ = SetEnhMetaFileBits(static_cast<unsigned>(size), - reinterpret_cast<const BYTE*>(buffer)); + emf_ = SetEnhMetaFileBits(size, reinterpret_cast<const BYTE*>(buffer)); DCHECK(emf_); return emf_ != NULL; } @@ -96,22 +95,22 @@ gfx::Rect Emf::GetBounds() const { header.rclBounds.bottom - header.rclBounds.top); } -unsigned Emf::GetDataSize() const { +uint32 Emf::GetDataSize() const { DCHECK(emf_ && !hdc_); return GetEnhMetaFileBits(emf_, 0, NULL); } -bool Emf::GetData(void* buffer, size_t size) const { +bool Emf::GetData(void* buffer, uint32 size) const { DCHECK(emf_ && !hdc_); DCHECK(buffer && size); - unsigned size2 = GetEnhMetaFileBits(emf_, static_cast<unsigned>(size), - reinterpret_cast<BYTE*>(buffer)); + uint32 size2 = + GetEnhMetaFileBits(emf_, size, reinterpret_cast<BYTE*>(buffer)); DCHECK(size2 == size); return size2 == size && size2 != 0; } bool Emf::GetData(std::vector<uint8>* buffer) const { - unsigned size = GetDataSize(); + uint32 size = GetDataSize(); if (!size) return false; diff --git a/printing/emf_win.h b/printing/emf_win.h index 7a21b1b..9f3dffe 100644 --- a/printing/emf_win.h +++ b/printing/emf_win.h @@ -34,7 +34,7 @@ class Emf { bool CreateDc(HDC sibling, const RECT* rect); // Load a EMF data stream. buffer contains EMF data. - bool CreateFromData(const void* buffer, size_t size); + bool CreateFromData(const void* buffer, uint32 size); // TODO(maruel): CreateFromFile(). If ever used. Maybe users would like to // have the ability to save web pages to an EMF file? Afterward, it is easy to @@ -68,10 +68,10 @@ class Emf { gfx::Rect GetBounds() const; // Retrieves the EMF stream size. - unsigned GetDataSize() const; + uint32 GetDataSize() const; // Retrieves the EMF stream. - bool GetData(void* buffer, size_t size) const; + bool GetData(void* buffer, uint32 size) const; // Retrieves the EMF stream. It is an helper function. bool GetData(std::vector<uint8>* buffer) const; diff --git a/printing/emf_win_unittest.cc b/printing/emf_win_unittest.cc index c3846f3..fb85282 100644 --- a/printing/emf_win_unittest.cc +++ b/printing/emf_win_unittest.cc @@ -34,7 +34,7 @@ class EmfPrintingTest : public testing::Test { } // namespace TEST(EmfTest, DC) { - static const int EMF_HEADER_SIZE = 128; + static const uint32 EMF_HEADER_SIZE = 128; // Simplest use case. printing::Emf emf; @@ -45,7 +45,7 @@ TEST(EmfTest, DC) { EXPECT_TRUE(emf.hdc() != NULL); // In theory, you'd use the HDC with GDI functions here. EXPECT_TRUE(emf.CloseDc()); - unsigned size = emf.GetDataSize(); + uint32 size = emf.GetDataSize(); EXPECT_EQ(size, EMF_HEADER_SIZE); std::vector<BYTE> data; EXPECT_TRUE(emf.GetData(&data)); diff --git a/printing/pdf_metafile_mac.cc b/printing/pdf_metafile_mac.cc index 381c6a3..ef2098c 100644 --- a/printing/pdf_metafile_mac.cc +++ b/printing/pdf_metafile_mac.cc @@ -42,7 +42,7 @@ CGContextRef PdfMetafile::Init() { return context_.get(); } -bool PdfMetafile::Init(const void* src_buffer, size_t src_buffer_size) { +bool PdfMetafile::Init(const void* src_buffer, uint32 src_buffer_size) { DCHECK(!context_.get()); DCHECK(!pdf_data_.get()); @@ -58,7 +58,7 @@ bool PdfMetafile::Init(const void* src_buffer, size_t src_buffer_size) { } bool PdfMetafile::CreateFromData(const void* src_buffer, - size_t src_buffer_size) { + uint32 src_buffer_size) { return Init(src_buffer, src_buffer_size); } @@ -123,7 +123,7 @@ bool PdfMetafile::RenderPage(unsigned int page_number, CGContextRef context, return true; } -size_t PdfMetafile::GetPageCount() const { +unsigned int PdfMetafile::GetPageCount() const { CGPDFDocumentRef pdf_doc = GetPDFDocument(); return pdf_doc ? CGPDFDocumentGetNumberOfPages(pdf_doc) : 0; } @@ -143,23 +143,23 @@ gfx::Rect PdfMetafile::GetPageBounds(unsigned int page_number) const { return gfx::Rect(page_rect); } -unsigned int PdfMetafile::GetDataSize() const { +uint32 PdfMetafile::GetDataSize() const { // PDF data is only valid/complete once the context is released. DCHECK(!context_); if (!pdf_data_) return 0; - return static_cast<unsigned int>(CFDataGetLength(pdf_data_)); + return static_cast<uint32>(CFDataGetLength(pdf_data_)); } -bool PdfMetafile::GetData(void* dst_buffer, size_t dst_buffer_size) const { +bool PdfMetafile::GetData(void* dst_buffer, uint32 dst_buffer_size) const { // PDF data is only valid/complete once the context is released. DCHECK(!context_); DCHECK(pdf_data_); DCHECK(dst_buffer); DCHECK_GT(dst_buffer_size, 0U); - size_t data_size = GetDataSize(); + uint32 data_size = GetDataSize(); if (dst_buffer_size > data_size) { return false; } diff --git a/printing/pdf_metafile_mac.h b/printing/pdf_metafile_mac.h index 61ba98e..6e50913 100644 --- a/printing/pdf_metafile_mac.h +++ b/printing/pdf_metafile_mac.h @@ -24,7 +24,7 @@ class PdfMetafile { // To create PDF data, callers should also call Init() to set up the // rendering context. // To create a metafile from existing Data, callers should also call - // Init(const void*, size_t). + // Init(const void*, uint32). PdfMetafile(); ~PdfMetafile() {} @@ -36,9 +36,9 @@ class PdfMetafile { CGContextRef Init(); // Initializes a copy of metafile from PDF data. Returns true on success. - bool Init(const void* src_buffer, size_t src_buffer_size); + bool Init(const void* src_buffer, uint32 src_buffer_size); // Alias for Init, for compatibility with Emf-based code. - bool CreateFromData(const void* src_buffer, size_t src_buffer_size); + bool CreateFromData(const void* src_buffer, uint32 src_buffer_size); // Prepares a new pdf page with the given width and height and a scale // factor to use for the drawing. @@ -55,7 +55,7 @@ class PdfMetafile { bool RenderPage(unsigned int page_number, CGContextRef context, const CGRect rect) const; - size_t GetPageCount() const; + unsigned int GetPageCount() const; // Returns the bounds of the given page. // Pages use a 1-based index. @@ -63,12 +63,12 @@ class PdfMetafile { // Returns the size of the underlying PDF data. Only valid after Close() has // been called. - unsigned int GetDataSize() const; + uint32 GetDataSize() const; // Copies the first |dst_buffer_size| bytes of the PDF data into |dst_buffer|. // Only valid after Close() has been called. // Returns true if the copy succeeds. - bool GetData(void* dst_buffer, size_t dst_buffer_size) const; + bool GetData(void* dst_buffer, uint32 dst_buffer_size) const; // Saves the raw PDF data to the given file. For testing only. // Returns true if writing succeeded. diff --git a/printing/pdf_metafile_mac_unittest.cc b/printing/pdf_metafile_mac_unittest.cc index 3a38e68..88f5c8f 100644 --- a/printing/pdf_metafile_mac_unittest.cc +++ b/printing/pdf_metafile_mac_unittest.cc @@ -29,7 +29,7 @@ TEST(PdfMetafileTest, Pdf) { pdf.Close(); // Check data size. - unsigned int size = pdf.GetDataSize(); + uint32 size = pdf.GetDataSize(); EXPECT_GT(size, 0U); // Get resulting data. diff --git a/printing/pdf_ps_metafile_cairo.cc b/printing/pdf_ps_metafile_cairo.cc index db70d08..31c1e8a 100644 --- a/printing/pdf_ps_metafile_cairo.cc +++ b/printing/pdf_ps_metafile_cairo.cc @@ -121,7 +121,7 @@ bool PdfPsMetafile::Init() { return true; } -bool PdfPsMetafile::Init(const void* src_buffer, size_t src_buffer_size) { +bool PdfPsMetafile::Init(const void* src_buffer, uint32 src_buffer_size) { // We need to check at least these two members to ensure Init() has not been // called before. Passing these two checks also implies that surface_, // page_surface_, and page_context_ are NULL, and current_page_ is empty. @@ -307,7 +307,7 @@ void PdfPsMetafile::Close() { CleanUpSurface(&surface_); } -unsigned int PdfPsMetafile::GetDataSize() const { +uint32 PdfPsMetafile::GetDataSize() const { // We need to check at least these two members to ensure that either Init() // has been called to initialize |all_pages_|, or metafile has been closed. // Passing these two checks also implies that surface_, page_surface_, and @@ -318,7 +318,7 @@ unsigned int PdfPsMetafile::GetDataSize() const { return all_pages_.size(); } -bool PdfPsMetafile::GetData(void* dst_buffer, size_t dst_buffer_size) const { +bool PdfPsMetafile::GetData(void* dst_buffer, uint32 dst_buffer_size) const { DCHECK(dst_buffer); DCHECK_GT(dst_buffer_size, 0u); // We need to check at least these two members to ensure that either Init() @@ -328,7 +328,7 @@ bool PdfPsMetafile::GetData(void* dst_buffer, size_t dst_buffer_size) const { DCHECK(!context_); DCHECK(!all_pages_.empty()); - size_t data_size = GetDataSize(); + uint32 data_size = GetDataSize(); if (dst_buffer_size > data_size) { return false; } diff --git a/printing/pdf_ps_metafile_cairo.h b/printing/pdf_ps_metafile_cairo.h index 1a7bd01..eff10d1 100644 --- a/printing/pdf_ps_metafile_cairo.h +++ b/printing/pdf_ps_metafile_cairo.h @@ -31,7 +31,7 @@ class PdfPsMetafile { // In the renderer process, callers should also call Init(void) to see if the // metafile can obtain all necessary rendering resources. - // In the browser process, callers should also call Init(const void*, size_t) + // In the browser process, callers should also call Init(const void*, uint32) // to initialize the buffer |all_pages_| to use SaveTo(). explicit PdfPsMetafile(const FileFormat& format); @@ -46,7 +46,7 @@ class PdfPsMetafile { // |src_buffer| should point to the shared memory which stores PDF/PS // contents generated in the renderer. // Note: Only call in the browser to initialize |all_pages_|. - bool Init(const void* src_buffer, size_t src_buffer_size); + bool Init(const void* src_buffer, uint32 src_buffer_size); FileFormat GetFileFormat() const { return format_; } @@ -70,12 +70,12 @@ class PdfPsMetafile { // Returns size of PDF/PS contents stored in buffer |all_pages_|. // This function should ONLY be called after PDF/PS file is closed. - unsigned int GetDataSize() const; + uint32 GetDataSize() const; // Copies PDF/PS contents stored in buffer |all_pages_| into |dst_buffer|. // This function should ONLY be called after PDF/PS file is closed. // Returns true only when success. - bool GetData(void* dst_buffer, size_t dst_buffer_size) const; + bool GetData(void* dst_buffer, uint32 dst_buffer_size) const; // Saves PDF/PS contents stored in buffer |all_pages_| into the file // associated with |fd|. diff --git a/printing/pdf_ps_metafile_cairo_unittest.cc b/printing/pdf_ps_metafile_cairo_unittest.cc index 6dfd70a..0510878 100644 --- a/printing/pdf_ps_metafile_cairo_unittest.cc +++ b/printing/pdf_ps_metafile_cairo_unittest.cc @@ -42,7 +42,7 @@ TEST_F(PdfPsTest, Pdf) { pdf.Close(); // Checks data size. - unsigned int size = pdf.GetDataSize(); + uint32 size = pdf.GetDataSize(); EXPECT_GT(size, 0u); // Gets resulting data. @@ -86,7 +86,7 @@ TEST_F(PdfPsTest, Ps) { ps.Close(); // Checks data size. - unsigned int size = ps.GetDataSize(); + uint32 size = ps.GetDataSize(); EXPECT_GT(size, 0u); // Gets resulting data. diff --git a/printing/printed_document.cc b/printing/printed_document.cc index 785b846..7452e0e 100644 --- a/printing/printed_document.cc +++ b/printing/printed_document.cc @@ -127,7 +127,7 @@ void PrintedDocument::DisconnectSource() { mutable_.source_ = NULL; } -size_t PrintedDocument::MemoryUsage() const { +uint32 PrintedDocument::MemoryUsage() const { std::vector< scoped_refptr<PrintedPage> > pages_copy; { AutoLock lock(lock_); @@ -140,7 +140,7 @@ size_t PrintedDocument::MemoryUsage() const { } } } - size_t total = 0; + uint32 total = 0; for (size_t i = 0; i < pages_copy.size(); ++i) { total += pages_copy[i]->native_metafile()->GetDataSize(); } diff --git a/printing/printed_document.h b/printing/printed_document.h index ca5e663..7b3079e 100644 --- a/printing/printed_document.h +++ b/printing/printed_document.h @@ -71,7 +71,7 @@ class PrintedDocument : public base::RefCountedThreadSafe<PrintedDocument> { // Retrieves the current memory usage of the renderer pages. // Note: locks for a short amount of time. - size_t MemoryUsage() const; + uint32 MemoryUsage() const; // Sets the number of pages in the document to be rendered. Can only be set // once. |