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 | |
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
41 files changed, 108 insertions, 106 deletions
diff --git a/app/clipboard/clipboard.cc b/app/clipboard/clipboard.cc index 54a7d90..9ac742d 100644 --- a/app/clipboard/clipboard.cc +++ b/app/clipboard/clipboard.cc @@ -20,13 +20,13 @@ namespace { // the bitmap data or -1 if the data is invalid. // returns: true if the bitmap size is valid, false otherwise. bool IsBitmapSafe(const Clipboard::ObjectMapParams& params, - size_t* bitmap_bytes) { + uint32* bitmap_bytes) { *bitmap_bytes = -1; if (params[1].size() != sizeof(gfx::Size)) return false; const gfx::Size* size = reinterpret_cast<const gfx::Size*>(&(params[1].front())); - size_t total_size = size->width(); + uint32 total_size = size->width(); // Using INT_MAX not SIZE_T_MAX to put a reasonable bound on things. if (INT_MAX / size->width() <= size->height()) return false; @@ -42,7 +42,7 @@ bool IsBitmapSafe(const Clipboard::ObjectMapParams& params, // Returns true if the clipboard data makes sense and it's safe to access the // bitmap. bool ValidatePlainBitmap(const Clipboard::ObjectMapParams& params) { - size_t bitmap_bytes = -1; + uint32 bitmap_bytes = -1; if (!IsBitmapSafe(params, &bitmap_bytes)) return false; if (bitmap_bytes != params[0].size()) @@ -56,7 +56,7 @@ bool ValidatePlainBitmap(const Clipboard::ObjectMapParams& params) { bool ValidateAndMapSharedBitmap(const Clipboard::ObjectMapParams& params, base::SharedMemory* bitmap_data) { using base::SharedMemory; - size_t bitmap_bytes = -1; + uint32 bitmap_bytes = -1; if (!IsBitmapSafe(params, &bitmap_bytes)) return false; diff --git a/app/clipboard/clipboard_unittest.cc b/app/clipboard/clipboard_unittest.cc index 8a2bd62..034e3a3 100644 --- a/app/clipboard/clipboard_unittest.cc +++ b/app/clipboard/clipboard_unittest.cc @@ -220,7 +220,7 @@ TEST_F(ClipboardTest, SharedBitmapTest) { 0x91E9F63A, 0xC31EA14F, 0x69AB32DF, 0x643A3FD1, }; gfx::Size fake_bitmap_size(3, 4); - size_t bytes = sizeof(fake_bitmap); + uint32 bytes = sizeof(fake_bitmap); // Create shared memory region. base::SharedMemory shared_buf; diff --git a/base/shared_memory.h b/base/shared_memory.h index 90bed59..48ba857 100644 --- a/base/shared_memory.h +++ b/base/shared_memory.h @@ -73,7 +73,7 @@ class SharedMemory { // If name is the empty string, use a unique name. // Returns true on success, false on failure. bool Create(const std::wstring& name, bool read_only, bool open_existing, - size_t size); + uint32 size); // Deletes resources associated with a shared memory segment based on name. // Not all platforms require this call. @@ -88,7 +88,7 @@ class SharedMemory { // Maps the shared memory into the caller's address space. // Returns true on success, false otherwise. The memory address // is accessed via the memory() accessor. - bool Map(size_t bytes); + bool Map(uint32 bytes); // Unmaps the shared memory from the caller's address space. // Returns true if successful; returns false on error or if the @@ -100,7 +100,7 @@ class SharedMemory { // shared memory, and not to those that opened shared memory // created externally. // Returns 0 if not opened or unknown. - size_t max_size() const { return max_size_; } + uint32 max_size() const { return max_size_; } // Gets a pointer to the opened memory space if it has been // Mapped via Map(). Returns NULL if it is not mapped. @@ -161,7 +161,7 @@ class SharedMemory { private: #if defined(OS_POSIX) - bool CreateOrOpen(const std::wstring &name, int posix_flags, size_t size); + bool CreateOrOpen(const std::wstring &name, int posix_flags, uint32 size); bool FilePathForMemoryName(const std::wstring& memname, FilePath* path); void LockOrUnlockCommon(int function); @@ -179,7 +179,7 @@ class SharedMemory { #endif void* memory_; bool read_only_; - size_t max_size_; + uint32 max_size_; #if !defined(OS_POSIX) SharedMemoryLock lock_; #endif diff --git a/base/shared_memory_posix.cc b/base/shared_memory_posix.cc index 5fff095..373ebf7 100644 --- a/base/shared_memory_posix.cc +++ b/base/shared_memory_posix.cc @@ -78,7 +78,7 @@ void SharedMemory::CloseHandle(const SharedMemoryHandle& handle) { } bool SharedMemory::Create(const std::wstring &name, bool read_only, - bool open_existing, size_t size) { + bool open_existing, uint32 size) { read_only_ = read_only; int posix_flags = 0; @@ -144,7 +144,7 @@ bool SharedMemory::FilePathForMemoryName(const std::wstring& memname, // In case we want to delete it later, it may be useful to save the value // of mem_filename after FilePathForMemoryName(). bool SharedMemory::CreateOrOpen(const std::wstring &name, - int posix_flags, size_t size) { + int posix_flags, uint32 size) { DCHECK(mapped_file_ == -1); file_util::ScopedFILE file_closer; @@ -206,7 +206,7 @@ bool SharedMemory::CreateOrOpen(const std::wstring &name, struct stat stat; if (fstat(fileno(fp), &stat) != 0) return false; - const size_t current_size = stat.st_size; + const uint32 current_size = stat.st_size; if (current_size != size) { if (ftruncate(fileno(fp), size) != 0) return false; @@ -233,7 +233,7 @@ bool SharedMemory::CreateOrOpen(const std::wstring &name, return true; } -bool SharedMemory::Map(size_t bytes) { +bool SharedMemory::Map(uint32 bytes) { if (mapped_file_ == -1) return false; diff --git a/base/shared_memory_unittest.cc b/base/shared_memory_unittest.cc index 6b95021..459b423 100644 --- a/base/shared_memory_unittest.cc +++ b/base/shared_memory_unittest.cc @@ -33,7 +33,7 @@ class MultipleThreadMain : public PlatformThread::Delegate { // PlatformThread::Delegate interface. void ThreadMain() { ScopedNSAutoreleasePool pool; // noop if not OSX - const int kDataSize = 1024; + const uint32 kDataSize = 1024; SharedMemory memory; bool rv = memory.Create(s_test_name_, false, true, kDataSize); EXPECT_TRUE(rv); @@ -77,7 +77,7 @@ class MultipleLockThread : public PlatformThread::Delegate { // PlatformThread::Delegate interface. void ThreadMain() { - const int kDataSize = sizeof(int); + const uint32 kDataSize = sizeof(int); SharedMemoryHandle handle = NULL; { SharedMemory memory1; @@ -115,7 +115,7 @@ class MultipleLockThread : public PlatformThread::Delegate { } // namespace TEST(SharedMemoryTest, OpenClose) { - const int kDataSize = 1024; + const uint32 kDataSize = 1024; std::wstring test_name = L"SharedMemoryOpenCloseTest"; // Open two handles to a memory segment, confirm that they are mapped @@ -234,7 +234,7 @@ TEST(SharedMemoryTest, AnonymousPrivate) { int i, j; int count = 4; bool rv; - const int kDataSize = 8192; + const uint32 kDataSize = 8192; scoped_array<SharedMemory> memories(new SharedMemory[count]); scoped_array<int*> pointers(new int*[count]); @@ -288,7 +288,7 @@ class SharedMemoryProcessTest : public MultiProcessTest { static int TaskTestMain() { int errors = 0; ScopedNSAutoreleasePool pool; // noop if not OSX - const int kDataSize = 1024; + const uint32 kDataSize = 1024; SharedMemory memory; bool rv = memory.Create(s_test_name_, false, true, kDataSize); EXPECT_TRUE(rv); diff --git a/base/shared_memory_win.cc b/base/shared_memory_win.cc index dd4c73b..4afad3a 100644 --- a/base/shared_memory_win.cc +++ b/base/shared_memory_win.cc @@ -62,7 +62,7 @@ void SharedMemory::CloseHandle(const SharedMemoryHandle& handle) { } bool SharedMemory::Create(const std::wstring &name, bool read_only, - bool open_existing, size_t size) { + bool open_existing, uint32 size) { DCHECK(mapped_file_ == NULL); name_ = name; @@ -102,7 +102,7 @@ bool SharedMemory::Open(const std::wstring &name, bool read_only) { return false; } -bool SharedMemory::Map(size_t bytes) { +bool SharedMemory::Map(uint32 bytes) { if (mapped_file_ == NULL) return false; diff --git a/chrome/browser/renderer_host/audio_renderer_host.cc b/chrome/browser/renderer_host/audio_renderer_host.cc index d49eac1..4e9c4db 100644 --- a/chrome/browser/renderer_host/audio_renderer_host.cc +++ b/chrome/browser/renderer_host/audio_renderer_host.cc @@ -291,7 +291,7 @@ uint32 AudioRendererHost::IPCAudioSource::OnMoreData(AudioOutputStream* stream, SubmitPacketRequest(&auto_lock); } else { // Low latency mode. - size = std::min(static_cast<uint32>(shared_memory_.max_size()), max_size); + size = std::min(shared_memory_.max_size(), max_size); memcpy(dest, shared_memory_.memory(), size); memset(shared_memory_.memory(), 0, shared_memory_.max_size()); shared_socket_->Send(&pending_bytes, sizeof(pending_bytes)); diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc index bb57e60..d5f7a55 100644 --- a/chrome/browser/renderer_host/resource_message_filter.cc +++ b/chrome/browser/renderer_host/resource_message_filter.cc @@ -939,7 +939,7 @@ void ResourceMessageFilter::OnDuplicateSection( #if defined(OS_MACOSX) void ResourceMessageFilter::OnAllocateSharedMemoryBuffer( - size_t buffer_size, + uint32 buffer_size, base::SharedMemoryHandle* handle) { base::SharedMemory shared_buf; shared_buf.Create(L"", false, false, buffer_size); diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h index 240227e..062ac7d 100644 --- a/chrome/browser/renderer_host/resource_message_filter.h +++ b/chrome/browser/renderer_host/resource_message_filter.h @@ -248,8 +248,8 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter, // Used to ask the browser to allocate a block of shared memory for the // renderer to send back data in, since shared memory can't be created // in the renderer on OS X due to the sandbox. - void OnAllocateSharedMemoryBuffer(size_t buffer_size, - base::SharedMemoryHandle* handle); + void OnAllocateSharedMemoryBuffer(uint32 buffer_size, + base::SharedMemoryHandle* handle); #endif void OnResourceTypeStats(const WebKit::WebCache::ResourceTypeStats& stats); diff --git a/chrome/browser/visitedlink_master.cc b/chrome/browser/visitedlink_master.cc index c2aa3fe..606261f 100644 --- a/chrome/browser/visitedlink_master.cc +++ b/chrome/browser/visitedlink_master.cc @@ -666,7 +666,7 @@ bool VisitedLinkMaster::GetDatabaseFileName(FilePath* filename) { // in so that it can be written to the shared memory bool VisitedLinkMaster::CreateURLTable(int32 num_entries, bool init_to_empty) { // The table is the size of the table followed by the entries. - int32 alloc_size = num_entries * sizeof(Fingerprint) + sizeof(SharedHeader); + uint32 alloc_size = num_entries * sizeof(Fingerprint) + sizeof(SharedHeader); // Create the shared memory object. shared_memory_ = new base::SharedMemory(); diff --git a/chrome/common/command_buffer_messages_internal.h b/chrome/common/command_buffer_messages_internal.h index 0969f1c..6d08dd3 100644 --- a/chrome/common/command_buffer_messages_internal.h +++ b/chrome/common/command_buffer_messages_internal.h @@ -53,7 +53,7 @@ IPC_BEGIN_MESSAGES(CommandBuffer) IPC_SYNC_MESSAGE_ROUTED1_2(CommandBufferMsg_GetTransferBuffer, int32 /* id */, base::SharedMemoryHandle /* transfer_buffer */, - size_t /* size */) + uint32 /* size */) #if defined(OS_MACOSX) // On Mac OS X the GPU plugin must be offscreen, because there is no diff --git a/chrome/common/plugin_messages_internal.h b/chrome/common/plugin_messages_internal.h index b5908a8..66df30b 100644 --- a/chrome/common/plugin_messages_internal.h +++ b/chrome/common/plugin_messages_internal.h @@ -204,7 +204,7 @@ IPC_BEGIN_MESSAGES(Plugin) IPC_SYNC_MESSAGE_ROUTED0_2(PluginMsg_Print, base::SharedMemoryHandle /* shared_memory*/, - size_t /* size */) + uint32 /* size */) IPC_SYNC_MESSAGE_ROUTED0_1(PluginMsg_GetPluginScriptableObject, int /* route_id */) diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index 008e53e..07b91a9 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -413,7 +413,7 @@ struct ViewHostMsg_DidPrintPage_Params { base::SharedMemoryHandle metafile_data_handle; // Size of the metafile data. - unsigned data_size; + uint32 data_size; // Cookie for the document to ensure correctness. int document_cookie; diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index 90500d1..8aef0f0 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -1636,12 +1636,12 @@ IPC_BEGIN_MESSAGES(ViewHost) // Asks the browser to create a block of shared memory for the renderer to pass // NativeMetafile data to the browser. IPC_SYNC_MESSAGE_ROUTED1_1(ViewHostMsg_AllocatePDFTransport, - size_t /* buffer size */, + uint32 /* buffer size */, base::SharedMemoryHandle /* browser handle */) // Asks the browser to create a block of shared memory for the renderer to // fill in and pass back to the browser. IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_AllocateSharedMemoryBuffer, - size_t /* buffer size */, + uint32 /* buffer size */, base::SharedMemoryHandle /* browser handle */) #endif diff --git a/chrome/common/resource_dispatcher_unittest.cc b/chrome/common/resource_dispatcher_unittest.cc index df658c0..d65abbe 100644 --- a/chrome/common/resource_dispatcher_unittest.cc +++ b/chrome/common/resource_dispatcher_unittest.cc @@ -24,7 +24,7 @@ static const char test_page_mime_type[] = "text/html"; static const char test_page_charset[] = ""; static const char test_page_contents[] = "<html><head><title>Google</title></head><body><h1>Google</h1></body></html>"; -static const int test_page_contents_len = arraysize(test_page_contents) - 1; +static const uint32 test_page_contents_len = arraysize(test_page_contents) - 1; // Listens for request response data and stores it so that it can be compared // to the reference data. diff --git a/chrome/plugin/command_buffer_stub.cc b/chrome/plugin/command_buffer_stub.cc index 9e80b14..09f4cdb 100644 --- a/chrome/plugin/command_buffer_stub.cc +++ b/chrome/plugin/command_buffer_stub.cc @@ -127,7 +127,7 @@ void CommandBufferStub::OnDestroyTransferBuffer(int32 id) { void CommandBufferStub::OnGetTransferBuffer( int32 id, base::SharedMemoryHandle* transfer_buffer, - size_t* size) { + uint32* size) { *transfer_buffer = base::SharedMemoryHandle(); *size = 0; diff --git a/chrome/plugin/command_buffer_stub.h b/chrome/plugin/command_buffer_stub.h index 539e241..f0d8ac0 100644 --- a/chrome/plugin/command_buffer_stub.h +++ b/chrome/plugin/command_buffer_stub.h @@ -48,7 +48,7 @@ class CommandBufferStub : public IPC::Channel::Listener, void OnDestroyTransferBuffer(int32 id); void OnGetTransferBuffer(int32 id, base::SharedMemoryHandle* transfer_buffer, - size_t* size); + uint32* size); #if defined(OS_MACOSX) void OnSetWindowSize(int32 width, int32 height); void SwapBuffersCallback(); diff --git a/chrome/plugin/webplugin_delegate_stub.cc b/chrome/plugin/webplugin_delegate_stub.cc index a24f7fa..7654058 100644 --- a/chrome/plugin/webplugin_delegate_stub.cc +++ b/chrome/plugin/webplugin_delegate_stub.cc @@ -278,7 +278,7 @@ void WebPluginDelegateStub::OnDidPaint() { } void WebPluginDelegateStub::OnPrint(base::SharedMemoryHandle* shared_memory, - size_t* size) { + uint32* size) { #if defined(OS_WIN) printing::NativeMetafile metafile; if (!metafile.CreateDc(NULL, NULL)) { @@ -407,7 +407,7 @@ void WebPluginDelegateStub::OnCreateCommandBuffer(int* route_id) { } void WebPluginDelegateStub::CreateSharedBuffer( - size_t size, + uint32 size, base::SharedMemory* shared_buf, base::SharedMemoryHandle* remote_handle) { if (!shared_buf->Create(std::wstring(), false, false, size)) { diff --git a/chrome/plugin/webplugin_delegate_stub.h b/chrome/plugin/webplugin_delegate_stub.h index efe93c10..36fda08 100644 --- a/chrome/plugin/webplugin_delegate_stub.h +++ b/chrome/plugin/webplugin_delegate_stub.h @@ -70,7 +70,7 @@ class WebPluginDelegateStub : public IPC::Channel::Listener, bool* handled, WebCursor* cursor); void OnPaint(const gfx::Rect& damaged_rect); void OnDidPaint(); - void OnPrint(base::SharedMemoryHandle* shared_memory, size_t* size); + void OnPrint(base::SharedMemoryHandle* shared_memory, uint32* size); void OnUpdateGeometry(const PluginMsg_UpdateGeometry_Param& param); void OnGetPluginScriptableObject(int* route_id); void OnSendJavaScriptStream(const GURL& url, @@ -98,7 +98,7 @@ class WebPluginDelegateStub : public IPC::Channel::Listener, int notify_id); void OnHTTPRangeRequestReply(unsigned long resource_id, int range_request_id); void OnCreateCommandBuffer(int* route_id); - void CreateSharedBuffer(size_t size, + void CreateSharedBuffer(uint32 size, base::SharedMemory* shared_buf, base::SharedMemoryHandle* remote_handle); diff --git a/chrome/renderer/command_buffer_proxy.cc b/chrome/renderer/command_buffer_proxy.cc index f1651db..2b71fa8 100644 --- a/chrome/renderer/command_buffer_proxy.cc +++ b/chrome/renderer/command_buffer_proxy.cc @@ -133,7 +133,7 @@ Buffer CommandBufferProxy::GetTransferBuffer(int32 id) { // Assuming we are in the renderer process, the service is responsible for // duplicating the handle. This might not be true for NaCl. base::SharedMemoryHandle handle; - size_t size; + uint32 size; if (!Send(new CommandBufferMsg_GetTransferBuffer(route_id_, id, &handle, diff --git a/chrome/renderer/mock_printer.cc b/chrome/renderer/mock_printer.cc index e8fbac0..235e056 100644 --- a/chrome/renderer/mock_printer.cc +++ b/chrome/renderer/mock_printer.cc @@ -145,43 +145,46 @@ int MockPrinter::GetPrintedPages() const { return page_number_; } -const MockPrinterPage* MockPrinter::GetPrintedPage(size_t pageno) const { +const MockPrinterPage* MockPrinter::GetPrintedPage(unsigned int pageno) const { if (pages_.size() > pageno) return pages_[pageno]; else return NULL; } -int MockPrinter::GetWidth(size_t page) const { +int MockPrinter::GetWidth(unsigned int page) const { if (printer_status_ != PRINTER_READY || page >= pages_.size()) return -1; return pages_[page]->width(); } -int MockPrinter::GetHeight(size_t page) const { +int MockPrinter::GetHeight(unsigned int page) const { if (printer_status_ != PRINTER_READY || page >= pages_.size()) return -1; return pages_[page]->height(); } -bool MockPrinter::GetBitmapChecksum(size_t page, std::string* checksum) const { +bool MockPrinter::GetBitmapChecksum( + unsigned int page, std::string* checksum) const { if (printer_status_ != PRINTER_READY || page >= pages_.size()) return false; *checksum = pages_[page]->image().checksum(); return true; } -bool MockPrinter::SaveSource(size_t page, const FilePath& filepath) const { +bool MockPrinter::SaveSource( + unsigned int page, const FilePath& filepath) const { if (printer_status_ != PRINTER_READY || page >= pages_.size()) return false; const uint8* source_data = pages_[page]->source_data(); - size_t source_size = pages_[page]->source_size(); + uint32 source_size = pages_[page]->source_size(); file_util::WriteFile(filepath, reinterpret_cast<const char*>(source_data), source_size); return true; } -bool MockPrinter::SaveBitmap(size_t page, const FilePath& filepath) const { +bool MockPrinter::SaveBitmap( + unsigned int page, const FilePath& filepath) const { if (printer_status_ != PRINTER_READY || page >= pages_.size()) return false; diff --git a/chrome/renderer/mock_printer.h b/chrome/renderer/mock_printer.h index 80f6c4b..c97f149 100644 --- a/chrome/renderer/mock_printer.h +++ b/chrome/renderer/mock_printer.h @@ -24,7 +24,7 @@ struct ViewHostMsg_DidPrintPage_Params; class MockPrinterPage : public base::RefCounted<MockPrinterPage> { public: MockPrinterPage(const void* source_data, - size_t source_size, + uint32 source_size, const printing::Image& image) : source_size_(source_size), image_(image) { @@ -40,11 +40,11 @@ class MockPrinterPage : public base::RefCounted<MockPrinterPage> { int width() const { return image_.size().width(); } int height() const { return image_.size().height(); } const uint8* source_data() const { return source_data_.get(); } - const size_t source_size() const { return source_size_; } + const uint32 source_size() const { return source_size_; } const printing::Image& image() const { return image_; } private: - size_t source_size_; + uint32 source_size_; scoped_array<uint8> source_data_; printing::Image image_; @@ -89,19 +89,19 @@ class MockPrinter { // Get a pointer to the printed page, returns NULL if pageno has not been // printed. The pointer is for read only view and should not be deleted. - const MockPrinterPage* GetPrintedPage(size_t pageno) const; + const MockPrinterPage* GetPrintedPage(unsigned int pageno) const; - int GetWidth(size_t page) const; - int GetHeight(size_t page) const; - bool GetBitmapChecksum(size_t page, std::string* checksum) const; - bool GetSource(size_t page, const void** data, size_t* size) const; - bool GetBitmap(size_t page, const void** data, size_t* size) const; - bool SaveSource(size_t page, const FilePath& filepath) const; - bool SaveBitmap(size_t page, const FilePath& filepath) const; + int GetWidth(unsigned int page) const; + int GetHeight(unsigned int page) const; + bool GetBitmapChecksum(unsigned int page, std::string* checksum) const; + bool GetSource(unsigned int page, const void** data, uint32* size) const; + bool GetBitmap(unsigned int page, const void** data, uint32* size) const; + bool SaveSource(unsigned int page, const FilePath& filepath) const; + bool SaveBitmap(unsigned int page, const FilePath& filepath) const; protected: int CreateDocumentCookie(); - bool GetChecksum(const void* data, size_t size, std::string* checksum) const; + bool GetChecksum(const void* data, uint32 size, std::string* checksum) const; private: // In pixels according to dpi_x and dpi_y. diff --git a/chrome/renderer/mock_render_thread.cc b/chrome/renderer/mock_render_thread.cc index bcb1517..1fa513f 100644 --- a/chrome/renderer/mock_render_thread.cc +++ b/chrome/renderer/mock_render_thread.cc @@ -122,7 +122,7 @@ void MockRenderThread::OnDuplicateSection( #if defined(OS_MACOSX) void MockRenderThread::OnAllocatePDFTransport( - size_t buffer_size, base::SharedMemoryHandle* handle) { + uint32 buffer_size, base::SharedMemoryHandle* handle) { base::SharedMemory shared_buf; shared_buf.Create(L"", false, false, buffer_size); if (!shared_buf.Map(buffer_size)) { diff --git a/chrome/renderer/mock_render_thread.h b/chrome/renderer/mock_render_thread.h index d4ed9f7..4f3b1d9 100644 --- a/chrome/renderer/mock_render_thread.h +++ b/chrome/renderer/mock_render_thread.h @@ -93,7 +93,7 @@ class MockRenderThread : public RenderThreadBase { #endif #if defined(OS_MACOSX) - void OnAllocatePDFTransport(size_t buffer_size, + void OnAllocatePDFTransport(uint32 buffer_size, base::SharedMemoryHandle* handle); #endif diff --git a/chrome/renderer/print_web_view_helper_linux.cc b/chrome/renderer/print_web_view_helper_linux.cc index 4b2f92f..415bf1d 100644 --- a/chrome/renderer/print_web_view_helper_linux.cc +++ b/chrome/renderer/print_web_view_helper_linux.cc @@ -80,7 +80,7 @@ void PrintWebViewHelper::PrintPages(const ViewMsg_PrintPages_Params& params, metafile.Close(); // Get the size of the resulting metafile. - unsigned int buf_size = metafile.GetDataSize(); + uint32 buf_size = metafile.GetDataSize(); DCHECK_GT(buf_size, 0u); base::FileDescriptor fd; diff --git a/chrome/renderer/print_web_view_helper_mac.mm b/chrome/renderer/print_web_view_helper_mac.mm index ae579bb..6e2cc2d 100644 --- a/chrome/renderer/print_web_view_helper_mac.mm +++ b/chrome/renderer/print_web_view_helper_mac.mm @@ -207,7 +207,7 @@ void PrintWebViewHelper::PrintPage(const ViewMsg_PrintPage_Params& params, base::SharedMemory shared_buf; // Ask the browser to create the shared memory for us. - unsigned int buf_size = metafile.GetDataSize(); + uint32 buf_size = metafile.GetDataSize(); base::SharedMemoryHandle shared_mem_handle; if (Send(new ViewHostMsg_AllocatePDFTransport(routing_id(), buf_size, &shared_mem_handle))) { diff --git a/chrome/renderer/print_web_view_helper_win.cc b/chrome/renderer/print_web_view_helper_win.cc index 1d9d595..6ba70a3 100644 --- a/chrome/renderer/print_web_view_helper_win.cc +++ b/chrome/renderer/print_web_view_helper_win.cc @@ -244,7 +244,7 @@ void PrintWebViewHelper::PrintPage(const ViewMsg_PrintPage_Params& params, } // Get the size of the compiled metafile. - unsigned buf_size = metafile.GetDataSize(); + uint32 buf_size = metafile.GetDataSize(); DCHECK_GT(buf_size, 128u); ViewHostMsg_DidPrintPage_Params page_params; page_params.data_size = 0; diff --git a/chrome/renderer/renderer_glue.cc b/chrome/renderer/renderer_glue.cc index 8b5d3fd..e4f8dd9 100644 --- a/chrome/renderer/renderer_glue.cc +++ b/chrome/renderer/renderer_glue.cc @@ -90,7 +90,7 @@ void ScopedClipboardWriterGlue::WriteBitmapFromPixels(const void* pixels, if (shared_buf_) return; - size_t buf_size = 4 * size.width() * size.height(); + uint32 buf_size = 4 * size.width() * size.height(); // Allocate a shared memory buffer to hold the bitmap bits. #if defined(OS_MACOSX) diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc index 6747ef0..178f07f 100644 --- a/chrome/renderer/webplugin_delegate_proxy.cc +++ b/chrome/renderer/webplugin_delegate_proxy.cc @@ -805,7 +805,7 @@ bool WebPluginDelegateProxy::BackgroundChanged( void WebPluginDelegateProxy::Print(gfx::NativeDrawingContext context) { base::SharedMemoryHandle shared_memory; - size_t size; + uint32 size; if (!Send(new PluginMsg_Print(instance_id_, &shared_memory, &size))) return; diff --git a/gpu/command_buffer/service/command_buffer_service.cc b/gpu/command_buffer/service/command_buffer_service.cc index 2716d3b..bd85dc1 100644 --- a/gpu/command_buffer/service/command_buffer_service.cc +++ b/gpu/command_buffer/service/command_buffer_service.cc @@ -33,7 +33,7 @@ bool CommandBufferService::Initialize(int32 size) { size_ = size; ring_buffer_.reset(new SharedMemory); - size_t size_bytes = size * sizeof(CommandBufferEntry); + uint32 size_bytes = size * sizeof(CommandBufferEntry); if (ring_buffer_->Create(std::wstring(), false, false, size_bytes)) { if (ring_buffer_->Map(size_bytes)) return true; 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. |