From 1ca3d9fe25e86b5553b971a0f6f081883888f3aa Mon Sep 17 00:00:00 2001 From: jinbei09 Date: Fri, 24 Mar 2023 17:02:16 +0800 Subject: [PATCH] [M108 Aura Migration][NaCl][PPFwk] Add error logs + SVACE/DLOG/Static analysis fix Ported patch from tizen_7.0: https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/280926/ Change-Id: I90218f239233ab49f543279cf50cf1bf8705bb5e Signed-off-by: jinbei09 --- .../pepper/pepper_browser_font_singleton_host.cc | 3 +- .../pepper/pepper_external_file_ref_backend.cc | 7 ++ .../renderer_host/pepper/pepper_file_io_host.cc | 42 ++++++-- .../renderer_host/pepper/pepper_file_ref_host.cc | 22 +++- .../pepper/pepper_file_system_browser_host.cc | 24 ++++- .../pepper/pepper_host_resolver_message_filter.cc | 2 + .../pepper/pepper_internal_file_ref_backend.cc | 58 +++++++--- .../pepper/pepper_network_proxy_host.cc | 2 + .../renderer_host/pepper/pepper_printing_host.cc | 2 + .../pepper_tcp_server_socket_message_filter.cc | 6 +- .../pepper/pepper_tcp_socket_message_filter.cc | 53 +++++++-- .../pepper/pepper_truetype_font_host.cc | 20 +++- .../pepper/pepper_truetype_font_list_host.cc | 2 + content/renderer/pepper/audio_helper.cc | 3 + content/renderer/pepper/host_array_buffer_var.cc | 7 +- content/renderer/pepper/host_resource_var.cc | 5 +- content/renderer/pepper/pepper_audio_input_host.cc | 26 +++-- .../renderer/pepper/pepper_camera_device_host.cc | 22 ++-- .../pepper_device_enumeration_host_helper.cc | 9 +- .../renderer/pepper/pepper_file_chooser_host.cc | 8 +- .../pepper/pepper_file_ref_renderer_host.cc | 2 + content/renderer/pepper/pepper_file_system_host.cc | 29 +++-- content/renderer/pepper/pepper_graphics_2d_host.cc | 59 +++++++++-- .../pepper/pepper_media_stream_audio_track_host.cc | 6 +- .../renderer/pepper/pepper_plugin_instance_impl.cc | 17 ++- content/renderer/pepper/pepper_url_loader_host.cc | 22 +++- .../renderer/pepper/pepper_video_capture_host.cc | 24 ++++- .../renderer/pepper/pepper_video_decoder_host.cc | 4 +- .../renderer/pepper/pepper_video_decoder_host.h | 4 +- .../renderer/pepper/pepper_video_encoder_host.cc | 34 ++++-- content/renderer/pepper/pepper_websocket_host.cc | 35 ++++-- content/renderer/pepper/ppb_audio_impl.cc | 12 ++- content/renderer/pepper/ppb_video_decoder_impl.cc | 29 +++-- content/renderer/pepper/video_decoder_shim.cc | 1 + ppapi/c/ppb_file_io.h | 7 +- ppapi/cpp/file_io.h | 5 +- ppapi/cpp/ppp_entrypoints.cc | 6 +- ppapi/cpp/private/ext_crx_file_system_private.cc | 3 +- ppapi/cpp/private/uma_private.cc | 3 +- ppapi/cpp/var.cc | 14 ++- ppapi/host/resource_message_handler.cc | 1 + ppapi/proxy/audio_encoder_resource.cc | 5 +- ppapi/proxy/audio_input_resource.cc | 21 +++- ppapi/proxy/camera_device_resource.cc | 21 +++- ppapi/proxy/device_enumeration_resource_helper.cc | 16 ++- ppapi/proxy/file_chooser_resource.cc | 5 +- ppapi/proxy/file_io_resource.cc | 46 ++++++-- ppapi/proxy/file_ref_resource.cc | 5 +- ppapi/proxy/file_system_resource.cc | 9 +- ppapi/proxy/graphics_2d_resource.cc | 9 +- ppapi/proxy/host_resolver_resource.cc | 4 +- ppapi/proxy/host_resolver_resource_base.cc | 9 +- .../proxy/isolated_file_system_private_resource.cc | 4 +- ppapi/proxy/media_stream_audio_track_resource.cc | 29 +++-- ppapi/proxy/media_stream_video_track_resource.cc | 24 ++++- ppapi/proxy/network_list_resource.cc | 14 ++- ppapi/proxy/network_monitor_resource.cc | 13 ++- ppapi/proxy/network_proxy_resource.cc | 5 +- ppapi/proxy/plugin_resource.cc | 2 + ppapi/proxy/ppb_buffer_proxy.cc | 1 + ppapi/proxy/ppb_graphics_3d_proxy.cc | 10 +- ppapi/proxy/ppb_image_data_proxy.cc | 1 + ppapi/proxy/ppb_instance_proxy.cc | 13 ++- ppapi/proxy/ppb_message_loop_proxy.cc | 32 ++++-- ppapi/proxy/ppb_video_decoder_proxy.cc | 16 ++- ppapi/proxy/printing_resource.cc | 5 +- ppapi/proxy/raw_var_data.cc | 4 +- ppapi/proxy/serialized_handle.h | 2 +- ppapi/proxy/serialized_var.cc | 3 +- ppapi/proxy/tcp_server_socket_private_resource.cc | 33 ++++-- ppapi/proxy/tcp_socket_private_resource.cc | 3 + ppapi/proxy/tcp_socket_resource.cc | 8 +- ppapi/proxy/tcp_socket_resource_base.cc | 118 ++++++++++++++++----- ppapi/proxy/udp_socket_filter.cc | 15 ++- ppapi/proxy/udp_socket_private_resource.cc | 2 + ppapi/proxy/uma_private_resource.cc | 5 +- ppapi/proxy/url_loader_resource.cc | 22 +++- ppapi/proxy/video_capture_resource.cc | 23 +++- ppapi/proxy/video_decoder_resource.cc | 82 ++++++++++---- ppapi/proxy/video_encoder_resource.cc | 29 +++-- ppapi/proxy/websocket_resource.cc | 72 ++++++++++--- ppapi/shared_impl/file_io_state_manager.cc | 13 ++- ppapi/shared_impl/media_stream_buffer_manager.cc | 5 +- ppapi/shared_impl/ppb_graphics_3d_shared.cc | 4 + ppapi/shared_impl/ppb_instance_shared.cc | 9 +- ppapi/thunk/ppb_tcp_server_socket_private_thunk.cc | 5 +- ppapi/thunk/ppb_udp_socket_private_thunk.cc | 5 +- 87 files changed, 1101 insertions(+), 320 deletions(-) diff --git a/content/browser/renderer_host/pepper/pepper_browser_font_singleton_host.cc b/content/browser/renderer_host/pepper/pepper_browser_font_singleton_host.cc index e9d09c4..96196a2 100644 --- a/content/browser/renderer_host/pepper/pepper_browser_font_singleton_host.cc +++ b/content/browser/renderer_host/pepper/pepper_browser_font_singleton_host.cc @@ -6,7 +6,7 @@ #include #include - +#include "base/logging.h" #include "base/values.h" #include "content/common/font_list.h" #include "content/public/browser/browser_ppapi_host.h" @@ -60,6 +60,7 @@ int32_t FontMessageFilter::OnResourceMessageReceived( PpapiHostMsg_BrowserFontSingleton_GetFontFamilies, OnHostMsgGetFontFamilies) PPAPI_END_MESSAGE_MAP() + LOG(ERROR) << "Resource message unresolved"; return PP_ERROR_FAILED; } diff --git a/content/browser/renderer_host/pepper/pepper_external_file_ref_backend.cc b/content/browser/renderer_host/pepper/pepper_external_file_ref_backend.cc index a63c064..3c619f1 100644 --- a/content/browser/renderer_host/pepper/pepper_external_file_ref_backend.cc +++ b/content/browser/renderer_host/pepper/pepper_external_file_ref_backend.cc @@ -9,6 +9,7 @@ #include "base/bind.h" #include "base/files/file_path.h" #include "base/files/file_util.h" +#include "base/logging.h" #include "base/task/task_runner_util.h" #include "base/task/thread_pool.h" #include "content/browser/child_process_security_policy_impl.h" @@ -75,6 +76,7 @@ PepperExternalFileRefBackend::~PepperExternalFileRefBackend() {} int32_t PepperExternalFileRefBackend::MakeDirectory( ppapi::host::ReplyMessageContext reply_context, int32_t make_directory_flags) { + LOG(ERROR) << "Operation not supported for external filesystems"; // This operation isn't supported for external filesystems. return PP_ERROR_NOACCESS; } @@ -94,6 +96,7 @@ int32_t PepperExternalFileRefBackend::Touch( int32_t PepperExternalFileRefBackend::Delete( ppapi::host::ReplyMessageContext reply_context) { + LOG(ERROR) << "Operation not supported for external filesystems"; // This operation isn't supported for external filesystems. return PP_ERROR_NOACCESS; } @@ -101,6 +104,7 @@ int32_t PepperExternalFileRefBackend::Delete( int32_t PepperExternalFileRefBackend::Rename( ppapi::host::ReplyMessageContext reply_context, PepperFileRefHost* new_file_ref) { + LOG(ERROR) << "Operation not supported for external filesystems"; // This operation isn't supported for external filesystems. return PP_ERROR_NOACCESS; } @@ -119,6 +123,7 @@ int32_t PepperExternalFileRefBackend::Query( int32_t PepperExternalFileRefBackend::ReadDirectoryEntries( ppapi::host::ReplyMessageContext context) { + LOG(ERROR) << "Operation not supported for external filesystems"; // This operation isn't supported for external filesystems. return PP_ERROR_NOACCESS; } @@ -145,6 +150,7 @@ base::FilePath PepperExternalFileRefBackend::GetExternalFilePath() const { int32_t PepperExternalFileRefBackend::CanRead() const { if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile( render_process_id_, path_)) { + LOG(ERROR) << "Insufficient permissions - cannot read the file"; return PP_ERROR_NOACCESS; } return PP_OK; @@ -163,6 +169,7 @@ int32_t PepperExternalFileRefBackend::CanCreate() const { int32_t PepperExternalFileRefBackend::CanReadWrite() const { if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanCreateReadWriteFile( render_process_id_, path_)) { + LOG(ERROR) << "Insufficient permissions - cannot read or write to the file"; return PP_ERROR_NOACCESS; } return PP_OK; diff --git a/content/browser/renderer_host/pepper/pepper_file_io_host.cc b/content/browser/renderer_host/pepper/pepper_file_io_host.cc index 40ff951..cc7834b 100644 --- a/content/browser/renderer_host/pepper/pepper_file_io_host.cc +++ b/content/browser/renderer_host/pepper/pepper_file_io_host.cc @@ -8,6 +8,7 @@ #include "base/bind.h" #include "base/callback.h" +#include "base/logging.h" #include "base/callback_forward.h" #include "base/callback_helpers.h" #include "base/memory/weak_ptr.h" @@ -134,6 +135,7 @@ PepperFileIOHost::PepperFileIOHost(BrowserPpapiHostImpl* host, {base::MayBlock(), base::TaskPriority::USER_VISIBLE, base::TaskShutdownBehavior::BLOCK_SHUTDOWN})), file_(task_runner_.get()), + resolved_render_process_id_(base::kNullProcessId), open_flags_(0), file_system_type_(PP_FILESYSTEMTYPE_INVALID), max_written_offset_(0), @@ -161,6 +163,7 @@ int32_t PepperFileIOHost::OnResourceMessageReceived( PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FileIO_RequestOSFileHandle, OnHostMsgRequestOSFileHandle) PPAPI_END_MESSAGE_MAP() + LOG(ERROR) << "Message not resolved"; return PP_ERROR_FAILED; } @@ -184,17 +187,23 @@ int32_t PepperFileIOHost::OnHostMsgOpen( uint32_t platform_file_flags = 0; if (!ppapi::PepperFileOpenFlagsToPlatformFileFlags(open_flags, - &platform_file_flags)) + &platform_file_flags)) { + LOG(ERROR); return PP_ERROR_BADARGUMENT; + } ppapi::host::ResourceHost* resource_host = host()->GetResourceHost(file_ref_resource); - if (!resource_host || !resource_host->IsFileRefHost()) + if (!resource_host || !resource_host->IsFileRefHost()) { + LOG(ERROR) << "Invalid Resource"; return PP_ERROR_BADRESOURCE; + } PepperFileRefHost* file_ref_host = static_cast(resource_host); - if (file_ref_host->GetFileSystemType() == PP_FILESYSTEMTYPE_INVALID) + if (file_ref_host->GetFileSystemType() == PP_FILESYSTEMTYPE_INVALID) { + LOG(ERROR) << "Invalid FileSystem type"; return PP_ERROR_FAILED; + } file_system_host_ = file_ref_host->GetFileSystemHost(); @@ -208,8 +217,10 @@ int32_t PepperFileIOHost::OnHostMsgOpen( file_system_url_.is_valid(); if (is_internal_type) { - if (!file_system_url_.is_valid()) + if (!file_system_url_.is_valid()) { + LOG(ERROR) << "Invalid URL"; return PP_ERROR_BADARGUMENT; + } // Not all external file systems are fully supported yet. // Whitelist the supported ones. @@ -219,20 +230,26 @@ int32_t PepperFileIOHost::OnHostMsgOpen( case storage::kFileSystemTypeDeviceMedia: break; default: + LOG(ERROR) << "External file system of type " + << file_system_url_.type() << " not supported"; return PP_ERROR_NOACCESS; } } - if (!CanOpenFileSystemURLWithPepperFlags( - open_flags, render_process_id_, file_system_url_)) + if (!CanOpenFileSystemURLWithPepperFlags(open_flags, render_process_id_, + file_system_url_)) { + LOG(ERROR) << "Cannot open file system URL with pepper flags"; return PP_ERROR_NOACCESS; + } GotUIThreadStuffForInternalFileSystems( context->MakeReplyMessageContext(), platform_file_flags, GetUIThreadStuffForInternalFileSystems(render_process_id_)); } else { base::FilePath path = file_ref_host->GetExternalFilePath(); - if (!CanOpenWithPepperFlags(open_flags, render_process_id_, path)) + if (!CanOpenWithPepperFlags(open_flags, render_process_id_, path)) { + LOG(ERROR) << "Cannot open with pepper flags"; return PP_ERROR_NOACCESS; + } GetUIThreadTaskRunner({})->PostTaskAndReplyWithResult( FROM_HERE, base::BindOnce(&GetResolvedRenderProcessId, render_process_id_), @@ -331,6 +348,7 @@ int32_t PepperFileIOHost::OnHostMsgTouch( PPTimeToTime(last_access_time), PPTimeToTime(last_modified_time), base::BindOnce(&PepperFileIOHost::ExecutePlatformGeneralCallback, AsWeakPtr(), context->MakeReplyMessageContext()))) { + LOG(ERROR) << "Could not modify file access and modification times"; return PP_ERROR_FAILED; } @@ -345,8 +363,10 @@ int32_t PepperFileIOHost::OnHostMsgSetLength( FileIOStateManager::OPERATION_EXCLUSIVE, true); if (rv != PP_OK) return rv; - if (length < 0) + if (length < 0) { + LOG(ERROR) << "New length cannot be less than 0, length=" << length; return PP_ERROR_BADARGUMENT; + } // Quota checks are performed on the plugin side, in order to use the same // quota reservation and request system as Write. @@ -355,6 +375,7 @@ int32_t PepperFileIOHost::OnHostMsgSetLength( length, base::BindOnce(&PepperFileIOHost::ExecutePlatformGeneralCallback, AsWeakPtr(), context->MakeReplyMessageContext()))) { + LOG(ERROR) << "SetLength failed"; return PP_ERROR_FAILED; } @@ -372,6 +393,7 @@ int32_t PepperFileIOHost::OnHostMsgFlush( if (!file_.Flush( base::BindOnce(&PepperFileIOHost::ExecutePlatformGeneralCallback, AsWeakPtr(), context->MakeReplyMessageContext()))) { + LOG(ERROR) << "Flush failed"; return PP_ERROR_FAILED; } @@ -412,8 +434,10 @@ void PepperFileIOHost::DidCloseFile(base::File::Error /*error*/) { int32_t PepperFileIOHost::OnHostMsgRequestOSFileHandle( ppapi::host::HostMessageContext* context) { - if (open_flags_ != PP_FILEOPENFLAG_READ && file_system_host_->ChecksQuota()) + if (open_flags_ != PP_FILEOPENFLAG_READ && file_system_host_->ChecksQuota()) { + LOG(ERROR); return PP_ERROR_FAILED; + } GURL document_url = browser_ppapi_host_->GetDocumentURLForInstance(pp_instance()); diff --git a/content/browser/renderer_host/pepper/pepper_file_ref_host.cc b/content/browser/renderer_host/pepper/pepper_file_ref_host.cc index de491d7..357c0d5 100644 --- a/content/browser/renderer_host/pepper/pepper_file_ref_host.cc +++ b/content/browser/renderer_host/pepper/pepper_file_ref_host.cc @@ -7,6 +7,7 @@ #include #include +#include "base/logging.h" #include "content/browser/renderer_host/pepper/pepper_external_file_ref_backend.h" #include "content/browser/renderer_host/pepper/pepper_file_system_browser_host.h" #include "content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.h" @@ -129,32 +130,38 @@ PepperFileRefHost::GetFileSystemHost() const { int32_t PepperFileRefHost::CanRead() const { if (backend_) return backend_->CanRead(); + LOG(ERROR) << "Invalid PepperFileRefBackend"; return PP_ERROR_FAILED; } int32_t PepperFileRefHost::CanWrite() const { if (backend_) return backend_->CanWrite(); + LOG(ERROR) << "Invalid PepperFileRefBackend"; return PP_ERROR_FAILED; } int32_t PepperFileRefHost::CanCreate() const { if (backend_) return backend_->CanCreate(); + LOG(ERROR) << "Invalid PepperFileRefBackend"; return PP_ERROR_FAILED; } int32_t PepperFileRefHost::CanReadWrite() const { if (backend_) return backend_->CanReadWrite(); + LOG(ERROR) << "Invalid PepperFileRefBackend"; return PP_ERROR_FAILED; } int32_t PepperFileRefHost::OnResourceMessageReceived( const IPC::Message& msg, ppapi::host::HostMessageContext* context) { - if (!backend_) + if (!backend_) { + LOG(ERROR) << "Invalid PepperFileRefBackend"; return PP_ERROR_FAILED; + } PPAPI_BEGIN_MESSAGE_MAP(PepperFileRefHost, msg) PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileRef_MakeDirectory, @@ -168,6 +175,7 @@ int32_t PepperFileRefHost::OnResourceMessageReceived( PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FileRef_GetAbsolutePath, OnGetAbsolutePath) PPAPI_END_MESSAGE_MAP() + LOG(ERROR) << "Resource message unresolved"; return PP_ERROR_FAILED; } @@ -208,14 +216,18 @@ int32_t PepperFileRefHost::OnRename(ppapi::host::HostMessageContext* context, ResourceHost* resource_host = host_->GetPpapiHost()->GetResourceHost(new_file_ref); - if (!resource_host) + if (!resource_host) { + LOG(ERROR) << "Invalid resource host"; return PP_ERROR_BADRESOURCE; + } PepperFileRefHost* file_ref_host = nullptr; if (resource_host->IsFileRefHost()) file_ref_host = static_cast(resource_host); - if (!file_ref_host) + if (!file_ref_host) { + LOG(ERROR) << "Invalid file ref host"; return PP_ERROR_BADRESOURCE; + } rv = file_ref_host->CanCreate(); if (rv != PP_OK) @@ -242,8 +254,10 @@ int32_t PepperFileRefHost::OnReadDirectoryEntries( int32_t PepperFileRefHost::OnGetAbsolutePath( ppapi::host::HostMessageContext* context) { if (!host_->GetPpapiHost()->permissions().HasPermission( - ppapi::PERMISSION_PRIVATE)) + ppapi::PERMISSION_PRIVATE)) { + LOG(ERROR) << "Insufficient permission"; return PP_ERROR_NOACCESS; + } return backend_->GetAbsolutePath(context->MakeReplyMessageContext()); } diff --git a/content/browser/renderer_host/pepper/pepper_file_system_browser_host.cc b/content/browser/renderer_host/pepper/pepper_file_system_browser_host.cc index 734ba2c..3b441b0 100644 --- a/content/browser/renderer_host/pepper/pepper_file_system_browser_host.cc +++ b/content/browser/renderer_host/pepper/pepper_file_system_browser_host.cc @@ -6,6 +6,7 @@ #include "base/bind.h" #include "base/callback.h" +#include "base/logging.h" #include "base/task/task_runner_util.h" #include "base/threading/sequenced_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h" @@ -374,6 +375,7 @@ int32_t PepperFileSystemBrowserHost::OnResourceMessageReceived( PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileSystem_ReserveQuota, OnHostMsgReserveQuota) PPAPI_END_MESSAGE_MAP() + LOG(ERROR) << "Resource message not resolved"; return PP_ERROR_FAILED; } @@ -454,19 +456,24 @@ int32_t PepperFileSystemBrowserHost::OnHostMsgOpen( // Figure out why. Why is the file system size signed? // Not allow multiple opens. - if (called_open_) + if (called_open_) { + LOG(ERROR) << "Open has already been called - Not allow multiple opens"; return PP_ERROR_INPROGRESS; + } called_open_ = true; storage::FileSystemType file_system_type = PepperFileSystemTypeToFileSystemType(type_); - if (file_system_type == storage::kFileSystemTypeUnknown) + if (file_system_type == storage::kFileSystemTypeUnknown) { + LOG(ERROR) << "Unknown file system type"; return PP_ERROR_FAILED; + } int render_process_id = 0; int unused; if (!browser_ppapi_host_->GetRenderFrameIDsForInstance( pp_instance(), &render_process_id, &unused)) { + LOG(ERROR); return PP_ERROR_FAILED; } @@ -486,19 +493,24 @@ int32_t PepperFileSystemBrowserHost::OnHostMsgInitIsolatedFileSystem( const std::string& fsid, PP_IsolatedFileSystemType_Private type) { // Do not allow multiple opens. - if (called_open_) + if (called_open_) { + LOG(ERROR) << "Open has already been called - Not allow multiple opens"; return PP_ERROR_INPROGRESS; + } called_open_ = true; // Do a sanity check. - if (!storage::ValidateIsolatedFileSystemId(fsid)) + if (!storage::ValidateIsolatedFileSystemId(fsid)) { + LOG(ERROR); return PP_ERROR_BADARGUMENT; + } int render_process_id = 0; int unused; if (!browser_ppapi_host_->GetRenderFrameIDsForInstance( pp_instance(), &render_process_id, &unused)) { storage::IsolatedContext::GetInstance()->RevokeFileSystem(fsid); + LOG(ERROR); return PP_ERROR_FAILED; } @@ -525,8 +537,10 @@ int32_t PepperFileSystemBrowserHost::OnHostMsgReserveQuota( DCHECK(ChecksQuota()); DCHECK_GT(amount, 0); - if (reserving_quota_) + if (reserving_quota_) { + LOG(ERROR) << "Reserving quota in progress"; return PP_ERROR_INPROGRESS; + } reserving_quota_ = true; int64_t reservation_amount = diff --git a/content/browser/renderer_host/pepper/pepper_host_resolver_message_filter.cc b/content/browser/renderer_host/pepper/pepper_host_resolver_message_filter.cc index b3bdb63..cec3221 100644 --- a/content/browser/renderer_host/pepper/pepper_host_resolver_message_filter.cc +++ b/content/browser/renderer_host/pepper/pepper_host_resolver_message_filter.cc @@ -115,6 +115,7 @@ int32_t PepperHostResolverMessageFilter::OnResourceMessageReceived( PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_HostResolver_Resolve, OnMsgResolve) PPAPI_END_MESSAGE_MAP() + LOG(ERROR) << "Resource message unresolved"; return PP_ERROR_FAILED; } @@ -132,6 +133,7 @@ int32_t PepperHostResolverMessageFilter::OnMsgResolve( &request, render_process_id_, render_frame_id_)) { + LOG(ERROR) << "Insufficient permissions"; return PP_ERROR_NOACCESS; } diff --git a/content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.cc b/content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.cc index 351fe8c..2d960db 100644 --- a/content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.cc +++ b/content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.cc @@ -12,6 +12,7 @@ #include "base/bind.h" #include "base/callback.h" #include "base/files/file_util.h" +#include "base/logging.h" #include "base/strings/escape.h" #include "content/browser/child_process_security_policy_impl.h" #include "content/browser/file_system/browser_file_system_helper.h" @@ -217,9 +218,10 @@ void PepperInternalFileRefBackend::GetMetadataCompleteOnIOThread( int32_t PepperInternalFileRefBackend::MakeDirectory( ppapi::host::ReplyMessageContext reply_context, int32_t make_directory_flags) { - if (!GetFileSystemURL().is_valid()) + if (!GetFileSystemURL().is_valid()) { + LOG(ERROR) << "Invalid file system URL"; return PP_ERROR_FAILED; - + } bool exclusive = !!(make_directory_flags & PP_MAKEDIRECTORYFLAG_EXCLUSIVE); bool recursive = !!(make_directory_flags & PP_MAKEDIRECTORYFLAG_WITH_ANCESTORS); @@ -238,9 +240,10 @@ int32_t PepperInternalFileRefBackend::Touch( ppapi::host::ReplyMessageContext reply_context, PP_Time last_access_time_in, PP_Time last_modified_time_in) { - if (!GetFileSystemURL().is_valid()) + if (!GetFileSystemURL().is_valid()) { + LOG(ERROR) << "Invalid file system URL"; return PP_ERROR_FAILED; - + } base::Time last_access_time = ppapi::PPTimeToTime(last_access_time_in); base::Time last_modified_time = ppapi::PPTimeToTime(last_modified_time_in); GetIOThreadTaskRunner({})->PostTask( @@ -256,9 +259,10 @@ int32_t PepperInternalFileRefBackend::Touch( int32_t PepperInternalFileRefBackend::Delete( ppapi::host::ReplyMessageContext reply_context) { - if (!GetFileSystemURL().is_valid()) + if (!GetFileSystemURL().is_valid()) { + LOG(ERROR) << "Invalid file system URL"; return PP_ERROR_FAILED; - + } GetIOThreadTaskRunner({})->PostTask( FROM_HERE, base::BindOnce( @@ -272,15 +276,20 @@ int32_t PepperInternalFileRefBackend::Delete( int32_t PepperInternalFileRefBackend::Rename( ppapi::host::ReplyMessageContext reply_context, PepperFileRefHost* new_file_ref) { - if (!GetFileSystemURL().is_valid()) + if (!GetFileSystemURL().is_valid()) { + LOG(ERROR) << "Invalid file system URL"; return PP_ERROR_FAILED; + } storage::FileSystemURL new_url = new_file_ref->GetFileSystemURL(); - if (!new_url.is_valid()) + if (!new_url.is_valid()) { + LOG(ERROR) << "Invalid new URL"; return PP_ERROR_FAILED; - if (!new_url.IsInSameFileSystem(GetFileSystemURL())) + } + if (!new_url.IsInSameFileSystem(GetFileSystemURL())) { + LOG(ERROR) << "The new URL is not in same file system"; return PP_ERROR_FAILED; - + } storage::FileSystemOperationRunner::CopyOrMoveOptionSet options = storage::FileSystemOperation::CopyOrMoveOptionSet(); GetIOThreadTaskRunner({})->PostTask( @@ -297,8 +306,10 @@ int32_t PepperInternalFileRefBackend::Rename( int32_t PepperInternalFileRefBackend::Query( ppapi::host::ReplyMessageContext reply_context) { - if (!GetFileSystemURL().is_valid()) + if (!GetFileSystemURL().is_valid()) { + LOG(ERROR) << "Invalid file system URL"; return PP_ERROR_FAILED; + } int fields = storage::FileSystemOperation::GET_METADATA_FIELD_IS_DIRECTORY | storage::FileSystemOperation::GET_METADATA_FIELD_SIZE | @@ -331,8 +342,10 @@ void PepperInternalFileRefBackend::GetMetadataComplete( int32_t PepperInternalFileRefBackend::ReadDirectoryEntries( ppapi::host::ReplyMessageContext reply_context) { - if (!GetFileSystemURL().is_valid()) + if (!GetFileSystemURL().is_valid()) { + LOG(ERROR) << "Invalid file system URL"; return PP_ERROR_FAILED; + } storage::FileSystemOperation::FileEntryList* accumulated_file_list = new storage::FileSystemOperation::FileEntryList; @@ -396,10 +409,13 @@ int32_t PepperInternalFileRefBackend::GetAbsolutePath( int32_t PepperInternalFileRefBackend::CanRead() const { storage::FileSystemURL url = GetFileSystemURL(); - if (!FileSystemURLIsValid(GetFileSystemContext().get(), url)) + if (!FileSystemURLIsValid(GetFileSystemContext().get(), url)) { + LOG(ERROR) << "Invalid file system URL"; return PP_ERROR_FAILED; + } if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFileSystemFile( render_process_id_, url)) { + LOG(ERROR) << "Insufficient permissions - cannot read file system file"; return PP_ERROR_NOACCESS; } return PP_OK; @@ -407,10 +423,13 @@ int32_t PepperInternalFileRefBackend::CanRead() const { int32_t PepperInternalFileRefBackend::CanWrite() const { storage::FileSystemURL url = GetFileSystemURL(); - if (!FileSystemURLIsValid(GetFileSystemContext().get(), url)) + if (!FileSystemURLIsValid(GetFileSystemContext().get(), url)) { + LOG(ERROR) << "Invalid file system URL"; return PP_ERROR_FAILED; + } if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanWriteFileSystemFile( render_process_id_, url)) { + LOG(ERROR) << "Insufficient permissions - cannot write to file system file"; return PP_ERROR_NOACCESS; } return PP_OK; @@ -418,10 +437,13 @@ int32_t PepperInternalFileRefBackend::CanWrite() const { int32_t PepperInternalFileRefBackend::CanCreate() const { storage::FileSystemURL url = GetFileSystemURL(); - if (!FileSystemURLIsValid(GetFileSystemContext().get(), url)) + if (!FileSystemURLIsValid(GetFileSystemContext().get(), url)) { + LOG(ERROR) << "Invalid file system URL"; return PP_ERROR_FAILED; + } if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanCreateFileSystemFile( render_process_id_, url)) { + LOG(ERROR) << "Insufficient permissions - cannot create file system file"; return PP_ERROR_NOACCESS; } return PP_OK; @@ -429,12 +451,16 @@ int32_t PepperInternalFileRefBackend::CanCreate() const { int32_t PepperInternalFileRefBackend::CanReadWrite() const { storage::FileSystemURL url = GetFileSystemURL(); - if (!FileSystemURLIsValid(GetFileSystemContext().get(), url)) + if (!FileSystemURLIsValid(GetFileSystemContext().get(), url)) { + LOG(ERROR) << "Invalid file system URL"; return PP_ERROR_FAILED; + } ChildProcessSecurityPolicyImpl* policy = ChildProcessSecurityPolicyImpl::GetInstance(); if (!policy->CanReadFileSystemFile(render_process_id_, url) || !policy->CanWriteFileSystemFile(render_process_id_, url)) { + LOG(ERROR) + << "Insufficient permissions: cannot read or write to file system file"; return PP_ERROR_NOACCESS; } return PP_OK; diff --git a/content/browser/renderer_host/pepper/pepper_network_proxy_host.cc b/content/browser/renderer_host/pepper/pepper_network_proxy_host.cc index 8718dd8..88af4be 100644 --- a/content/browser/renderer_host/pepper/pepper_network_proxy_host.cc +++ b/content/browser/renderer_host/pepper/pepper_network_proxy_host.cc @@ -5,6 +5,7 @@ #include "content/browser/renderer_host/pepper/pepper_network_proxy_host.h" #include "base/bind.h" +#include "base/logging.h" #include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h" #include "content/browser/renderer_host/pepper/pepper_proxy_lookup_helper.h" #include "content/browser/renderer_host/pepper/pepper_socket_utils.h" @@ -115,6 +116,7 @@ int32_t PepperNetworkProxyHost::OnResourceMessageReceived( PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_NetworkProxy_GetProxyForURL, OnMsgGetProxyForURL) PPAPI_END_MESSAGE_MAP() + LOG(ERROR) << "Resource message not resolved"; return PP_ERROR_FAILED; } diff --git a/content/browser/renderer_host/pepper/pepper_printing_host.cc b/content/browser/renderer_host/pepper/pepper_printing_host.cc index 4770e7b..0c41f09 100644 --- a/content/browser/renderer_host/pepper/pepper_printing_host.cc +++ b/content/browser/renderer_host/pepper/pepper_printing_host.cc @@ -7,6 +7,7 @@ #include #include "base/bind.h" +#include "base/logging.h" #include "ppapi/c/dev/pp_print_settings_dev.h" #include "ppapi/c/pp_errors.h" #include "ppapi/host/dispatch_host_message.h" @@ -34,6 +35,7 @@ int32_t PepperPrintingHost::OnResourceMessageReceived( PpapiHostMsg_Printing_GetDefaultPrintSettings, OnGetDefaultPrintSettings) PPAPI_END_MESSAGE_MAP() + LOG(ERROR) << "Resource message unresolved"; return PP_ERROR_FAILED; } diff --git a/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.cc b/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.cc index 9f545bd..82f38ba 100644 --- a/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.cc +++ b/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.cc @@ -128,6 +128,7 @@ int32_t PepperTCPServerSocketMessageFilter::OnResourceMessageReceived( PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( PpapiHostMsg_TCPServerSocket_StopListening, OnMsgStopListening) PPAPI_END_MESSAGE_MAP() + LOG(ERROR) << "Resource message unresolved"; return PP_ERROR_FAILED; } @@ -146,6 +147,7 @@ int32_t PepperTCPServerSocketMessageFilter::OnMsgListen( &request, render_process_id_, render_frame_id_)) { + LOG(ERROR) << "Insufficient permissions"; return PP_ERROR_NOACCESS; } @@ -190,8 +192,10 @@ int32_t PepperTCPServerSocketMessageFilter::OnMsgAccept( DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK(context); - if (state_ != STATE_LISTENING) + if (state_ != STATE_LISTENING) { + LOG(ERROR) << "Socket not listening"; return PP_ERROR_FAILED; + } state_ = STATE_ACCEPT_IN_PROGRESS; ppapi::host::ReplyMessageContext reply_context( diff --git a/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.cc b/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.cc index 82b55dc..b280823 100644 --- a/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.cc +++ b/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.cc @@ -216,6 +216,7 @@ int32_t PepperTCPSocketMessageFilter::OnResourceMessageReceived( PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_TCPSocket_SetOption, OnMsgSetOption) PPAPI_END_MESSAGE_MAP() + LOG(ERROR) << "Resource message unresolved"; return PP_ERROR_FAILED; } @@ -304,6 +305,7 @@ int32_t PepperTCPSocketMessageFilter::OnMsgBind( // This is only supported by PPB_TCPSocket v1.1 or above. if (version_ != ppapi::TCP_SOCKET_VERSION_1_1_OR_ABOVE) { + LOG(ERROR) << "Supported only by PPB_TCPSocket v1.1 or above"; NOTREACHED(); return PP_ERROR_NOACCESS; } @@ -311,6 +313,7 @@ int32_t PepperTCPSocketMessageFilter::OnMsgBind( if (!pepper_socket_utils::CanUseSocketAPIs( external_plugin_, false /* private_api */, nullptr, render_process_id_, render_frame_id_)) { + LOG(ERROR) << "Cannot use Socket APIs"; return PP_ERROR_NOACCESS; } @@ -365,6 +368,7 @@ int32_t PepperTCPSocketMessageFilter::OnMsgConnect( // This is only supported by PPB_TCPSocket_Private. if (!IsPrivateAPI()) { NOTREACHED(); + LOG(ERROR) << "Supported only by PPB_TCPSocket_Private"; return PP_ERROR_NOACCESS; } @@ -373,6 +377,7 @@ int32_t PepperTCPSocketMessageFilter::OnMsgConnect( if (!pepper_socket_utils::CanUseSocketAPIs( external_plugin_, true /* private_api */, &request, render_process_id_, render_frame_id_)) { + LOG(ERROR) << "Insufficient permissions"; return PP_ERROR_NOACCESS; } @@ -421,6 +426,7 @@ int32_t PepperTCPSocketMessageFilter::OnMsgConnectWithNetAddress( if (!pepper_socket_utils::CanUseSocketAPIs(external_plugin_, IsPrivateAPI(), &request, render_process_id_, render_frame_id_)) { + LOG(ERROR) << "Insufficient permissions: Cannot connect with NetAddress"; return PP_ERROR_NOACCESS; } @@ -455,6 +461,7 @@ int32_t PepperTCPSocketMessageFilter::OnMsgSSLHandshake( // and there isn't pending read or write. if (!state_.IsValidTransition(TCPSocketState::SSL_CONNECT) || pending_read_context_.is_valid() || pending_write_context_.is_valid()) { + LOG(ERROR) << "Socket not connected or pending read or write"; return PP_ERROR_FAILED; } @@ -512,13 +519,17 @@ int32_t PepperTCPSocketMessageFilter::OnMsgRead( // This only covers the case where the socket was explicitly closed from the // caller, or the filter is being destroyed. Read errors and Mojo errors are // handled in TryRead(). - if (!state_.IsConnected()) + if (!state_.IsConnected()) { + LOG(ERROR) << "Not connected"; return PP_ERROR_FAILED; - + } if (pending_read_context_.is_valid()) return PP_ERROR_INPROGRESS; if (bytes_to_read <= 0 || bytes_to_read > TCPSocketResourceConstants::kMaxReadSize) { + LOG(ERROR) << "Incorrect number of bytes to read - " << bytes_to_read + << " Should be <= " << TCPSocketResourceConstants::kMaxReadSize + << " and > 0"; return PP_ERROR_BADARGUMENT; } @@ -533,8 +544,10 @@ int32_t PepperTCPSocketMessageFilter::OnMsgWrite( const ppapi::DataView& data) { DCHECK_CURRENTLY_ON(BrowserThread::UI); - if (!state_.IsConnected()) + if (!state_.IsConnected()) { + LOG(ERROR) << "Not connected"; return PP_ERROR_FAILED; + } if (pending_write_context_.is_valid()) return PP_ERROR_INPROGRESS; @@ -545,6 +558,9 @@ int32_t PepperTCPSocketMessageFilter::OnMsgWrite( if (data_size == 0 || data_size > static_cast(TCPSocketResourceConstants::kMaxWriteSize)) { + LOG(ERROR) << "Invalid data size - " << data_size << " should be <= " + << static_cast(TCPSocketResourceConstants::kMaxWriteSize) + << " and != 0"; return PP_ERROR_BADARGUMENT; } @@ -567,6 +583,7 @@ int32_t PepperTCPSocketMessageFilter::OnMsgListen( // This is only supported by PPB_TCPSocket v1.1 or above. if (version_ != ppapi::TCP_SOCKET_VERSION_1_1_OR_ABOVE) { + LOG(ERROR) << "Supported only by PPB_TCPSocket v1.1 or above"; NOTREACHED(); return PP_ERROR_NOACCESS; } @@ -577,6 +594,7 @@ int32_t PepperTCPSocketMessageFilter::OnMsgListen( if (!pepper_socket_utils::CanUseSocketAPIs( external_plugin_, false /* private_api */, &request, render_process_id_, render_frame_id_)) { + LOG(ERROR) << "Insufficient permissions"; return PP_ERROR_NOACCESS; } @@ -599,11 +617,14 @@ int32_t PepperTCPSocketMessageFilter::OnMsgAccept( const ppapi::host::HostMessageContext* context) { DCHECK_CURRENTLY_ON(BrowserThread::UI); - if (pending_accept_) + if (pending_accept_) { + LOG(WARNING) << "Pending accept"; return PP_ERROR_INPROGRESS; - if (state_.state() != TCPSocketState::LISTENING) + } + if (state_.state() != TCPSocketState::LISTENING) { + LOG(ERROR) << "Invalid socket state: " << static_cast(state_.state()); return PP_ERROR_FAILED; - + } DCHECK(server_socket_); pending_accept_ = true; @@ -646,9 +667,10 @@ int32_t PepperTCPSocketMessageFilter::OnMsgSetOption( switch (name) { case PP_TCPSOCKET_OPTION_NO_DELAY: { bool boolean_value = false; - if (!value.GetBool(&boolean_value)) + if (!value.GetBool(&boolean_value)) { + LOG(ERROR) << "Invalid socket option"; return PP_ERROR_BADARGUMENT; - + } // If |connected_socket_| is connecting or has connected, pass the setting // along. if (connected_socket_.is_bound()) { @@ -679,8 +701,13 @@ int32_t PepperTCPSocketMessageFilter::OnMsgSetOption( case PP_TCPSOCKET_OPTION_SEND_BUFFER_SIZE: { int32_t integer_value = 0; if (!value.GetInt32(&integer_value) || integer_value <= 0 || - integer_value > TCPSocketResourceConstants::kMaxSendBufferSize) + integer_value > TCPSocketResourceConstants::kMaxSendBufferSize) { + LOG(ERROR) << "Invalid send buffer size value - " << integer_value + << " should be <= " + << TCPSocketResourceConstants::kMaxSendBufferSize + << " and > 0"; return PP_ERROR_BADARGUMENT; + } // If |connected_socket_| is connecting or has connected, pass the setting // along. @@ -700,8 +727,13 @@ int32_t PepperTCPSocketMessageFilter::OnMsgSetOption( case PP_TCPSOCKET_OPTION_RECV_BUFFER_SIZE: { int32_t integer_value = 0; if (!value.GetInt32(&integer_value) || integer_value <= 0 || - integer_value > TCPSocketResourceConstants::kMaxReceiveBufferSize) + integer_value > TCPSocketResourceConstants::kMaxReceiveBufferSize) { + LOG(ERROR) << "Invalid receive buffer size - " << integer_value + << " should be <= " + << TCPSocketResourceConstants::kMaxReceiveBufferSize + << " and > 0"; return PP_ERROR_BADARGUMENT; + } // If |connected_socket_| is connecting or has connected, pass the setting // along. @@ -720,6 +752,7 @@ int32_t PepperTCPSocketMessageFilter::OnMsgSetOption( return PP_OK; } default: { + LOG(ERROR); NOTREACHED(); return PP_ERROR_BADARGUMENT; } diff --git a/content/browser/renderer_host/pepper/pepper_truetype_font_host.cc b/content/browser/renderer_host/pepper/pepper_truetype_font_host.cc index baf9ea5..5141e05 100644 --- a/content/browser/renderer_host/pepper/pepper_truetype_font_host.cc +++ b/content/browser/renderer_host/pepper/pepper_truetype_font_host.cc @@ -5,6 +5,7 @@ #include "content/browser/renderer_host/pepper/pepper_truetype_font_host.h" #include "base/bind.h" +#include "base/logging.h" #include "base/task/task_runner_util.h" #include "base/task/thread_pool.h" #include "content/browser/renderer_host/pepper/pepper_truetype_font.h" @@ -50,8 +51,10 @@ PepperTrueTypeFontHost::~PepperTrueTypeFontHost() { int32_t PepperTrueTypeFontHost::OnResourceMessageReceived( const IPC::Message& msg, HostMessageContext* context) { - if (!host()->permissions().HasPermission(ppapi::PERMISSION_DEV)) + if (!host()->permissions().HasPermission(ppapi::PERMISSION_DEV)) { + LOG(ERROR) << "No dev permission. Permission denied"; return PP_ERROR_FAILED; + } PPAPI_BEGIN_MESSAGE_MAP(PepperTrueTypeFontHost, msg) PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_TrueTypeFont_GetTableTags, @@ -59,13 +62,16 @@ int32_t PepperTrueTypeFontHost::OnResourceMessageReceived( PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_TrueTypeFont_GetTable, OnHostMsgGetTable) PPAPI_END_MESSAGE_MAP() + LOG(ERROR) << "Resource message unresolved"; return PP_ERROR_FAILED; } int32_t PepperTrueTypeFontHost::OnHostMsgGetTableTags( HostMessageContext* context) { - if (!font_.get()) + if (!font_.get()) { + LOG(ERROR) << "Font not found"; return PP_ERROR_FAILED; + } // Get font data on a thread that allows slow blocking operations. std::vector* tags = new std::vector(); @@ -83,10 +89,16 @@ int32_t PepperTrueTypeFontHost::OnHostMsgGetTable(HostMessageContext* context, uint32_t table, int32_t offset, int32_t max_data_length) { - if (!font_.get()) + if (!font_.get()) { + LOG(ERROR) << "Font not found"; return PP_ERROR_FAILED; - if (offset < 0 || max_data_length < 0) + } + if (offset < 0 || max_data_length < 0) { + LOG(ERROR) << "Offset should be greater or equal to 0, offset=" << offset + << " Max data length should be greater or equal to 0," + << " max_data_length=" << max_data_length; return PP_ERROR_BADARGUMENT; + } // Get font data on a thread that allows slow blocking operations. std::string* data = new std::string(); diff --git a/content/browser/renderer_host/pepper/pepper_truetype_font_list_host.cc b/content/browser/renderer_host/pepper/pepper_truetype_font_list_host.cc index b5a31e5..954a3f6 100644 --- a/content/browser/renderer_host/pepper/pepper_truetype_font_list_host.cc +++ b/content/browser/renderer_host/pepper/pepper_truetype_font_list_host.cc @@ -8,6 +8,7 @@ #include +#include "base/logging.h" #include "base/numerics/safe_conversions.h" #include "content/browser/renderer_host/pepper/pepper_truetype_font_list.h" #include "content/common/font_list.h" @@ -70,6 +71,7 @@ int32_t TrueTypeFontMessageFilter::OnResourceMessageReceived( PpapiHostMsg_TrueTypeFontSingleton_GetFontsInFamily, OnHostMsgGetFontsInFamily) PPAPI_END_MESSAGE_MAP() + LOG(ERROR) << "Resource message unresolved"; return PP_ERROR_FAILED; } diff --git a/content/renderer/pepper/audio_helper.cc b/content/renderer/pepper/audio_helper.cc index 6a1dd8e..756323b 100644 --- a/content/renderer/pepper/audio_helper.cc +++ b/content/renderer/pepper/audio_helper.cc @@ -7,6 +7,7 @@ #include #include "base/check.h" +#include "base/logging.h" #include "content/common/pepper_file_util.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_errors.h" @@ -27,6 +28,7 @@ int32_t AudioHelper::GetSyncSocketImpl(int* sync_socket) { socket_for_create_callback_->handle()); return PP_OK; } + LOG(ERROR) << "Cannot get sync socket"; return PP_ERROR_FAILED; } @@ -35,6 +37,7 @@ int32_t AudioHelper::GetSharedMemoryImpl(base::UnsafeSharedMemoryRegion** shm) { *shm = &shared_memory_for_create_callback_; return PP_OK; } + LOG(ERROR) << "Cannot get shared memory"; return PP_ERROR_FAILED; } diff --git a/content/renderer/pepper/host_array_buffer_var.cc b/content/renderer/pepper/host_array_buffer_var.cc index 678f6af..e7bf9bc 100644 --- a/content/renderer/pepper/host_array_buffer_var.cc +++ b/content/renderer/pepper/host_array_buffer_var.cc @@ -66,6 +66,11 @@ bool HostArrayBufferVar::CopyToNewShmem( if (!shm.IsValid()) return false; + HostGlobals* hg = HostGlobals::Get(); + PluginModule* pm = hg->GetModule(hg->GetModuleForInstance(instance)); + if (!pm) + return false; + base::WritableSharedMemoryMapping shm_mapping = shm.MapAt(0, ByteLength()); if (!shm_mapping.IsValid()) return false; @@ -73,8 +78,6 @@ bool HostArrayBufferVar::CopyToNewShmem( // Duplicate the handle here; the UnsafeSharedMemoryRegion destructor closes // its handle on us. - HostGlobals* hg = HostGlobals::Get(); - PluginModule* pm = hg->GetModule(hg->GetModuleForInstance(instance)); *plugin_shm_region = pm->renderer_ppapi_host()->ShareUnsafeSharedMemoryRegionWithRemote(shm); diff --git a/content/renderer/pepper/host_resource_var.cc b/content/renderer/pepper/host_resource_var.cc index ab510a8..bee389a 100644 --- a/content/renderer/pepper/host_resource_var.cc +++ b/content/renderer/pepper/host_resource_var.cc @@ -6,7 +6,10 @@ namespace content { -HostResourceVar::HostResourceVar() : pp_resource_(0) {} +HostResourceVar::HostResourceVar() + : pp_resource_(0), + pending_renderer_host_id_(0), + pending_browser_host_id_(0) {} HostResourceVar::HostResourceVar(PP_Resource pp_resource) : pp_resource_(pp_resource), diff --git a/content/renderer/pepper/pepper_audio_input_host.cc b/content/renderer/pepper/pepper_audio_input_host.cc index bae18a3..bf56b1f 100644 --- a/content/renderer/pepper/pepper_audio_input_host.cc +++ b/content/renderer/pepper/pepper_audio_input_host.cc @@ -48,6 +48,7 @@ int32_t PepperAudioInputHost::OnResourceMessageReceived( OnStartOrStop) PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_AudioInput_Close, OnClose) PPAPI_END_MESSAGE_MAP() + LOG(ERROR) << "Resource message unresolved"; return PP_ERROR_FAILED; } @@ -66,14 +67,20 @@ int32_t PepperAudioInputHost::OnOpen(ppapi::host::HostMessageContext* context, const std::string& device_id, PP_AudioSampleRate sample_rate, uint32_t sample_frame_count) { - if (open_context_.is_valid()) + if (open_context_.is_valid()) { + LOG(ERROR) << "Invalid open context"; return PP_ERROR_INPROGRESS; - if (audio_input_) + } + if (audio_input_) { + LOG(ERROR) << "Audio input is not NULL"; return PP_ERROR_FAILED; + } GURL document_url = renderer_ppapi_host_->GetDocumentURL(pp_instance()); - if (!document_url.is_valid()) + if (!document_url.is_valid()) { + LOG(ERROR) << "Invalid document URL"; return PP_ERROR_FAILED; + } // When it is done, we'll get called back on StreamCreated() or // StreamCreationFailed(). @@ -88,6 +95,7 @@ int32_t PepperAudioInputHost::OnOpen(ppapi::host::HostMessageContext* context, open_context_ = context->MakeReplyMessageContext(); return PP_OK_COMPLETIONPENDING; } else { + LOG(ERROR) << "Audio input is NULL"; return PP_ERROR_FAILED; } } @@ -95,8 +103,10 @@ int32_t PepperAudioInputHost::OnOpen(ppapi::host::HostMessageContext* context, int32_t PepperAudioInputHost::OnStartOrStop( ppapi::host::HostMessageContext* /* context */, bool capture) { - if (!audio_input_) + if (!audio_input_) { + LOG(ERROR) << "Audio input is NULL"; return PP_ERROR_FAILED; + } if (capture) audio_input_->StartCapture(); else @@ -157,14 +167,18 @@ int32_t PepperAudioInputHost::GetRemoteHandles( base::ReadOnlySharedMemoryRegion* remote_shared_memory_region) { *remote_socket_handle = renderer_ppapi_host_->ShareHandleWithRemote(socket.handle(), false); - if (*remote_socket_handle == IPC::InvalidPlatformFileForTransit()) + if (*remote_socket_handle == IPC::InvalidPlatformFileForTransit()) { + LOG(ERROR) << "Invalid platform file for transit"; return PP_ERROR_FAILED; + } *remote_shared_memory_region = renderer_ppapi_host_->ShareReadOnlySharedMemoryRegionWithRemote( shared_memory_region); - if (!remote_shared_memory_region->IsValid()) + if (!remote_shared_memory_region->IsValid()) { + LOG(ERROR) << "Invalid region for shared memory"; return PP_ERROR_FAILED; + } return PP_OK; } diff --git a/content/renderer/pepper/pepper_camera_device_host.cc b/content/renderer/pepper/pepper_camera_device_host.cc index a9f59cf..f74b5f0 100644 --- a/content/renderer/pepper/pepper_camera_device_host.cc +++ b/content/renderer/pepper/pepper_camera_device_host.cc @@ -5,7 +5,7 @@ #include "content/renderer/pepper/pepper_camera_device_host.h" #include - +#include "base/logging.h" #include "content/public/renderer/render_frame.h" #include "content/renderer/pepper/pepper_platform_camera_device.h" #include "content/renderer/pepper/renderer_ppapi_host_impl.h" @@ -79,15 +79,21 @@ void PepperCameraDeviceHost::OnVideoCaptureFormatsEnumerated( int32_t PepperCameraDeviceHost::OnOpen(ppapi::host::HostMessageContext* context, const std::string& device_id) { - if (open_reply_context_.is_valid()) + if (open_reply_context_.is_valid()) { + LOG(ERROR) << "Invalid open reply context"; return PP_ERROR_INPROGRESS; + } - if (platform_camera_device_.get()) + if (platform_camera_device_.get()) { + LOG(ERROR) << "Platform camera device is NULL"; return PP_ERROR_FAILED; + } GURL document_url = renderer_ppapi_host_->GetDocumentURL(pp_instance()); - if (!document_url.is_valid()) + if (!document_url.is_valid()) { + LOG(ERROR) << "Invalid document URL"; return PP_ERROR_FAILED; + } platform_camera_device_ = std::make_unique( renderer_ppapi_host_->GetRenderFrameForInstance(pp_instance()) @@ -107,10 +113,14 @@ int32_t PepperCameraDeviceHost::OnClose( int32_t PepperCameraDeviceHost::OnGetSupportedVideoCaptureFormats( ppapi::host::HostMessageContext* context) { - if (video_capture_formats_reply_context_.is_valid()) + if (video_capture_formats_reply_context_.is_valid()) { + LOG(ERROR) << "Invalid video capture formats reply context"; return PP_ERROR_INPROGRESS; - if (!platform_camera_device_) + } + if (!platform_camera_device_) { + LOG(ERROR) << "Platform camera device is NULL"; return PP_ERROR_FAILED; + } video_capture_formats_reply_context_ = context->MakeReplyMessageContext(); platform_camera_device_->GetSupportedVideoCaptureFormats(); diff --git a/content/renderer/pepper/pepper_device_enumeration_host_helper.cc b/content/renderer/pepper/pepper_device_enumeration_host_helper.cc index 76af12f..5b1ded6 100644 --- a/content/renderer/pepper/pepper_device_enumeration_host_helper.cc +++ b/content/renderer/pepper/pepper_device_enumeration_host_helper.cc @@ -163,20 +163,25 @@ int32_t PepperDeviceEnumerationHostHelper::InternalHandleResourceMessage( PPAPI_END_MESSAGE_MAP() *handled = false; + LOG(ERROR) << "Cannot handle internal resource message"; return PP_ERROR_FAILED; } int32_t PepperDeviceEnumerationHostHelper::OnEnumerateDevices( HostMessageContext* context) { - if (enumerate_devices_context_.is_valid()) + if (enumerate_devices_context_.is_valid()) { + LOG(ERROR) << "Invalid enumerate devices context"; return PP_ERROR_INPROGRESS; + } enumerate_ = std::make_unique( this, base::BindOnce( &PepperDeviceEnumerationHostHelper::OnEnumerateDevicesComplete, base::Unretained(this))); - if (!enumerate_->requested()) + if (!enumerate_->requested()) { + LOG(ERROR) << "Cannot request enumerate"; return PP_ERROR_FAILED; + } enumerate_devices_context_ = context->MakeReplyMessageContext(); return PP_OK_COMPLETIONPENDING; diff --git a/content/renderer/pepper/pepper_file_chooser_host.cc b/content/renderer/pepper/pepper_file_chooser_host.cc index 3113805..c892010 100644 --- a/content/renderer/pepper/pepper_file_chooser_host.cc +++ b/content/renderer/pepper/pepper_file_chooser_host.cc @@ -8,6 +8,7 @@ #include "base/bind.h" #include "base/files/file_path.h" +#include "base/logging.h" #include "base/strings/utf_string_conversions.h" #include "content/public/renderer/renderer_ppapi_host.h" #include "content/renderer/pepper/pepper_file_ref_renderer_host.h" @@ -108,6 +109,7 @@ int32_t PepperFileChooserHost::OnResourceMessageReceived( PPAPI_BEGIN_MESSAGE_MAP(PepperFileChooserHost, msg) PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileChooser_Show, OnShow) PPAPI_END_MESSAGE_MAP() + LOG(ERROR) << "Resource message unresolved"; return PP_ERROR_FAILED; } @@ -144,12 +146,15 @@ int32_t PepperFileChooserHost::OnShow( bool open_multiple, const std::string& suggested_file_name, const std::vector& accept_mime_types) { - if (handler_) + if (handler_) { + LOG(ERROR) << "Show already pending"; return PP_ERROR_INPROGRESS; // Already pending. + } if (!host()->permissions().HasPermission( ppapi::PERMISSION_BYPASS_USER_GESTURE) && !renderer_ppapi_host_->HasUserGesture(pp_instance())) { + LOG(ERROR) << "No user gesture"; return PP_ERROR_NO_USER_GESTURE; } @@ -176,6 +181,7 @@ int32_t PepperFileChooserHost::OnShow( if (!handler_->OpenFileChooser(render_frame, std::move(params))) { delete handler_; handler_ = nullptr; + LOG(ERROR); return PP_ERROR_NOACCESS; } diff --git a/content/renderer/pepper/pepper_file_ref_renderer_host.cc b/content/renderer/pepper/pepper_file_ref_renderer_host.cc index f272897..cff07c9 100644 --- a/content/renderer/pepper/pepper_file_ref_renderer_host.cc +++ b/content/renderer/pepper/pepper_file_ref_renderer_host.cc @@ -6,6 +6,7 @@ #include +#include "base/logging.h" #include "base/strings/escape.h" #include "ppapi/c/pp_errors.h" #include "ppapi/host/ppapi_host.h" @@ -71,6 +72,7 @@ int32_t PepperFileRefRendererHost::OnResourceMessageReceived( const IPC::Message& msg, ppapi::host::HostMessageContext* context) { // We don't handle any messages from the plugin in this host. + LOG(ERROR) << "Resource message unresolved"; NOTREACHED(); return PP_ERROR_FAILED; } diff --git a/content/renderer/pepper/pepper_file_system_host.cc b/content/renderer/pepper/pepper_file_system_host.cc index cfd37fb..5fbf54b 100644 --- a/content/renderer/pepper/pepper_file_system_host.cc +++ b/content/renderer/pepper/pepper_file_system_host.cc @@ -78,6 +78,7 @@ int32_t PepperFileSystemHost::OnResourceMessageReceived( PpapiHostMsg_FileSystem_InitIsolatedFileSystem, OnHostMsgInitIsolatedFileSystem) PPAPI_END_MESSAGE_MAP() + LOG(ERROR) << "Resource message unresolved"; return PP_ERROR_FAILED; } @@ -110,18 +111,24 @@ int32_t PepperFileSystemHost::OnHostMsgOpen( ppapi::host::HostMessageContext* context, int64_t expected_size) { // Not allow multiple opens. - if (called_open_) + if (called_open_) { + LOG(ERROR) << "Already an open called - not allow multiple opens"; return PP_ERROR_INPROGRESS; + } called_open_ = true; absl::optional file_system_type = PepperFileSystemTypeToMojoFileSystemType(type_); - if (!file_system_type.has_value()) + if (!file_system_type.has_value()) { + LOG(ERROR) << "Unknown file system type"; return PP_ERROR_FAILED; + } GURL document_url = renderer_ppapi_host_->GetDocumentURL(pp_instance()); - if (!document_url.is_valid()) + if (!document_url.is_valid()) { + LOG(ERROR) << "Invalid document URL"; return PP_ERROR_FAILED; + } reply_context_ = context->MakeReplyMessageContext(); blink::mojom::FileSystemManager* file_system_manager = GetFileSystemManager(); @@ -139,24 +146,32 @@ int32_t PepperFileSystemHost::OnHostMsgInitIsolatedFileSystem( const std::string& fsid, PP_IsolatedFileSystemType_Private type) { // Do not allow multiple opens. - if (called_open_) + if (called_open_) { + LOG(ERROR) << "Already an open called - not allow multiple opens"; return PP_ERROR_INPROGRESS; + } called_open_ = true; // Do a sanity check. - if (!storage::ValidateIsolatedFileSystemId(fsid)) + if (!storage::ValidateIsolatedFileSystemId(fsid)) { + LOG(ERROR) << "Cannot validate isolated file system ID"; return PP_ERROR_BADARGUMENT; + } RenderFrame* frame = renderer_ppapi_host_->GetRenderFrameForInstance(pp_instance()); - if (!frame) + if (!frame) { + LOG(ERROR) << "Cannot get render view"; return PP_ERROR_FAILED; + } url::Origin main_frame_origin( frame->GetWebView()->MainFrame()->GetSecurityOrigin()); const std::string root_name = ppapi::IsolatedFileSystemTypeToRootName(type); - if (root_name.empty()) + if (root_name.empty()) { + LOG(ERROR) << "Cannot get isolated file system root name"; return PP_ERROR_BADARGUMENT; + } root_url_ = GURL(storage::GetIsolatedFileSystemRootURIString( main_frame_origin.GetURL(), fsid, root_name)); opened_ = true; diff --git a/content/renderer/pepper/pepper_graphics_2d_host.cc b/content/renderer/pepper/pepper_graphics_2d_host.cc index eee0b92..d1aa9e4 100644 --- a/content/renderer/pepper/pepper_graphics_2d_host.cc +++ b/content/renderer/pepper/pepper_graphics_2d_host.cc @@ -260,6 +260,7 @@ int32_t PepperGraphics2DHost::OnResourceMessageReceived( PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Graphics2D_ReadImageData, OnHostMsgReadImageData) PPAPI_END_MESSAGE_MAP() + LOG(ERROR) << "Resource message unresolved"; return PP_ERROR_FAILED; } @@ -433,8 +434,10 @@ int32_t PepperGraphics2DHost::OnHostMsgPaintImageData( const PP_Rect& src_rect) { EnterResourceNoLock enter(image_data.host_resource(), true); - if (enter.failed()) + if (enter.failed()) { + LOG(ERROR) << "Enter ImageData failed"; return PP_ERROR_BADRESOURCE; + } PPB_ImageData_Impl* image_resource = static_cast(enter.object()); @@ -442,8 +445,10 @@ int32_t PepperGraphics2DHost::OnHostMsgPaintImageData( operation.paint_image = image_resource; if (!ValidateAndConvertRect(src_rect_specified ? &src_rect : nullptr, image_resource->width(), image_resource->height(), - &operation.paint_src_rect)) + &operation.paint_src_rect)) { + LOG(ERROR) << "ValidateAndConvertRect failed"; return PP_ERROR_BADARGUMENT; + } // Validate the bitmap position using the previously-validated rect, there // should be no painted area outside of the image. @@ -451,12 +456,24 @@ int32_t PepperGraphics2DHost::OnHostMsgPaintImageData( int64_t y64 = static_cast(top_left.y); if (x64 + static_cast(operation.paint_src_rect.x()) < 0 || x64 + static_cast(operation.paint_src_rect.right()) > - image_data_->width()) + image_data_->width()) { + LOG(ERROR) << "Wrong horizontal position to be painted, position value: " + << x64 + static_cast(operation.paint_src_rect.x()) + << " should be greater or equal to 0 and size value: " + << x64 + static_cast(operation.paint_src_rect.right()) + << " should be less or equal to " << image_data_->width(); return PP_ERROR_BADARGUMENT; + } if (y64 + static_cast(operation.paint_src_rect.y()) < 0 || y64 + static_cast(operation.paint_src_rect.bottom()) > - image_data_->height()) + image_data_->height()) { + LOG(ERROR) << "Wrong vertical position to be painted:, position value " + << y64 + static_cast(operation.paint_src_rect.y()) + << " should be greater or equal to 0 and size value: " + << y64 + static_cast(operation.paint_src_rect.bottom()) + << " should be less or equal to " << image_data_->height(); return PP_ERROR_BADARGUMENT; + } operation.paint_x = top_left.x; operation.paint_y = top_left.y; @@ -472,16 +489,23 @@ int32_t PepperGraphics2DHost::OnHostMsgScroll( QueuedOperation operation(QueuedOperation::SCROLL); if (!ValidateAndConvertRect(clip_specified ? &clip : nullptr, image_data_->width(), image_data_->height(), - &operation.scroll_clip_rect)) + &operation.scroll_clip_rect)) { + LOG(ERROR) << "ValidateAndConvertRect failed"; return PP_ERROR_BADARGUMENT; + } // If we're being asked to scroll by more than the clip rect size, just // ignore this scroll command and say it worked. int32_t dx = amount.x; int32_t dy = amount.y; if (dx <= -image_data_->width() || dx >= image_data_->width() || - dy <= -image_data_->height() || dy >= image_data_->height()) + dy <= -image_data_->height() || dy >= image_data_->height()) { + LOG(ERROR) << "Scrolling amount greater than clip rect size: Absolute value" + << " of x= " << dx << " should be less than " + << image_data_->width() << "and absolute value of y= " << dy + << " should be less than " << image_data_->height(); return PP_ERROR_BADARGUMENT; + } operation.scroll_dx = dx; operation.scroll_dy = dy; @@ -495,17 +519,29 @@ int32_t PepperGraphics2DHost::OnHostMsgReplaceContents( const ppapi::HostResource& image_data) { EnterResourceNoLock enter(image_data.host_resource(), true); - if (enter.failed()) + if (enter.failed()) { + LOG(ERROR) << "Enter ImageData failed"; return PP_ERROR_BADRESOURCE; + } PPB_ImageData_Impl* image_resource = static_cast(enter.object()); - if (!PPB_ImageData_Impl::IsImageDataFormatSupported(image_resource->format())) + if (!PPB_ImageData_Impl::IsImageDataFormatSupported( + image_resource->format())) { + LOG(ERROR) << "Unsupported image data format: " + << static_cast(image_resource->format()); return PP_ERROR_BADARGUMENT; + } if (image_resource->width() != image_data_->width() || - image_resource->height() != image_data_->height()) + image_resource->height() != image_data_->height()) { + LOG(ERROR) << "Different widths or heights between image resource and" + << " image data, image resource (width, height) = (" + << image_resource->width() << ", " << image_resource->height() + << "), image data (width, height) = (" << image_data_->width() + << ", " << image_data_->height() << ")"; return PP_ERROR_BADARGUMENT; + } QueuedOperation operation(QueuedOperation::REPLACE); operation.replace_image = image_resource; @@ -516,8 +552,10 @@ int32_t PepperGraphics2DHost::OnHostMsgReplaceContents( int32_t PepperGraphics2DHost::OnHostMsgFlush( ppapi::host::HostMessageContext* context) { // Don't allow more than one pending flush at a time. - if (HasPendingFlush()) + if (HasPendingFlush()) { + LOG(ERROR) << "Flush is pending"; return PP_ERROR_INPROGRESS; + } PP_Resource old_image_data = 0; flush_reply_context_ = context->MakeReplyMessageContext(); @@ -547,6 +585,7 @@ int32_t PepperGraphics2DHost::OnHostMsgSetScale( scale_ = scale; return PP_OK; } + LOG(ERROR) << "Scale cannot be negative or zero: " << scale; return PP_ERROR_BADARGUMENT; } diff --git a/content/renderer/pepper/pepper_media_stream_audio_track_host.cc b/content/renderer/pepper/pepper_media_stream_audio_track_host.cc index 0dec03c..d33d4fd 100644 --- a/content/renderer/pepper/pepper_media_stream_audio_track_host.cc +++ b/content/renderer/pepper/pepper_media_stream_audio_track_host.cc @@ -73,6 +73,7 @@ PepperMediaStreamAudioTrackHost::AudioSink::AudioSink( active_buffers_generation_(0), active_buffer_frame_offset_(0), buffers_generation_(0), + output_buffer_size_(0), main_task_runner_(base::ThreadTaskRunnerHandle::Get()), number_of_buffers_(kDefaultNumberOfAudioBuffers), bytes_per_second_(0), @@ -97,6 +98,7 @@ int32_t PepperMediaStreamAudioTrackHost::AudioSink::Configure( DCHECK_EQ(main_task_runner_, base::ThreadTaskRunnerHandle::Get()); if (pending_configure_reply_.is_valid()) { + LOG(ERROR) << "Invalid ending reply context"; return PP_ERROR_INPROGRESS; } pending_configure_reply_ = context; @@ -335,8 +337,10 @@ int32_t PepperMediaStreamAudioTrackHost::OnResourceMessageReceived( int32_t PepperMediaStreamAudioTrackHost::OnHostMsgConfigure( HostMessageContext* context, const MediaStreamAudioTrackShared::Attributes& attributes) { - if (!MediaStreamAudioTrackShared::VerifyAttributes(attributes)) + if (!MediaStreamAudioTrackShared::VerifyAttributes(attributes)) { + LOG(ERROR) << "Invalid attributes"; return PP_ERROR_BADARGUMENT; + } int32_t buffers = attributes.buffers ? std::min(kMaxNumberOfAudioBuffers, attributes.buffers) diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc index 6dd7fb4..eefd3b2 100644 --- a/content/renderer/pepper/pepper_plugin_instance_impl.cc +++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc @@ -1279,6 +1279,7 @@ int32_t PepperPluginInstanceImpl::RegisterMessageHandler( const PPP_MessageHandler_0_2* handler, PP_Resource message_loop) { // Not supported in-process. + LOG(ERROR) << "Not supported in-process"; NOTIMPLEMENTED(); return PP_ERROR_FAILED; } @@ -2188,20 +2189,28 @@ PP_Bool PepperPluginInstanceImpl::SetCursor(PP_Instance instance, int32_t PepperPluginInstanceImpl::LockMouse( PP_Instance instance, scoped_refptr callback) { - if (TrackedCallback::IsPending(lock_mouse_callback_)) + if (TrackedCallback::IsPending(lock_mouse_callback_)) { + LOG(ERROR) << "Lock mouse callback is pending"; return PP_ERROR_INPROGRESS; + } if (IsMouseLocked()) return PP_OK; - if (!CanAccessMainFrame()) + if (!CanAccessMainFrame()) { + LOG(ERROR) << "Cannot access main frame"; return PP_ERROR_NOACCESS; + } - if (!HasTransientUserActivation()) + if (!HasTransientUserActivation()) { + LOG(ERROR) << "Not have TransientUserActivation"; return PP_ERROR_NO_USER_GESTURE; + } - if (!LockMouse(false)) + if (!LockMouse(false)) { + LOG(ERROR) << "Locking mouse failed"; return PP_ERROR_FAILED; + } lock_mouse_callback_ = callback; return PP_OK_COMPLETIONPENDING; diff --git a/content/renderer/pepper/pepper_url_loader_host.cc b/content/renderer/pepper/pepper_url_loader_host.cc index f561822..f876fb1 100644 --- a/content/renderer/pepper/pepper_url_loader_host.cc +++ b/content/renderer/pepper/pepper_url_loader_host.cc @@ -7,6 +7,7 @@ #include #include "base/feature_list.h" +#include "base/logging.h" #include "base/numerics/safe_conversions.h" #include "base/strings/string_util.h" #include "content/public/common/content_features.h" @@ -122,6 +123,7 @@ int32_t PepperURLLoaderHost::OnResourceMessageReceived( PpapiHostMsg_URLLoader_GrantUniversalAccess, OnHostMsgGrantUniversalAccess) PPAPI_END_MESSAGE_MAP() + LOG(ERROR) << "Resource message unresolved"; return PP_ERROR_FAILED; } @@ -241,8 +243,10 @@ int32_t PepperURLLoaderHost::InternalOnHostMsgOpen( const ppapi::URLRequestInfoData& request_data) { // Main document loads are already open, so don't allow people to open them // again. - if (main_document_loader_) + if (main_document_loader_) { + LOG(ERROR) << "Main document already opened - not allow to multiple opens"; return PP_ERROR_INPROGRESS; + } // Create a copy of the request data since CreateWebURLRequest will populate // the file refs. @@ -258,19 +262,26 @@ int32_t PepperURLLoaderHost::InternalOnHostMsgOpen( " on a different security origin than your plugin. To request " " cross-origin resources, see " " PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS."); + LOG(ERROR) << "The URL you're requesting is on a different security" + << " origin than your plugin"; return PP_ERROR_NOACCESS; } - if (loader_.get()) + if (loader_.get()) { + LOG(ERROR) << "Open already in progress"; return PP_ERROR_INPROGRESS; + } WebLocalFrame* frame = GetFrame(); - if (!frame) + if (!frame) { + LOG(ERROR) << "Frame is NULL"; return PP_ERROR_FAILED; + } WebURLRequest web_request; if (!CreateWebURLRequest( pp_instance(), &filled_in_request_data, frame, &web_request)) { + LOG(ERROR) << "Cannot create WebURLRequest"; return PP_ERROR_FAILED; } @@ -302,8 +313,10 @@ int32_t PepperURLLoaderHost::InternalOnHostMsgOpen( } loader_ = frame->CreateAssociatedURLLoader(options); - if (!loader_.get()) + if (!loader_.get()) { + LOG(ERROR) << "Unsuccessful creation of AssociatedURLLoader"; return PP_ERROR_FAILED; + } // Don't actually save the request until we know we're going to load. request_data_ = filled_in_request_data; @@ -334,6 +347,7 @@ int32_t PepperURLLoaderHost::OnHostMsgGrantUniversalAccess( has_universal_access_ = true; return PP_OK; } + LOG(ERROR) << "Only plugins with permission can bypass same origin"; return PP_ERROR_FAILED; } diff --git a/content/renderer/pepper/pepper_video_capture_host.cc b/content/renderer/pepper/pepper_video_capture_host.cc index b4c8c60..6243f0e 100644 --- a/content/renderer/pepper/pepper_video_capture_host.cc +++ b/content/renderer/pepper/pepper_video_capture_host.cc @@ -80,6 +80,7 @@ int32_t PepperVideoCaptureHost::OnResourceMessageReceived( PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoCapture_Close, OnClose) PPAPI_END_MESSAGE_MAP() + LOG(ERROR) << "Resource message unresolved"; return PP_ERROR_FAILED; } @@ -270,14 +271,18 @@ int32_t PepperVideoCaptureHost::OnOpen( const std::string& device_id, const PP_VideoCaptureDeviceInfo_Dev& requested_info, uint32_t buffer_count) { - if (platform_video_capture_.get()) + if (platform_video_capture_.get()) { + LOG(ERROR) << "Platform video capture is not NULL"; return PP_ERROR_FAILED; + } SetRequestedInfo(requested_info, buffer_count); GURL document_url = renderer_ppapi_host_->GetDocumentURL(pp_instance()); - if (!document_url.is_valid()) + if (!document_url.is_valid()) { + LOG(ERROR) << "Invalid document URL"; return PP_ERROR_FAILED; + } platform_video_capture_ = std::make_unique( renderer_ppapi_host_->GetRenderFrameForInstance(pp_instance()) @@ -292,8 +297,11 @@ int32_t PepperVideoCaptureHost::OnOpen( int32_t PepperVideoCaptureHost::OnStartCapture( ppapi::host::HostMessageContext* context) { if (!SetStatus(PP_VIDEO_CAPTURE_STATUS_STARTING, false) || - !platform_video_capture_.get()) + !platform_video_capture_.get()) { + LOG(ERROR) << "Cannot set PP_VIDEO_CAPTURE_STATUS_STARTING status or " + << "platform video capture is NULL"; return PP_ERROR_FAILED; + } DCHECK(buffers_.empty()); @@ -306,8 +314,12 @@ int32_t PepperVideoCaptureHost::OnStartCapture( int32_t PepperVideoCaptureHost::OnReuseBuffer( ppapi::host::HostMessageContext* context, uint32_t buffer) { - if (buffer >= buffers_.size() || !buffers_[buffer].in_use) + if (buffer >= buffers_.size() || !buffers_[buffer].in_use) { + LOG(ERROR) << "Wrong buffer ID: " << buffer << "Should be less than " + << buffers_.size() << " and should be in use, buffer.in_use =" + << buffers_[buffer].in_use; return PP_ERROR_BADARGUMENT; + } buffers_[buffer].in_use = false; return PP_OK; } @@ -323,8 +335,10 @@ int32_t PepperVideoCaptureHost::OnClose( } int32_t PepperVideoCaptureHost::StopCapture() { - if (!SetStatus(PP_VIDEO_CAPTURE_STATUS_STOPPING, false)) + if (!SetStatus(PP_VIDEO_CAPTURE_STATUS_STOPPING, false)) { + LOG(ERROR) << "Cannot set PP_VIDEO_CAPTURE_STATUS_STOPPING status"; return PP_ERROR_FAILED; + } DCHECK(platform_video_capture_.get()); diff --git a/content/renderer/pepper/pepper_video_decoder_host.cc b/content/renderer/pepper/pepper_video_decoder_host.cc index 7dd8526..66ca49d 100644 --- a/content/renderer/pepper/pepper_video_decoder_host.cc +++ b/content/renderer/pepper/pepper_video_decoder_host.cc @@ -273,8 +273,10 @@ int32_t PepperVideoDecoderHost::OnHostMsgAssignTextures( const std::vector& mailboxes) { if (!initialized_) return PP_ERROR_FAILED; - if (texture_ids.size() != mailboxes.size()) + if (texture_ids.size() != mailboxes.size()) { + LOG(ERROR) << "Texture_ids size was invalid"; return PP_ERROR_FAILED; + } DCHECK(decoder_); pending_texture_requests_--; diff --git a/content/renderer/pepper/pepper_video_decoder_host.h b/content/renderer/pepper/pepper_video_decoder_host.h index 8614cde..a873000 100644 --- a/content/renderer/pepper/pepper_video_decoder_host.h +++ b/content/renderer/pepper/pepper_video_decoder_host.h @@ -127,7 +127,7 @@ class PepperVideoDecoderHost : public ppapi::host::ResourceHost, // Non-owning pointer. RendererPpapiHost* renderer_ppapi_host_; - media::VideoCodecProfile profile_; + media::VideoCodecProfile profile_ = media::VIDEO_CODEC_PROFILE_UNKNOWN; std::unique_ptr decoder_; @@ -155,7 +155,7 @@ class PepperVideoDecoderHost : public ppapi::host::ResourceHost, // writable before sending a read-only region back to the host. std::vector shm_buffers_; - uint32_t min_picture_count_; + uint32_t min_picture_count_ = 0; typedef std::map PictureBufferMap; PictureBufferMap picture_buffer_map_; diff --git a/content/renderer/pepper/pepper_video_encoder_host.cc b/content/renderer/pepper/pepper_video_encoder_host.cc index dd77a33..61cc3d3 100644 --- a/content/renderer/pepper/pepper_video_encoder_host.cc +++ b/content/renderer/pepper/pepper_video_encoder_host.cc @@ -7,6 +7,7 @@ #include #include "base/bind.h" +#include "base/logging.h" #include "base/memory/unsafe_shared_memory_region.h" #include "base/numerics/safe_math.h" #include "base/threading/thread_task_runner_handle.h" @@ -45,12 +46,17 @@ int32_t PP_FromMediaEncodeAcceleratorError( media::VideoEncodeAccelerator::Error error) { switch (error) { case media::VideoEncodeAccelerator::kInvalidArgumentError: + LOG(ERROR) << "Invalid Argument in VideoEncodeAccelerator"; return PP_ERROR_MALFORMED_INPUT; case media::VideoEncodeAccelerator::kIllegalStateError: + LOG(ERROR) << "VideoEncodeAccelerator in illegal state"; + return PP_ERROR_RESOURCE_FAILED; case media::VideoEncodeAccelerator::kPlatformFailureError: + LOG(ERROR) << "Platform Failure in VideoEncodeAccelerator"; return PP_ERROR_RESOURCE_FAILED; // No default case, to catch unhandled enum values. } + LOG(ERROR); return PP_ERROR_FAILED; } @@ -221,6 +227,7 @@ int32_t PepperVideoEncoderHost::OnResourceMessageReceived( PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoEncoder_Close, OnHostMsgClose) PPAPI_END_MESSAGE_MAP() + LOG(ERROR) << "Resource message unresolved"; return PP_ERROR_FAILED; } @@ -261,21 +268,29 @@ int32_t PepperVideoEncoderHost::OnHostMsgInitialize( PP_VideoProfile output_profile, uint32_t initial_bitrate, PP_HardwareAcceleration acceleration) { - if (initialized_) + if (initialized_) { + LOG(ERROR) << "Encoder already initialized"; return PP_ERROR_FAILED; + } media_input_format_ = PP_ToMediaVideoFormat(input_format); - if (media_input_format_ == media::PIXEL_FORMAT_UNKNOWN) + if (media_input_format_ == media::PIXEL_FORMAT_UNKNOWN) { + LOG(ERROR) << "Unknown pixel format"; return PP_ERROR_BADARGUMENT; + } media::VideoCodecProfile media_profile = PP_ToMediaVideoProfile(output_profile); - if (media_profile == media::VIDEO_CODEC_PROFILE_UNKNOWN) + if (media_profile == media::VIDEO_CODEC_PROFILE_UNKNOWN) { + LOG(ERROR) << "Unknown codec profile"; return PP_ERROR_BADARGUMENT; + } gfx::Size input_size(input_visible_size.width, input_visible_size.height); - if (input_size.IsEmpty()) + if (input_size.IsEmpty()) { + LOG(ERROR) << "Input size is empty"; return PP_ERROR_BADARGUMENT; + } if (acceleration == PP_HARDWAREACCELERATION_ONLY) return PP_ERROR_NOTSUPPORTED; @@ -310,8 +325,11 @@ int32_t PepperVideoEncoderHost::OnHostMsgEncode( if (encoder_last_error_) return encoder_last_error_; - if (frame_id >= frame_count_) + if (frame_id >= frame_count_) { + LOG(ERROR) << "The frame ID = " << frame_id << " cannot be larger or " + << "equal to " << frame_count_; return PP_ERROR_FAILED; + } encoder_->Encode( CreateVideoFrame(frame_id, context->MakeReplyMessageContext()), @@ -326,8 +344,12 @@ int32_t PepperVideoEncoderHost::OnHostMsgRecycleBitstreamBuffer( if (encoder_last_error_) return encoder_last_error_; - if (buffer_id >= shm_buffers_.size() || shm_buffers_[buffer_id]->in_use) + if (buffer_id >= shm_buffers_.size() || shm_buffers_[buffer_id]->in_use) { + LOG(ERROR) << "Wrong buffer ID = " << buffer_id << ", should be less than" + << shm_buffers_.size() << " and not in use, buffer.in_use = " + << shm_buffers_[buffer_id]->in_use; return PP_ERROR_FAILED; + } shm_buffers_[buffer_id]->in_use = true; encoder_->UseOutputBitstreamBuffer( diff --git a/content/renderer/pepper/pepper_websocket_host.cc b/content/renderer/pepper/pepper_websocket_host.cc index 535bdf7..0e5c1bd 100644 --- a/content/renderer/pepper/pepper_websocket_host.cc +++ b/content/renderer/pepper/pepper_websocket_host.cc @@ -6,6 +6,7 @@ #include +#include "base/logging.h" #include "content/public/renderer/renderer_ppapi_host.h" #include "net/base/port_util.h" #include "ppapi/c/pp_errors.h" @@ -92,6 +93,7 @@ int32_t PepperWebSocketHost::OnResourceMessageReceived( PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_WebSocket_Fail, OnHostMsgFail) PPAPI_END_MESSAGE_MAP() + LOG(ERROR) << "Resource message unresolved"; return PP_ERROR_FAILED; } @@ -203,15 +205,23 @@ int32_t PepperWebSocketHost::OnHostMsgConnect( // Validate url and convert it to WebURL. GURL gurl(url); url_ = gurl.spec(); - if (!gurl.is_valid()) + if (!gurl.is_valid()) { + LOG(ERROR) << "Invalid URL"; return PP_ERROR_BADARGUMENT; - if (!gurl.SchemeIs("ws") && !gurl.SchemeIs("wss")) + } + if (!gurl.SchemeIs("ws") && !gurl.SchemeIs("wss")) { + LOG(ERROR) << "Invalid scheme of the URL"; return PP_ERROR_BADARGUMENT; - if (gurl.has_ref()) + } + if (gurl.has_ref()) { + LOG(ERROR) << "The URL has ref"; return PP_ERROR_BADARGUMENT; + } if (!net::IsPortAllowedForScheme(gurl.EffectiveIntPort(), - gurl.scheme_piece())) + gurl.scheme_piece())) { + LOG(ERROR) << "Chosen port is not allowed for scheme"; return PP_ERROR_BADARGUMENT; + } WebURL web_url(gurl); // Validate protocols. @@ -234,9 +244,10 @@ int32_t PepperWebSocketHost::OnHostMsgConnect( character == '/' || (character >= ':' && character <= '@') || // U+003A - U+0040 (character >= '[' && character <= ']') || // U+005B - u+005D - character == '{' || - character == '}') + character == '{' || character == '}') { + LOG(ERROR) << "Incorrect character"; return PP_ERROR_BADARGUMENT; + } } // Join protocols with the comma separator. if (vector_it != protocols.begin()) @@ -250,12 +261,16 @@ int32_t PepperWebSocketHost::OnHostMsgConnect( // Create blink::WebSocket object and connect. blink::WebPluginContainer* container = renderer_ppapi_host_->GetContainerForInstance(pp_instance()); - if (!container) + if (!container) { + LOG(ERROR) << "Invalid WebPluginContainer"; return PP_ERROR_BADARGUMENT; + } websocket_ = WebPepperSocket::Create(container->GetDocument(), this); DCHECK(websocket_.get()); - if (!websocket_) + if (!websocket_) { + LOG(ERROR) << "Invalid websocket, nullptr"; return PP_ERROR_NOTSUPPORTED; + } websocket_->Connect(web_url, web_protocols); @@ -268,8 +283,10 @@ int32_t PepperWebSocketHost::OnHostMsgClose( ppapi::host::HostMessageContext* context, int32_t code, const std::string& reason) { - if (!websocket_) + if (!websocket_) { + LOG(ERROR) << "Invalid websocket, nullptr"; return PP_ERROR_FAILED; + } close_reply_ = context->MakeReplyMessageContext(); initiating_close_ = true; diff --git a/content/renderer/pepper/ppb_audio_impl.cc b/content/renderer/pepper/ppb_audio_impl.cc index 76cf444..ff41172 100644 --- a/content/renderer/pepper/ppb_audio_impl.cc +++ b/content/renderer/pepper/ppb_audio_impl.cc @@ -96,14 +96,18 @@ int32_t PPB_Audio_Impl::Open(PP_Resource config, scoped_refptr create_callback) { // Validate the config and keep a reference to it. EnterResourceNoLock enter(config, true); - if (enter.failed()) + if (enter.failed()) { + LOG(ERROR) << "Enter AudioConfig failed"; return PP_ERROR_FAILED; + } config_ = config; PepperPluginInstanceImpl* instance = static_cast( PepperPluginInstance::Get(pp_instance())); - if (!instance) + if (!instance) { + LOG(ERROR) << "Instance is NULL"; return PP_ERROR_FAILED; + } // When the stream is created, we'll get called back on StreamCreated(). DCHECK(!audio_); @@ -111,8 +115,10 @@ int32_t PPB_Audio_Impl::Open(PP_Resource config, static_cast(enter.object()->GetSampleRate()), static_cast(enter.object()->GetSampleFrameCount()), instance->render_frame()->GetWebFrame()->GetLocalFrameToken(), this); - if (!audio_) + if (!audio_) { + LOG(ERROR) << "Audio is NULL"; return PP_ERROR_FAILED; + } // At this point, we are guaranteeing ownership of the completion // callback. Audio promises to fire the completion callback diff --git a/content/renderer/pepper/ppb_video_decoder_impl.cc b/content/renderer/pepper/ppb_video_decoder_impl.cc index 3b6b0a5..90e287d 100644 --- a/content/renderer/pepper/ppb_video_decoder_impl.cc +++ b/content/renderer/pepper/ppb_video_decoder_impl.cc @@ -7,6 +7,7 @@ #include #include "base/check_op.h" +#include "base/logging.h" #include "base/memory/ptr_util.h" #include "base/metrics/histogram_macros.h" #include "base/notreached.h" @@ -156,12 +157,16 @@ const PPP_VideoDecoder_Dev* PPB_VideoDecoder_Impl::GetPPP() { int32_t PPB_VideoDecoder_Impl::Decode( const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, scoped_refptr callback) { - if (!decoder_) + if (!decoder_) { + LOG(ERROR) << "Decoder is NULL"; return PP_ERROR_BADRESOURCE; + } EnterResourceNoLock enter(bitstream_buffer->data, true); - if (enter.failed()) + if (enter.failed()) { + LOG(ERROR) << "Enter Buffer failed"; return PP_ERROR_FAILED; + } PPB_Buffer_Impl* buffer = static_cast(enter.object()); DCHECK_GE(bitstream_buffer->id, 0); @@ -170,8 +175,10 @@ int32_t PPB_VideoDecoder_Impl::Decode( media::BitstreamBuffer decode_buffer(bitstream_buffer->id, buffer->shared_memory().Duplicate(), bitstream_buffer->size); - if (!SetBitstreamBufferCallback(bitstream_buffer->id, callback)) + if (!SetBitstreamBufferCallback(bitstream_buffer->id, callback)) { + LOG(ERROR) << "SetBitstreamBufferCallback failed"; return PP_ERROR_BADARGUMENT; + } FlushCommandBuffer(); decoder_->Decode(std::move(decode_buffer)); @@ -212,11 +219,15 @@ void PPB_VideoDecoder_Impl::ReusePictureBuffer(int32_t picture_buffer_id) { } int32_t PPB_VideoDecoder_Impl::Flush(scoped_refptr callback) { - if (!decoder_) + if (!decoder_) { + LOG(ERROR) << "Decoder is NULL"; return PP_ERROR_BADRESOURCE; + } - if (!SetFlushCallback(callback)) + if (!SetFlushCallback(callback)) { + LOG(ERROR) << "SetFlushCallback failed"; return PP_ERROR_INPROGRESS; + } FlushCommandBuffer(); decoder_->Flush(); @@ -224,11 +235,15 @@ int32_t PPB_VideoDecoder_Impl::Flush(scoped_refptr callback) { } int32_t PPB_VideoDecoder_Impl::Reset(scoped_refptr callback) { - if (!decoder_) + if (!decoder_) { + LOG(ERROR) << "Decoder is NULL"; return PP_ERROR_BADRESOURCE; + } - if (!SetResetCallback(callback)) + if (!SetResetCallback(callback)) { + LOG(ERROR) << "SetFlushCallback failed"; return PP_ERROR_INPROGRESS; + } FlushCommandBuffer(); decoder_->Reset(); diff --git a/content/renderer/pepper/video_decoder_shim.cc b/content/renderer/pepper/video_decoder_shim.cc index d987fa2..bafc973 100644 --- a/content/renderer/pepper/video_decoder_shim.cc +++ b/content/renderer/pepper/video_decoder_shim.cc @@ -265,6 +265,7 @@ void VideoDecoderShim::DecoderImpl::OnDecodeComplete( result = PP_OK; break; default: + LOG(ERROR) << "Decode Error occurred"; result = PP_ERROR_RESOURCE_FAILED; break; } diff --git a/ppapi/c/ppb_file_io.h b/ppapi/c/ppb_file_io.h index 170cc7c..c5079ff 100644 --- a/ppapi/c/ppb_file_io.h +++ b/ppapi/c/ppb_file_io.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* From ppb_file_io.idl modified Tue Oct 22 15:09:47 2013. */ +/* From ppb_file_io.idl modified Wed Mar 15 15:15:36 2017. */ #ifndef PPAPI_C_PPB_FILE_IO_H_ #define PPAPI_C_PPB_FILE_IO_H_ @@ -179,7 +179,7 @@ struct PPB_FileIO_1_1 { * @param[in] file_io A PP_Resource corresponding to a file * FileIO. * @param[in] offset The offset into the file. - * @param[in] buffer The buffer to hold the specified number of bytes read. + * @param[out] buffer The buffer to hold the specified number of bytes read. * @param[in] bytes_to_read The number of bytes to read from * offset. * @param[in] callback A PP_CompletionCallback to be called upon @@ -205,7 +205,8 @@ struct PPB_FileIO_1_1 { * @param[in] file_io A PP_Resource corresponding to a file * FileIO. * @param[in] offset The offset into the file. - * @param[in] buffer The buffer to hold the specified number of bytes read. + * @param[in] buffer The buffer to hold the specified number of bytes to + * write. * @param[in] bytes_to_write The number of bytes to write to * offset. * @param[in] callback A PP_CompletionCallback to be called upon diff --git a/ppapi/cpp/file_io.h b/ppapi/cpp/file_io.h index 3a2b0d3..23aefdd 100644 --- a/ppapi/cpp/file_io.h +++ b/ppapi/cpp/file_io.h @@ -139,7 +139,7 @@ class FileIO : public Resource { /// managed by the callback. /// /// @param[in] offset The offset into the file. - /// @param[in] buffer The buffer to hold the specified number of bytes read. + /// @param[out] buffer The buffer to hold the specified number of bytes read. /// @param[in] bytes_to_read The number of bytes to read from /// offset. /// @param[in] cc A CompletionCallback to be called upon @@ -182,7 +182,8 @@ class FileIO : public Resource { /// partial write. The FileIO object must have been opened with write access. /// /// @param[in] offset The offset into the file. - /// @param[in] buffer The buffer to hold the specified number of bytes read. + /// @param[in] buffer The buffer to hold the specified number of bytes to + /// write. /// @param[in] bytes_to_write The number of bytes to write to /// offset. /// @param[in] cc A CompletionCallback to be called upon diff --git a/ppapi/cpp/ppp_entrypoints.cc b/ppapi/cpp/ppp_entrypoints.cc index 4e8bbbb7..0b7e119 100644 --- a/ppapi/cpp/ppp_entrypoints.cc +++ b/ppapi/cpp/ppp_entrypoints.cc @@ -9,6 +9,7 @@ #include +#include "base/logging.h" #include "ppapi/c/pp_errors.h" #include "ppapi/c/ppb.h" #include "ppapi/c/ppp.h" @@ -36,11 +37,14 @@ void SetBrokerGetInterfaceFunc(PP_GetInterface_Func broker_get_interface) { PP_EXPORT int32_t PPP_InitializeModule(PP_Module module_id, PPB_GetInterface get_browser_interface) { pp::Module* module = pp::CreateModule(); - if (!module) + if (!module) { + LOG(ERROR) << "Invalid pp::Module"; return PP_ERROR_FAILED; + } if (!module->InternalInit(module_id, get_browser_interface)) { delete module; + LOG(ERROR) << "Module InternalInit failed"; return PP_ERROR_FAILED; } g_module_singleton = module; diff --git a/ppapi/cpp/private/ext_crx_file_system_private.cc b/ppapi/cpp/private/ext_crx_file_system_private.cc index 1621b8a..ea94541 100644 --- a/ppapi/cpp/private/ext_crx_file_system_private.cc +++ b/ppapi/cpp/private/ext_crx_file_system_private.cc @@ -17,8 +17,7 @@ template <> const char* interface_name() { } // namespace -ExtCrxFileSystemPrivate::ExtCrxFileSystemPrivate() { -} +ExtCrxFileSystemPrivate::ExtCrxFileSystemPrivate() : instance_(0) {} ExtCrxFileSystemPrivate::ExtCrxFileSystemPrivate( const InstanceHandle& instance) : instance_(instance.pp_instance()) { diff --git a/ppapi/cpp/private/uma_private.cc b/ppapi/cpp/private/uma_private.cc index 6ee4179..7d623ac 100644 --- a/ppapi/cpp/private/uma_private.cc +++ b/ppapi/cpp/private/uma_private.cc @@ -20,8 +20,7 @@ template <> const char* interface_name() { } // namespace -UMAPrivate::UMAPrivate() { -} +UMAPrivate::UMAPrivate() : instance_(0) {} UMAPrivate::UMAPrivate( const InstanceHandle& instance) : instance_(instance.pp_instance()) { diff --git a/ppapi/cpp/var.cc b/ppapi/cpp/var.cc index 1c46f6a..2b8ffd2 100644 --- a/ppapi/cpp/var.cc +++ b/ppapi/cpp/var.cc @@ -141,16 +141,20 @@ Var::Var(const pp::Resource& resource) { if (has_interface()) { var_ = get_interface()->VarFromResource( resource.pp_resource()); + + // Set |is_managed_| to true, so |var_| will be properly released upon + // destruction. + is_managed_ = true; } else { PP_NOTREACHED(); - return; + + // Initialize to default values (see Var::Var()) + memset(&var_, 0, sizeof(var_)); + var_.type = PP_VARTYPE_UNDEFINED; + is_managed_ = true; } - // Set |is_managed_| to true, so |var_| will be properly released upon - // destruction. - is_managed_ = true; } - Var::Var(const PP_Var& var) { var_ = var; is_managed_ = true; diff --git a/ppapi/host/resource_message_handler.cc b/ppapi/host/resource_message_handler.cc index cfb55a3..a7d5869 100644 --- a/ppapi/host/resource_message_handler.cc +++ b/ppapi/host/resource_message_handler.cc @@ -58,6 +58,7 @@ void ResourceMessageHandler::RunMessageHandlerAndReply( int32_t ResourceMessageHandler::OnResourceMessageReceived( const IPC::Message& msg, HostMessageContext* context) { + LOG(ERROR) << "The requested command is not supported by the browser"; return PP_ERROR_NOTSUPPORTED; } diff --git a/ppapi/proxy/audio_encoder_resource.cc b/ppapi/proxy/audio_encoder_resource.cc index 3c8ba3f..284e87c 100644 --- a/ppapi/proxy/audio_encoder_resource.cc +++ b/ppapi/proxy/audio_encoder_resource.cc @@ -7,6 +7,7 @@ #include #include "base/bind.h" +#include "base/logging.h" #include "base/memory/unsafe_shared_memory_region.h" #include "ppapi/c/pp_array_output.h" #include "ppapi/c/pp_codecs.h" @@ -39,8 +40,10 @@ thunk::PPB_AudioEncoder_API* AudioEncoderResource::AsPPB_AudioEncoder_API() { int32_t AudioEncoderResource::GetSupportedProfiles( const PP_ArrayOutput& output, const scoped_refptr& callback) { - if (TrackedCallback::IsPending(get_supported_profiles_callback_)) + if (TrackedCallback::IsPending(get_supported_profiles_callback_)) { + LOG(ERROR) << "Profile not supported"; return PP_ERROR_INPROGRESS; + } get_supported_profiles_callback_ = callback; Call( diff --git a/ppapi/proxy/audio_input_resource.cc b/ppapi/proxy/audio_input_resource.cc index ef30ba7..2f38d0b 100644 --- a/ppapi/proxy/audio_input_resource.cc +++ b/ppapi/proxy/audio_input_resource.cc @@ -319,22 +319,33 @@ int32_t AudioInputResource::CommonOpen( if (device_ref != 0) { thunk::EnterResourceNoLock enter_device_ref( device_ref, true); - if (enter_device_ref.failed()) + if (enter_device_ref.failed()) { + LOG(ERROR) << "Enter DeviceRef failed"; return PP_ERROR_BADRESOURCE; + } device_id = enter_device_ref.object()->GetDeviceRefData().id; } - if (TrackedCallback::IsPending(open_callback_)) + if (TrackedCallback::IsPending(open_callback_)) { + LOG(ERROR) << "Open is pending"; return PP_ERROR_INPROGRESS; - if (open_state_ != BEFORE_OPEN) + } + if (open_state_ != BEFORE_OPEN) { + LOG(ERROR) << "Audio input already opened"; return PP_ERROR_FAILED; + } - if (!audio_input_callback_0_3 && !audio_input_callback) + if (!audio_input_callback_0_3 && !audio_input_callback) { + LOG(ERROR) << "Cannot resolve audio_input_callback_0_3 or " + "audio_input_callback"; return PP_ERROR_BADARGUMENT; + } thunk::EnterResourceNoLock enter_config(config, true); - if (enter_config.failed()) + if (enter_config.failed()) { + LOG(ERROR) << "Enter AudioConfig failed"; return PP_ERROR_BADARGUMENT; + } config_ = config; audio_input_callback_0_3_ = audio_input_callback_0_3; diff --git a/ppapi/proxy/camera_device_resource.cc b/ppapi/proxy/camera_device_resource.cc index f49f56e..3e61b1c 100644 --- a/ppapi/proxy/camera_device_resource.cc +++ b/ppapi/proxy/camera_device_resource.cc @@ -5,6 +5,7 @@ #include "ppapi/proxy/camera_device_resource.h" #include "base/bind.h" +#include "base/logging.h" #include "ppapi/proxy/camera_capabilities_resource.h" #include "ppapi/proxy/plugin_resource_tracker.h" #include "ppapi/proxy/ppapi_messages.h" @@ -26,15 +27,21 @@ CameraDeviceResource::~CameraDeviceResource() { int32_t CameraDeviceResource::Open( PP_Var device_id, const scoped_refptr& callback) { - if (open_state_ != OpenState::BEFORE_OPEN) + if (open_state_ != OpenState::BEFORE_OPEN) { + LOG(ERROR) << "Camera device already opened"; return PP_ERROR_FAILED; + } - if (TrackedCallback::IsPending(open_callback_)) + if (TrackedCallback::IsPending(open_callback_)) { + LOG(ERROR) << "Open is pending"; return PP_ERROR_INPROGRESS; + } scoped_refptr source_string_var(StringVar::FromPPVar(device_id)); - if (!source_string_var || source_string_var->value().empty()) + if (!source_string_var || source_string_var->value().empty()) { + LOG(ERROR) << "Couldn't resolve device ID"; return PP_ERROR_BADARGUMENT; + } open_callback_ = callback; @@ -67,11 +74,15 @@ void CameraDeviceResource::Close() { int32_t CameraDeviceResource::GetCameraCapabilities( PP_Resource* capabilities, const scoped_refptr& callback) { - if (!is_opened()) + if (!is_opened()) { + LOG(ERROR) << "Camera is not opened"; return PP_ERROR_FAILED; + } - if (TrackedCallback::IsPending(get_capabilities_callback_)) + if (TrackedCallback::IsPending(get_capabilities_callback_)) { + LOG(ERROR) << "GetCameraCapabilities is pending"; return PP_ERROR_INPROGRESS; + } if (camera_capabilities_.get()) { *capabilities = camera_capabilities_->GetReference(); diff --git a/ppapi/proxy/device_enumeration_resource_helper.cc b/ppapi/proxy/device_enumeration_resource_helper.cc index 8ca57ee..f871e70 100644 --- a/ppapi/proxy/device_enumeration_resource_helper.cc +++ b/ppapi/proxy/device_enumeration_resource_helper.cc @@ -42,8 +42,10 @@ DeviceEnumerationResourceHelper::~DeviceEnumerationResourceHelper() { int32_t DeviceEnumerationResourceHelper::EnumerateDevices( const PP_ArrayOutput& output, scoped_refptr callback) { - if (pending_enumerate_devices_) + if (pending_enumerate_devices_) { + LOG(ERROR) << "Enumerate devices pending"; return PP_ERROR_INPROGRESS; + } pending_enumerate_devices_ = true; PpapiHostMsg_DeviceEnumeration_EnumerateDevices msg; @@ -78,8 +80,10 @@ int32_t DeviceEnumerationResourceHelper::MonitorDeviceChange( if (callback) { monitor_callback_.reset( ThreadAwareCallback::Create(callback)); - if (!monitor_callback_.get()) + if (!monitor_callback_.get()) { + LOG(ERROR) << "Cannot get monitor_callback"; return PP_ERROR_NO_MESSAGE_LOOP; + } owner_->Post(PluginResource::RENDERER, PpapiHostMsg_DeviceEnumeration_MonitorDeviceChange( @@ -169,16 +173,20 @@ int32_t DeviceEnumerationResourceHelper::WriteToArrayOutput( const std::vector& devices, const PP_ArrayOutput& output) { ArrayWriter writer(output); - if (!writer.is_valid()) + if (!writer.is_valid()) { + LOG(ERROR) << "Invalid output"; return PP_ERROR_BADARGUMENT; + } std::vector > device_resources; for (size_t i = 0; i < devices.size(); ++i) { device_resources.push_back(new PPB_DeviceRef_Shared( OBJECT_IS_PROXY, owner_->pp_instance(), devices[i])); } - if (!writer.StoreResourceVector(device_resources)) + if (!writer.StoreResourceVector(device_resources)) { + LOG(ERROR) << "Fail in StoreResourceVector"; return PP_ERROR_FAILED; + } return PP_OK; } diff --git a/ppapi/proxy/file_chooser_resource.cc b/ppapi/proxy/file_chooser_resource.cc index f84e851..e35406e 100644 --- a/ppapi/proxy/file_chooser_resource.cc +++ b/ppapi/proxy/file_chooser_resource.cc @@ -7,6 +7,7 @@ #include #include "base/bind.h" +#include "base/logging.h" #include "base/strings/string_split.h" #include "ipc/ipc_message.h" #include "ppapi/c/pp_errors.h" @@ -133,8 +134,10 @@ int32_t FileChooserResource::ShowInternal( PP_Bool save_as, const PP_Var& suggested_file_name, scoped_refptr callback) { - if (TrackedCallback::IsPending(callback_)) + if (TrackedCallback::IsPending(callback_)) { + LOG(ERROR) << "ShowInternal is pending"; return PP_ERROR_INPROGRESS; + } if (!sent_create_to_renderer()) SendCreate(RENDERER, PpapiHostMsg_FileChooser_Create()); diff --git a/ppapi/proxy/file_io_resource.cc b/ppapi/proxy/file_io_resource.cc index 914ab0f..07b452b 100644 --- a/ppapi/proxy/file_io_resource.cc +++ b/ppapi/proxy/file_io_resource.cc @@ -8,6 +8,7 @@ #include #include "base/bind.h" +#include "base/logging.h" #include "base/task/task_runner_util.h" #include "ipc/ipc_message.h" #include "ppapi/c/pp_errors.h" @@ -128,12 +129,15 @@ int32_t FileIOResource::Open(PP_Resource file_ref, int32_t open_flags, scoped_refptr callback) { EnterResourceNoLock enter_file_ref(file_ref, true); - if (enter_file_ref.failed()) + if (enter_file_ref.failed()) { + LOG(ERROR) << "Enter FileRef failed"; return PP_ERROR_BADRESOURCE; + } PPB_FileRef_API* file_ref_api = enter_file_ref.object(); const FileRefCreateInfo& create_info = file_ref_api->GetCreateInfo(); if (!FileSystemTypeIsValid(create_info.file_system_type)) { + LOG(ERROR) << "Invalid file system type"; NOTREACHED(); return PP_ERROR_FAILED; } @@ -148,8 +152,10 @@ int32_t FileIOResource::Open(PP_Resource file_ref, if (create_info.file_system_plugin_resource) { EnterResourceNoLock enter_file_system( create_info.file_system_plugin_resource, true); - if (enter_file_system.failed()) + if (enter_file_system.failed()) { + LOG(ERROR) << "Enter FileSystem failed"; return PP_ERROR_FAILED; + } // Take a reference on the FileSystem resource. The FileIO host uses the // FileSystem host for running tasks and checking quota. file_system_resource_ = enter_file_system.resource(); @@ -174,10 +180,14 @@ int32_t FileIOResource::Query(PP_FileInfo* info, FileIOStateManager::OPERATION_EXCLUSIVE, true); if (rv != PP_OK) return rv; - if (!info) + if (!info) { + LOG(ERROR) << "PP_FileInfo output memory block not available"; return PP_ERROR_BADARGUMENT; - if (!FileHolder::IsValid(file_holder_)) + } + if (!FileHolder::IsValid(file_holder_)) { + LOG(ERROR) << "Invalid file holder"; return PP_ERROR_FAILED; + } state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE); @@ -266,12 +276,20 @@ int32_t FileIOResource::Write(int64_t offset, const char* buffer, int32_t bytes_to_write, scoped_refptr callback) { - if (!buffer) + if (!buffer) { + LOG(ERROR) << "Buffer with input data empty"; return PP_ERROR_FAILED; - if (offset < 0 || bytes_to_write < 0) + } + if (offset < 0 || bytes_to_write < 0) { + LOG(ERROR) << "Offset and bytes to writes must be non-negative, " + << "offset = " << offset + << ", bytes to write = " << bytes_to_write; return PP_ERROR_FAILED; - if (!FileHolder::IsValid(file_holder_)) + } + if (!FileHolder::IsValid(file_holder_)) { + LOG(ERROR) << "Invalid file holder"; return PP_ERROR_FAILED; + } int32_t rv = state_manager_.CheckOperationState( FileIOStateManager::OPERATION_WRITE, true); @@ -290,6 +308,7 @@ int32_t FileIOResource::Write(int64_t offset, max_offset = offset + bytes_to_write; if (max_offset > static_cast(std::numeric_limits::max())) { + LOG(ERROR) << "Too big predicted offset = " << max_offset; return PP_ERROR_FAILED; // amount calculation would overflow. } increase = static_cast(max_offset) - max_written_offset_; @@ -324,8 +343,10 @@ int32_t FileIOResource::SetLength(int64_t length, FileIOStateManager::OPERATION_EXCLUSIVE, true); if (rv != PP_OK) return rv; - if (length < 0) + if (length < 0) { + LOG(ERROR) << "Length must be non-negative: length=" << length; return PP_ERROR_FAILED; + } if (check_quota_) { int64_t increase = length - max_written_offset_; @@ -440,10 +461,15 @@ int32_t FileIOResource::ReadValidated(int64_t offset, int32_t bytes_to_read, const PP_ArrayOutput& array_output, scoped_refptr callback) { - if (bytes_to_read < 0) + if (bytes_to_read < 0) { + LOG(ERROR) << "Bytes to read must be non-negative: bytes to read=" + << bytes_to_read; return PP_ERROR_FAILED; - if (!FileHolder::IsValid(file_holder_)) + } + if (!FileHolder::IsValid(file_holder_)) { + LOG(ERROR) << "Invalid file holder"; return PP_ERROR_FAILED; + } state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_READ); diff --git a/ppapi/proxy/file_ref_resource.cc b/ppapi/proxy/file_ref_resource.cc index 087866b..1baf69c 100644 --- a/ppapi/proxy/file_ref_resource.cc +++ b/ppapi/proxy/file_ref_resource.cc @@ -7,6 +7,7 @@ #include #include "base/bind.h" +#include "base/logging.h" #include "base/numerics/safe_conversions.h" #include "ppapi/c/pp_directory_entry.h" #include "ppapi/c/pp_instance.h" @@ -169,8 +170,10 @@ int32_t FileRefResource::Rename(PP_Resource new_file_ref, int32_t FileRefResource::Query(PP_FileInfo* info, scoped_refptr callback) { - if (info == NULL) + if (info == NULL) { + LOG(ERROR) << "PP_FileInfo output memory block not available"; return PP_ERROR_BADARGUMENT; + } Call( BROWSER, PpapiHostMsg_FileRef_Query(), diff --git a/ppapi/proxy/file_system_resource.cc b/ppapi/proxy/file_system_resource.cc index 8b8c64c..909c310 100644 --- a/ppapi/proxy/file_system_resource.cc +++ b/ppapi/proxy/file_system_resource.cc @@ -7,6 +7,7 @@ #include "base/barrier_closure.h" #include "base/bind.h" #include "base/containers/contains.h" +#include "base/logging.h" #include "ipc/ipc_message.h" #include "ppapi/c/pp_errors.h" #include "ppapi/proxy/ppapi_messages.h" @@ -76,8 +77,10 @@ PPB_FileSystem_API* FileSystemResource::AsPPB_FileSystem_API() { int32_t FileSystemResource::Open(int64_t expected_size, scoped_refptr callback) { DCHECK(type_ != PP_FILESYSTEMTYPE_ISOLATED); - if (called_open_) + if (called_open_) { + LOG(ERROR) << "Open already called"; return PP_ERROR_FAILED; + } called_open_ = true; Call( @@ -128,8 +131,10 @@ int32_t FileSystemResource::InitIsolatedFileSystem( // This call is mutually exclusive with Open() above, so we can reuse the // called_open state. DCHECK(type_ == PP_FILESYSTEMTYPE_ISOLATED); - if (called_open_) + if (called_open_) { + LOG(ERROR) << "Open already called"; return PP_ERROR_FAILED; + } called_open_ = true; base::RepeatingClosure ipc_callback = base::BarrierClosure( diff --git a/ppapi/proxy/graphics_2d_resource.cc b/ppapi/proxy/graphics_2d_resource.cc index 511fbef..66339d5 100644 --- a/ppapi/proxy/graphics_2d_resource.cc +++ b/ppapi/proxy/graphics_2d_resource.cc @@ -5,6 +5,7 @@ #include "ppapi/proxy/graphics_2d_resource.h" #include "base/bind.h" +#include "base/logging.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_rect.h" @@ -131,11 +132,15 @@ PP_Bool Graphics2DResource::SetLayerTransform(float scale, int32_t Graphics2DResource::Flush(scoped_refptr callback) { // If host is not even created, return failure immediately. This can happen // when failed to initialize (in constructor). - if (!sent_create_to_renderer()) + if (!sent_create_to_renderer()) { + LOG(ERROR) << "Failed to initialize - host not created"; return PP_ERROR_FAILED; + } - if (TrackedCallback::IsPending(current_flush_callback_)) + if (TrackedCallback::IsPending(current_flush_callback_)) { + LOG(ERROR) << "Flush is pending"; return PP_ERROR_INPROGRESS; // Can't have >1 flush pending. + } current_flush_callback_ = callback; Call( diff --git a/ppapi/proxy/host_resolver_resource.cc b/ppapi/proxy/host_resolver_resource.cc index 7832b64..7e17e1e 100644 --- a/ppapi/proxy/host_resolver_resource.cc +++ b/ppapi/proxy/host_resolver_resource.cc @@ -57,8 +57,10 @@ int32_t HostResolverResource::Resolve(const char* host, uint16_t port, const PP_HostResolver_Hint* hint, scoped_refptr callback) { - if (!hint) + if (!hint) { + LOG(ERROR) << "Hint is NULL"; return PP_ERROR_BADARGUMENT; + } PP_HostResolver_Private_Hint private_hint = ConvertToHostResolverPrivateHint(*hint); diff --git a/ppapi/proxy/host_resolver_resource_base.cc b/ppapi/proxy/host_resolver_resource_base.cc index 5fab982..17f6547 100644 --- a/ppapi/proxy/host_resolver_resource_base.cc +++ b/ppapi/proxy/host_resolver_resource_base.cc @@ -5,6 +5,7 @@ #include "ppapi/proxy/host_resolver_resource_base.h" #include "base/bind.h" +#include "base/logging.h" #include "ppapi/c/pp_errors.h" #include "ppapi/proxy/error_conversion.h" #include "ppapi/proxy/net_address_resource.h" @@ -36,10 +37,14 @@ int32_t HostResolverResourceBase::ResolveImpl( const PP_HostResolver_Private_Hint* hint, scoped_refptr callback) { allow_get_results_ = false; - if (!host || !hint) + if (!host || !hint) { + LOG(ERROR) << "Host or hint is NULL"; return PP_ERROR_BADARGUMENT; - if (ResolveInProgress()) + } + if (ResolveInProgress()) { + LOG(ERROR) << "Resolve is pending"; return PP_ERROR_INPROGRESS; + } resolve_callback_ = callback; diff --git a/ppapi/proxy/isolated_file_system_private_resource.cc b/ppapi/proxy/isolated_file_system_private_resource.cc index 4003b11..72d2a9e 100644 --- a/ppapi/proxy/isolated_file_system_private_resource.cc +++ b/ppapi/proxy/isolated_file_system_private_resource.cc @@ -43,8 +43,10 @@ int32_t IsolatedFileSystemPrivateResource::Open( PP_IsolatedFileSystemType_Private type, PP_Resource* file_system_resource, scoped_refptr callback) { - if (!file_system_resource) + if (!file_system_resource) { + LOG(ERROR) << "File system resource is NULL"; return PP_ERROR_BADARGUMENT; + } Call( BROWSER, PpapiHostMsg_IsolatedFileSystem_BrowserOpen(type), diff --git a/ppapi/proxy/media_stream_audio_track_resource.cc b/ppapi/proxy/media_stream_audio_track_resource.cc index d56ff47..76098f4 100644 --- a/ppapi/proxy/media_stream_audio_track_resource.cc +++ b/ppapi/proxy/media_stream_audio_track_resource.cc @@ -5,6 +5,7 @@ #include "ppapi/proxy/media_stream_audio_track_resource.h" #include "base/bind.h" +#include "base/logging.h" #include "ppapi/proxy/audio_buffer_resource.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/shared_impl/media_stream_audio_track_shared.h" @@ -44,17 +45,22 @@ PP_Bool MediaStreamAudioTrackResource::HasEnded() { int32_t MediaStreamAudioTrackResource::Configure( const int32_t attrib_list[], scoped_refptr callback) { - if (has_ended()) + if (has_ended()) { + LOG(ERROR) << "Media stream audio track has ended"; return PP_ERROR_FAILED; + } if (TrackedCallback::IsPending(configure_callback_) || TrackedCallback::IsPending(get_buffer_callback_)) { + LOG(ERROR) << "Configure or Get buffer is pending"; return PP_ERROR_INPROGRESS; } // Do not support configure if audio buffers are held by plugin. - if (!buffers_.empty()) + if (!buffers_.empty()) { + LOG(ERROR) << "Audio buffers are already held by plugin"; return PP_ERROR_INPROGRESS; + } MediaStreamAudioTrackShared::Attributes attributes; int i = 0; @@ -69,14 +75,18 @@ int32_t MediaStreamAudioTrackResource::Configure( case PP_MEDIASTREAMAUDIOTRACK_ATTRIB_SAMPLE_RATE: case PP_MEDIASTREAMAUDIOTRACK_ATTRIB_SAMPLE_SIZE: case PP_MEDIASTREAMAUDIOTRACK_ATTRIB_CHANNELS: + LOG(ERROR) << "Attribute not supported"; return PP_ERROR_NOTSUPPORTED; default: + LOG(ERROR); return PP_ERROR_BADARGUMENT; } } - if (!MediaStreamAudioTrackShared::VerifyAttributes(attributes)) + if (!MediaStreamAudioTrackShared::VerifyAttributes(attributes)) { + LOG(ERROR) << "Given attributes are invalid"; return PP_ERROR_BADARGUMENT; + } configure_callback_ = callback; Call( @@ -91,18 +101,23 @@ int32_t MediaStreamAudioTrackResource::GetAttrib( PP_MediaStreamAudioTrack_Attrib attrib, int32_t* value) { // TODO(penghuang): Implement this function. + LOG(ERROR) << "Function not implemented"; return PP_ERROR_NOTSUPPORTED; } int32_t MediaStreamAudioTrackResource::GetBuffer( PP_Resource* buffer, scoped_refptr callback) { - if (has_ended()) + if (has_ended()) { + LOG(ERROR) << "Media stream audio track has ended"; return PP_ERROR_FAILED; + } if (TrackedCallback::IsPending(configure_callback_) || - TrackedCallback::IsPending(get_buffer_callback_)) + TrackedCallback::IsPending(get_buffer_callback_)) { + LOG(ERROR) << "Configure or GetBuffer is pending"; return PP_ERROR_INPROGRESS; + } *buffer = GetAudioBuffer(); if (*buffer) @@ -118,8 +133,10 @@ int32_t MediaStreamAudioTrackResource::GetBuffer( int32_t MediaStreamAudioTrackResource::RecycleBuffer(PP_Resource buffer) { BufferMap::iterator it = buffers_.find(buffer); - if (it == buffers_.end()) + if (it == buffers_.end()) { + LOG(ERROR) << "Media stream audio track has ended"; return PP_ERROR_BADRESOURCE; + } scoped_refptr buffer_resource = it->second; buffers_.erase(it); diff --git a/ppapi/proxy/media_stream_video_track_resource.cc b/ppapi/proxy/media_stream_video_track_resource.cc index b4df216..70600ee 100644 --- a/ppapi/proxy/media_stream_video_track_resource.cc +++ b/ppapi/proxy/media_stream_video_track_resource.cc @@ -53,17 +53,22 @@ PP_Bool MediaStreamVideoTrackResource::HasEnded() { int32_t MediaStreamVideoTrackResource::Configure( const int32_t attrib_list[], scoped_refptr callback) { - if (has_ended()) + if (has_ended()) { + LOG(ERROR) << "Media stream video track has ended"; return PP_ERROR_FAILED; + } if (TrackedCallback::IsPending(configure_callback_) || TrackedCallback::IsPending(get_frame_callback_)) { + LOG(ERROR) << "Configure or Get frame is pending"; return PP_ERROR_INPROGRESS; } // Do not support configure, if frames are hold by plugin. - if (!frames_.empty()) + if (!frames_.empty()) { + LOG(ERROR) << "Frames are already held by plugin"; return PP_ERROR_INPROGRESS; + } MediaStreamVideoTrackShared::Attributes attributes; int i = 0; @@ -82,12 +87,15 @@ int32_t MediaStreamVideoTrackResource::Configure( attributes.format = static_cast(attrib_list[i + 1]); break; default: + LOG(ERROR); return PP_ERROR_BADARGUMENT; } } - if (!MediaStreamVideoTrackShared::VerifyAttributes(attributes)) + if (!MediaStreamVideoTrackShared::VerifyAttributes(attributes)) { + LOG(ERROR) << "Invalid attributes"; return PP_ERROR_BADARGUMENT; + } configure_callback_ = callback; Call( @@ -102,17 +110,21 @@ int32_t MediaStreamVideoTrackResource::GetAttrib( PP_MediaStreamVideoTrack_Attrib attrib, int32_t* value) { // TODO(penghuang): implement this function. + LOG(ERROR) << "Not implemented function"; return PP_ERROR_NOTSUPPORTED; } int32_t MediaStreamVideoTrackResource::GetFrame( PP_Resource* frame, scoped_refptr callback) { - if (has_ended()) + if (has_ended()) { + LOG(ERROR) << "Media stream video track has ended"; return PP_ERROR_FAILED; + } if (TrackedCallback::IsPending(configure_callback_) || TrackedCallback::IsPending(get_frame_callback_)) { + LOG(ERROR) << "Configure or Get frame is pending"; return PP_ERROR_INPROGRESS; } @@ -127,8 +139,10 @@ int32_t MediaStreamVideoTrackResource::GetFrame( int32_t MediaStreamVideoTrackResource::RecycleFrame(PP_Resource frame) { FrameMap::iterator it = frames_.find(frame); - if (it == frames_.end()) + if (it == frames_.end()) { + LOG(ERROR); return PP_ERROR_BADRESOURCE; + } scoped_refptr frame_resource = it->second; frames_.erase(it); diff --git a/ppapi/proxy/network_list_resource.cc b/ppapi/proxy/network_list_resource.cc index 3d288f3..be9e3ed 100644 --- a/ppapi/proxy/network_list_resource.cc +++ b/ppapi/proxy/network_list_resource.cc @@ -8,6 +8,7 @@ #include +#include "base/logging.h" #include "ppapi/c/pp_errors.h" #include "ppapi/shared_impl/array_writer.h" #include "ppapi/shared_impl/var.h" @@ -53,12 +54,17 @@ PP_NetworkList_State NetworkListResource::GetState(uint32_t index) { int32_t NetworkListResource::GetIpAddresses(uint32_t index, const PP_ArrayOutput& output) { ArrayWriter writer(output); - if (index >= list_.size() || !writer.is_valid()) + if (index >= list_.size() || !writer.is_valid()) { + LOG(ERROR) << "Index is larger than list size or output array is invalid, " + << "index = " << index << ", list size = " << list_.size(); return PP_ERROR_BADARGUMENT; + } thunk::EnterResourceCreationNoLock enter(pp_instance()); - if (enter.failed()) + if (enter.failed()) { + LOG(ERROR) << "Enter pp_instance failed"; return PP_ERROR_FAILED; + } const std::vector& addresses = list_.at(index).addresses; @@ -68,8 +74,10 @@ int32_t NetworkListResource::GetIpAddresses(uint32_t index, enter.functions()->CreateNetAddressFromNetAddressPrivate( pp_instance(), addresses[i])); } - if (!writer.StoreResourceVector(addr_resources)) + if (!writer.StoreResourceVector(addr_resources)) { + LOG(ERROR) << "Writer cannot store given resource vector"; return PP_ERROR_FAILED; + } return PP_OK; } diff --git a/ppapi/proxy/network_monitor_resource.cc b/ppapi/proxy/network_monitor_resource.cc index 777652a..51bf4dd 100644 --- a/ppapi/proxy/network_monitor_resource.cc +++ b/ppapi/proxy/network_monitor_resource.cc @@ -4,6 +4,7 @@ #include "ppapi/proxy/network_monitor_resource.h" +#include "base/logging.h" #include "ppapi/proxy/dispatch_reply_message.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/thunk/enter.h" @@ -44,12 +45,18 @@ void NetworkMonitorResource::OnReplyReceived( int32_t NetworkMonitorResource::UpdateNetworkList( PP_Resource* network_list, scoped_refptr callback) { - if (!network_list) + if (!network_list) { + LOG(ERROR) << "Network list is NULL"; return PP_ERROR_BADARGUMENT; - if (TrackedCallback::IsPending(update_callback_)) + } + if (TrackedCallback::IsPending(update_callback_)) { + LOG(ERROR) << "Update Network List is pending"; return PP_ERROR_INPROGRESS; - if (forbidden_) + } + if (forbidden_) { + LOG(ERROR) << "Insufficient permissions"; return PP_ERROR_NOACCESS; + } if (current_list_.get()) { *network_list = current_list_.Release(); diff --git a/ppapi/proxy/network_proxy_resource.cc b/ppapi/proxy/network_proxy_resource.cc index a96840f..366107f 100644 --- a/ppapi/proxy/network_proxy_resource.cc +++ b/ppapi/proxy/network_proxy_resource.cc @@ -5,6 +5,7 @@ #include "ppapi/proxy/network_proxy_resource.h" #include "base/bind.h" +#include "base/logging.h" #include "ppapi/proxy/dispatch_reply_message.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/shared_impl/tracked_callback.h" @@ -32,8 +33,10 @@ int32_t NetworkProxyResource::GetProxyForURL( PP_Var* proxy_string, scoped_refptr callback) { StringVar* string_url = StringVar::FromPPVar(url); - if (!string_url) + if (!string_url) { + LOG(ERROR) << "Invalid URL"; return PP_ERROR_BADARGUMENT; + } Call( BROWSER, PpapiHostMsg_NetworkProxy_GetProxyForURL(string_url->value()), base::BindOnce(&NetworkProxyResource::OnPluginMsgGetProxyForURLReply, diff --git a/ppapi/proxy/plugin_resource.cc b/ppapi/proxy/plugin_resource.cc index 813f15d..2981036 100644 --- a/ppapi/proxy/plugin_resource.cc +++ b/ppapi/proxy/plugin_resource.cc @@ -6,6 +6,7 @@ #include +#include "base/logging.h" #include "ppapi/proxy/plugin_globals.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/shared_impl/ppapi_globals.h" @@ -156,6 +157,7 @@ int32_t PluginResource::GenericSyncCall( params, msg, reply_params, reply)); if (success) return reply_params->result(); + LOG(ERROR); return PP_ERROR_FAILED; } diff --git a/ppapi/proxy/ppb_buffer_proxy.cc b/ppapi/proxy/ppb_buffer_proxy.cc index f708303..d15f551 100644 --- a/ppapi/proxy/ppb_buffer_proxy.cc +++ b/ppapi/proxy/ppb_buffer_proxy.cc @@ -57,6 +57,7 @@ void Buffer::Unmap() { } int32_t Buffer::GetSharedMemory(base::UnsafeSharedMemoryRegion** out_handle) { + LOG(ERROR) << "Cannot get shared memory"; NOTREACHED(); return PP_ERROR_NOTSUPPORTED; } diff --git a/ppapi/proxy/ppb_graphics_3d_proxy.cc b/ppapi/proxy/ppb_graphics_3d_proxy.cc index ed09a70..6d01ede 100644 --- a/ppapi/proxy/ppb_graphics_3d_proxy.cc +++ b/ppapi/proxy/ppb_graphics_3d_proxy.cc @@ -5,7 +5,7 @@ #include "ppapi/proxy/ppb_graphics_3d_proxy.h" #include - +#include "base/logging.h" #include "base/numerics/safe_conversions.h" #include "build/build_config.h" #include "gpu/command_buffer/client/gles2_implementation.h" @@ -159,15 +159,19 @@ PP_Resource PPB_Graphics3D_Proxy::CreateProxyResource( PP_Resource share_context, const int32_t* attrib_list) { PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); - if (!dispatcher) + if (!dispatcher) { + LOG(ERROR) << "Dispatcher is NULL"; return PP_ERROR_BADARGUMENT; + } HostResource share_host; gpu::gles2::GLES2Implementation* share_gles2 = nullptr; if (share_context != 0) { EnterResourceNoLock enter(share_context, true); - if (enter.failed()) + if (enter.failed()) { + LOG(ERROR) << "Enter Graphics3D failed"; return PP_ERROR_BADARGUMENT; + } PPB_Graphics3D_Shared* share_graphics = static_cast(enter.object()); diff --git a/ppapi/proxy/ppb_image_data_proxy.cc b/ppapi/proxy/ppb_image_data_proxy.cc index c915993..d5eaff8 100644 --- a/ppapi/proxy/ppb_image_data_proxy.cc +++ b/ppapi/proxy/ppb_image_data_proxy.cc @@ -354,6 +354,7 @@ int32_t ImageData::GetSharedMemoryRegion( base::UnsafeSharedMemoryRegion** /* region */) { // Not supported in the proxy (this method is for actually implementing the // proxy in the host). + LOG(ERROR) << "Not supported"; return PP_ERROR_NOACCESS; } diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc index 37a791c..7155f3a 100644 --- a/ppapi/proxy/ppb_instance_proxy.cc +++ b/ppapi/proxy/ppb_instance_proxy.cc @@ -7,6 +7,7 @@ #include #include "base/bind.h" +#include "base/logging.h" #include "base/memory/ref_counted.h" #include "base/numerics/safe_conversions.h" #include "build/build_config.h" @@ -475,8 +476,10 @@ int32_t PPB_Instance_Proxy::RegisterMessageHandler( PP_Resource message_loop) { InstanceData* data = static_cast(dispatcher())->GetInstanceData(instance); - if (!data) + if (!data) { + LOG(ERROR) << "Data is NULL"; return PP_ERROR_BADARGUMENT; + } int32_t result = PP_ERROR_FAILED; std::unique_ptr message_handler = MessageHandler::Create( @@ -525,10 +528,14 @@ int32_t PPB_Instance_Proxy::LockMouse(PP_Instance instance, // Save the mouse callback on the instance data. InstanceData* data = static_cast(dispatcher())-> GetInstanceData(instance); - if (!data) + if (!data) { + LOG(ERROR) << "Data is NULL"; return PP_ERROR_BADARGUMENT; - if (TrackedCallback::IsPending(data->mouse_lock_callback)) + } + if (TrackedCallback::IsPending(data->mouse_lock_callback)) { + LOG(ERROR) << "Lock mouse is pending"; return PP_ERROR_INPROGRESS; // Already have a pending callback. + } data->mouse_lock_callback = callback; dispatcher()->Send(new PpapiHostMsg_PPBInstance_LockMouse( diff --git a/ppapi/proxy/ppb_message_loop_proxy.cc b/ppapi/proxy/ppb_message_loop_proxy.cc index e695734..757b331 100644 --- a/ppapi/proxy/ppb_message_loop_proxy.cc +++ b/ppapi/proxy/ppb_message_loop_proxy.cc @@ -71,8 +71,10 @@ PPB_MessageLoop_API* MessageLoopResource::AsPPB_MessageLoop_API() { } int32_t MessageLoopResource::AttachToCurrentThread() { - if (is_main_thread_loop_) + if (is_main_thread_loop_) { + LOG(ERROR) << "Cannot attach to current thread if it is main thread loop"; return PP_ERROR_INPROGRESS; + } PluginGlobals* globals = PluginGlobals::Get(); @@ -81,8 +83,10 @@ int32_t MessageLoopResource::AttachToCurrentThread() { slot = new base::ThreadLocalStorage::Slot(&ReleaseMessageLoop); globals->set_msg_loop_slot(slot); } else { - if (slot->Get()) + if (slot->Get()) { + LOG(ERROR) << "Message loop slot already in use"; return PP_ERROR_INPROGRESS; + } } // TODO(dmichael) check that the current thread can support a task executor. @@ -106,10 +110,14 @@ int32_t MessageLoopResource::AttachToCurrentThread() { } int32_t MessageLoopResource::Run() { - if (!IsCurrent()) + if (!IsCurrent()) { + LOG(ERROR) << "Run called not on current thread"; return PP_ERROR_WRONG_THREAD; - if (is_main_thread_loop_) + } + if (is_main_thread_loop_) { + LOG(ERROR) << "Run called on the main thread"; return PP_ERROR_INPROGRESS; + } base::RunLoop* previous_run_loop = run_loop_; base::RunLoop run_loop; @@ -136,10 +144,14 @@ int32_t MessageLoopResource::Run() { int32_t MessageLoopResource::PostWork(PP_CompletionCallback callback, int64_t delay_ms) { - if (!callback.func) + if (!callback.func) { + LOG(ERROR); return PP_ERROR_BADARGUMENT; - if (destroyed_) + } + if (destroyed_) { + LOG(ERROR) << "Message loop already destroyed"; return PP_ERROR_FAILED; + } PostClosure(FROM_HERE, base::BindOnce(callback.func, callback.user_data, static_cast(PP_OK)), @@ -148,8 +160,10 @@ int32_t MessageLoopResource::PostWork(PP_CompletionCallback callback, } int32_t MessageLoopResource::PostQuit(PP_Bool should_destroy) { - if (is_main_thread_loop_) + if (is_main_thread_loop_) { + LOG(ERROR) << "Post Quit in main thread loop"; return PP_ERROR_WRONG_THREAD; + } if (PP_ToBool(should_destroy)) should_destroy_ = true; @@ -255,6 +269,7 @@ int32_t AttachToCurrentThread(PP_Resource message_loop) { EnterMessageLoop enter(message_loop, true); if (enter.succeeded()) return enter.object()->AttachToCurrentThread(); + LOG(ERROR); return PP_ERROR_BADRESOURCE; } @@ -262,6 +277,7 @@ int32_t Run(PP_Resource message_loop) { EnterMessageLoop enter(message_loop, true); if (enter.succeeded()) return enter.object()->Run(); + LOG(ERROR) << "Cannot enter message loop"; return PP_ERROR_BADRESOURCE; } @@ -271,6 +287,7 @@ int32_t PostWork(PP_Resource message_loop, EnterMessageLoop enter(message_loop, true); if (enter.succeeded()) return enter.object()->PostWork(callback, delay_ms); + LOG(ERROR) << "Cannot enter message loop"; return PP_ERROR_BADRESOURCE; } @@ -278,6 +295,7 @@ int32_t PostQuit(PP_Resource message_loop, PP_Bool should_destroy) { EnterMessageLoop enter(message_loop, true); if (enter.succeeded()) return enter.object()->PostQuit(should_destroy); + LOG(ERROR) << "Cannot enter message loop"; return PP_ERROR_BADRESOURCE; } diff --git a/ppapi/proxy/ppb_video_decoder_proxy.cc b/ppapi/proxy/ppb_video_decoder_proxy.cc index 19c703f..1f23b44 100644 --- a/ppapi/proxy/ppb_video_decoder_proxy.cc +++ b/ppapi/proxy/ppb_video_decoder_proxy.cc @@ -73,11 +73,15 @@ int32_t VideoDecoder::Decode( scoped_refptr callback) { EnterResourceNoLock enter_buffer(bitstream_buffer->data, true); - if (enter_buffer.failed()) + if (enter_buffer.failed()) { + LOG(ERROR) << "Enter buffer failed"; return PP_ERROR_BADRESOURCE; + } - if (!SetBitstreamBufferCallback(bitstream_buffer->id, callback)) + if (!SetBitstreamBufferCallback(bitstream_buffer->id, callback)) { + LOG(ERROR) << "Cannot set bit stream buffer"; return PP_ERROR_BADARGUMENT; + } Buffer* ppb_buffer = static_cast(enter_buffer.object()); @@ -108,8 +112,10 @@ void VideoDecoder::ReusePictureBuffer(int32_t picture_buffer_id) { } int32_t VideoDecoder::Flush(scoped_refptr callback) { - if (!SetFlushCallback(callback)) + if (!SetFlushCallback(callback)) { + LOG(ERROR) << "Cannot set flush callback"; return PP_ERROR_INPROGRESS; + } FlushCommandBuffer(); GetDispatcher()->Send(new PpapiHostMsg_PPBVideoDecoder_Flush( @@ -118,8 +124,10 @@ int32_t VideoDecoder::Flush(scoped_refptr callback) { } int32_t VideoDecoder::Reset(scoped_refptr callback) { - if (!SetResetCallback(callback)) + if (!SetResetCallback(callback)) { + LOG(ERROR) << "Cannot set reset callback"; return PP_ERROR_INPROGRESS; + } FlushCommandBuffer(); GetDispatcher()->Send(new PpapiHostMsg_PPBVideoDecoder_Reset( diff --git a/ppapi/proxy/printing_resource.cc b/ppapi/proxy/printing_resource.cc index 00739dd..5a57b3e 100644 --- a/ppapi/proxy/printing_resource.cc +++ b/ppapi/proxy/printing_resource.cc @@ -5,6 +5,7 @@ #include "ppapi/proxy/printing_resource.h" #include "base/bind.h" +#include "base/logging.h" #include "ipc/ipc_message.h" #include "ppapi/c/pp_errors.h" #include "ppapi/proxy/dispatch_reply_message.h" @@ -27,8 +28,10 @@ thunk::PPB_Printing_API* PrintingResource::AsPPB_Printing_API() { int32_t PrintingResource::GetDefaultPrintSettings( PP_PrintSettings_Dev* print_settings, scoped_refptr callback) { - if (!print_settings) + if (!print_settings) { + LOG(ERROR) << "Memory for print settings not allocated"; return PP_ERROR_BADARGUMENT; + } if (!sent_create_to_browser()) SendCreate(BROWSER, PpapiHostMsg_Printing_Create()); diff --git a/ppapi/proxy/raw_var_data.cc b/ppapi/proxy/raw_var_data.cc index 193c10c..23a44f6 100644 --- a/ppapi/proxy/raw_var_data.cc +++ b/ppapi/proxy/raw_var_data.cc @@ -265,8 +265,7 @@ SerializedHandle* RawVarData::GetHandle() { } // BasicRawVarData ------------------------------------------------------------- -BasicRawVarData::BasicRawVarData() { -} +BasicRawVarData::BasicRawVarData() : var_(PP_MakeUndefined()) {} BasicRawVarData::~BasicRawVarData() { } @@ -631,6 +630,7 @@ void DictionaryRawVarData::PopulatePPVar(const PP_Var& var, return; } DictionaryVar* dictionary_var = DictionaryVar::FromPPVar(var); + DCHECK(dictionary_var); DCHECK(dictionary_var->key_value_map().empty()); for (size_t i = 0; i < children_.size(); ++i) { bool success = dictionary_var->SetWithStringKey(children_[i].first, diff --git a/ppapi/proxy/serialized_handle.h b/ppapi/proxy/serialized_handle.h index 699d0bf..cde894a 100644 --- a/ppapi/proxy/serialized_handle.h +++ b/ppapi/proxy/serialized_handle.h @@ -38,7 +38,7 @@ class PPAPI_PROXY_EXPORT SerializedHandle { // Header contains the fields that we send in IPC messages, apart from the // actual handle. See comments on the SerializedHandle fields below. struct Header { - Header() : type(INVALID), size(0), open_flags(0) {} + Header() : type(INVALID), size(0), open_flags(0), file_io(0) {} Header(Type type_arg, int32_t open_flags_arg, PP_Resource file_io_arg) diff --git a/ppapi/proxy/serialized_var.cc b/ppapi/proxy/serialized_var.cc index 953877e..fd4a9ba 100644 --- a/ppapi/proxy/serialized_var.cc +++ b/ppapi/proxy/serialized_var.cc @@ -44,7 +44,8 @@ SerializedVar::Inner::Inner(VarSerializationRules* serialization_rules) : serialization_rules_(serialization_rules), var_(PP_MakeUndefined()), instance_(0), - cleanup_mode_(CLEANUP_NONE) { + cleanup_mode_(CLEANUP_NONE), + is_valid_var_(true) { #ifndef NDEBUG has_been_serialized_ = false; has_been_deserialized_ = false; diff --git a/ppapi/proxy/tcp_server_socket_private_resource.cc b/ppapi/proxy/tcp_server_socket_private_resource.cc index 0f80783..8d42308 100644 --- a/ppapi/proxy/tcp_server_socket_private_resource.cc +++ b/ppapi/proxy/tcp_server_socket_private_resource.cc @@ -5,6 +5,7 @@ #include "ppapi/proxy/tcp_server_socket_private_resource.h" #include "base/bind.h" +#include "base/logging.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/proxy/tcp_socket_private_resource.h" @@ -32,12 +33,18 @@ int32_t TCPServerSocketPrivateResource::Listen( const PP_NetAddress_Private* addr, int32_t backlog, scoped_refptr callback) { - if (!addr) + if (!addr) { + LOG(ERROR) << "Address is NULL"; return PP_ERROR_BADARGUMENT; - if (state_ != STATE_BEFORE_LISTENING) + } + if (state_ != STATE_BEFORE_LISTENING) { + LOG(ERROR) << "Listening was already started"; return PP_ERROR_FAILED; - if (TrackedCallback::IsPending(listen_callback_)) + } + if (TrackedCallback::IsPending(listen_callback_)) { + LOG(ERROR) << "Listen is pending"; return PP_ERROR_INPROGRESS; + } listen_callback_ = callback; @@ -52,12 +59,18 @@ int32_t TCPServerSocketPrivateResource::Listen( int32_t TCPServerSocketPrivateResource::Accept( PP_Resource* tcp_socket, scoped_refptr callback) { - if (!tcp_socket) + if (!tcp_socket) { + LOG(ERROR) << "TCP socket is NULL"; return PP_ERROR_BADARGUMENT; - if (state_ != STATE_LISTENING) + } + if (state_ != STATE_LISTENING) { + LOG(ERROR) << "Socket not opened or already closed"; return PP_ERROR_FAILED; - if (TrackedCallback::IsPending(accept_callback_)) + } + if (TrackedCallback::IsPending(accept_callback_)) { + LOG(ERROR) << "Accept is pending"; return PP_ERROR_INPROGRESS; + } accept_callback_ = callback; @@ -70,10 +83,14 @@ int32_t TCPServerSocketPrivateResource::Accept( int32_t TCPServerSocketPrivateResource::GetLocalAddress( PP_NetAddress_Private* addr) { - if (!addr) + if (!addr) { + LOG(ERROR) << "Address is NULL"; return PP_ERROR_BADARGUMENT; - if (state_ != STATE_LISTENING) + } + if (state_ != STATE_LISTENING) { + LOG(ERROR) << "Socket not opened or already closed"; return PP_ERROR_FAILED; + } *addr = local_addr_; return PP_OK; } diff --git a/ppapi/proxy/tcp_socket_private_resource.cc b/ppapi/proxy/tcp_socket_private_resource.cc index ee6752a..3d50da2 100644 --- a/ppapi/proxy/tcp_socket_private_resource.cc +++ b/ppapi/proxy/tcp_socket_private_resource.cc @@ -4,6 +4,7 @@ #include "ppapi/proxy/tcp_socket_private_resource.h" +#include "base/logging.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/shared_impl/ppb_tcp_socket_shared.h" @@ -99,12 +100,14 @@ int32_t TCPSocketPrivateResource::SetOption( scoped_refptr callback) { switch (name) { case PP_TCPSOCKETOPTION_PRIVATE_INVALID: + LOG(ERROR) << "Invalid TCP socket private option"; return PP_ERROR_BADARGUMENT; case PP_TCPSOCKETOPTION_PRIVATE_NO_DELAY: return SetOptionImpl(PP_TCPSOCKET_OPTION_NO_DELAY, value, true, // Check connect() state. callback); default: + LOG(ERROR); NOTREACHED(); return PP_ERROR_BADARGUMENT; } diff --git a/ppapi/proxy/tcp_socket_resource.cc b/ppapi/proxy/tcp_socket_resource.cc index 20328cf..79af3649 100644 --- a/ppapi/proxy/tcp_socket_resource.cc +++ b/ppapi/proxy/tcp_socket_resource.cc @@ -49,8 +49,10 @@ thunk::PPB_TCPSocket_API* TCPSocketResource::AsPPB_TCPSocket_API() { int32_t TCPSocketResource::Bind(PP_Resource addr, scoped_refptr callback) { EnterNetAddressNoLock enter(addr, true); - if (enter.failed()) + if (enter.failed()) { + LOG(ERROR) << "Enter address failed"; return PP_ERROR_BADARGUMENT; + } return BindImpl(&enter.object()->GetNetAddressPrivate(), callback); } @@ -58,8 +60,10 @@ int32_t TCPSocketResource::Bind(PP_Resource addr, int32_t TCPSocketResource::Connect(PP_Resource addr, scoped_refptr callback) { EnterNetAddressNoLock enter(addr, true); - if (enter.failed()) + if (enter.failed()) { + LOG(ERROR) << "Enter address failed"; return PP_ERROR_BADARGUMENT; + } return ConnectWithNetAddressImpl(&enter.object()->GetNetAddressPrivate(), callback); diff --git a/ppapi/proxy/tcp_socket_resource_base.cc b/ppapi/proxy/tcp_socket_resource_base.cc index b0870b7..f4b0e22 100644 --- a/ppapi/proxy/tcp_socket_resource_base.cc +++ b/ppapi/proxy/tcp_socket_resource_base.cc @@ -66,12 +66,18 @@ TCPSocketResourceBase::~TCPSocketResourceBase() { int32_t TCPSocketResourceBase::BindImpl( const PP_NetAddress_Private* addr, scoped_refptr callback) { - if (!addr) + if (!addr) { + LOG(ERROR) << "Address is NULL"; return PP_ERROR_BADARGUMENT; - if (state_.IsPending(TCPSocketState::BIND)) + } + if (state_.IsPending(TCPSocketState::BIND)) { + LOG(ERROR) << "Bind is pending"; return PP_ERROR_INPROGRESS; - if (!state_.IsValidTransition(TCPSocketState::BIND)) + } + if (!state_.IsValidTransition(TCPSocketState::BIND)) { + LOG(ERROR) << "Invalid Transition"; return PP_ERROR_FAILED; + } bind_callback_ = callback; state_.SetPendingTransition(TCPSocketState::BIND); @@ -88,12 +94,18 @@ int32_t TCPSocketResourceBase::ConnectImpl( const char* host, uint16_t port, scoped_refptr callback) { - if (!host) + if (!host) { + LOG(ERROR) << "Host is NULL"; return PP_ERROR_BADARGUMENT; - if (state_.IsPending(TCPSocketState::CONNECT)) + } + if (state_.IsPending(TCPSocketState::CONNECT)) { + LOG(ERROR) << "Connect is pending"; return PP_ERROR_INPROGRESS; - if (!state_.IsValidTransition(TCPSocketState::CONNECT)) + } + if (!state_.IsValidTransition(TCPSocketState::CONNECT)) { + LOG(ERROR) << "Invalid Transition"; return PP_ERROR_FAILED; + } connect_callback_ = callback; state_.SetPendingTransition(TCPSocketState::CONNECT); @@ -109,12 +121,18 @@ int32_t TCPSocketResourceBase::ConnectImpl( int32_t TCPSocketResourceBase::ConnectWithNetAddressImpl( const PP_NetAddress_Private* addr, scoped_refptr callback) { - if (!addr) + if (!addr) { + LOG(ERROR) << "Address is NULL"; return PP_ERROR_BADARGUMENT; - if (state_.IsPending(TCPSocketState::CONNECT)) + } + if (state_.IsPending(TCPSocketState::CONNECT)) { + LOG(ERROR) << "ConnectWithNetAddress is pending"; return PP_ERROR_INPROGRESS; - if (!state_.IsValidTransition(TCPSocketState::CONNECT)) + } + if (!state_.IsValidTransition(TCPSocketState::CONNECT)) { + LOG(ERROR) << "Invalid Transition"; return PP_ERROR_FAILED; + } connect_callback_ = callback; state_.SetPendingTransition(TCPSocketState::CONNECT); @@ -147,16 +165,21 @@ int32_t TCPSocketResourceBase::SSLHandshakeImpl( const char* server_name, uint16_t server_port, scoped_refptr callback) { - if (!server_name) + if (!server_name) { + LOG(ERROR) << "Server name is NULL"; return PP_ERROR_BADARGUMENT; + } if (state_.IsPending(TCPSocketState::SSL_CONNECT) || TrackedCallback::IsPending(read_callback_) || TrackedCallback::IsPending(write_callback_)) { + LOG(ERROR) << "SSL Handshake is pending"; return PP_ERROR_INPROGRESS; } - if (!state_.IsValidTransition(TCPSocketState::SSL_CONNECT)) + if (!state_.IsValidTransition(TCPSocketState::SSL_CONNECT)) { + LOG(ERROR) << "Invalid Transition"; return PP_ERROR_FAILED; + } ssl_handshake_callback_ = callback; state_.SetPendingTransition(TCPSocketState::SSL_CONNECT); @@ -194,14 +217,24 @@ int32_t TCPSocketResourceBase::ReadImpl( char* buffer, int32_t bytes_to_read, scoped_refptr callback) { - if (!buffer || bytes_to_read <= 0) + if (!buffer) { + LOG(ERROR) << "Invalid buffer"; + return PP_ERROR_BADARGUMENT; + } else if (bytes_to_read <= 0) { + LOG(ERROR) << "Bytes to read must be positive, bytes_to_read=" + << bytes_to_read; return PP_ERROR_BADARGUMENT; + } - if (!state_.IsConnected()) + if (!state_.IsConnected()) { + LOG(ERROR) << "Socket is not connected"; return PP_ERROR_FAILED; + } if (TrackedCallback::IsPending(read_callback_) || - state_.IsPending(TCPSocketState::SSL_CONNECT)) + state_.IsPending(TCPSocketState::SSL_CONNECT)) { + LOG(ERROR) << "Read is pending"; return PP_ERROR_INPROGRESS; + } read_buffer_ = buffer; bytes_to_read_ = std::min(bytes_to_read, @@ -220,14 +253,24 @@ int32_t TCPSocketResourceBase::WriteImpl( const char* buffer, int32_t bytes_to_write, scoped_refptr callback) { - if (!buffer || bytes_to_write <= 0) + if (!buffer) { + LOG(ERROR) << "Invalid buffer"; + return PP_ERROR_BADARGUMENT; + } else if (bytes_to_write <= 0) { + LOG(ERROR) << "Bytes to write must be positive, bytes_to_write=" + << bytes_to_write; return PP_ERROR_BADARGUMENT; + } - if (!state_.IsConnected()) + if (!state_.IsConnected()) { + LOG(ERROR) << "Socket is not connected"; return PP_ERROR_FAILED; + } if (TrackedCallback::IsPending(write_callback_) || - state_.IsPending(TCPSocketState::SSL_CONNECT)) + state_.IsPending(TCPSocketState::SSL_CONNECT)) { + LOG(ERROR) << "Write is pending"; return PP_ERROR_INPROGRESS; + } if (bytes_to_write > TCPSocketResourceConstants::kMaxWriteSize) bytes_to_write = TCPSocketResourceConstants::kMaxWriteSize; @@ -246,12 +289,18 @@ int32_t TCPSocketResourceBase::WriteImpl( int32_t TCPSocketResourceBase::ListenImpl( int32_t backlog, scoped_refptr callback) { - if (backlog <= 0) + if (backlog <= 0) { + LOG(ERROR) << "Backlog is negative, backlog = " << backlog; return PP_ERROR_BADARGUMENT; - if (state_.IsPending(TCPSocketState::LISTEN)) + } + if (state_.IsPending(TCPSocketState::LISTEN)) { + LOG(ERROR) << "Listen is pending"; return PP_ERROR_INPROGRESS; - if (!state_.IsValidTransition(TCPSocketState::LISTEN)) + } + if (!state_.IsValidTransition(TCPSocketState::LISTEN)) { + LOG(ERROR) << "Invalid Transition"; return PP_ERROR_FAILED; + } listen_callback_ = callback; state_.SetPendingTransition(TCPSocketState::LISTEN); @@ -267,12 +316,18 @@ int32_t TCPSocketResourceBase::ListenImpl( int32_t TCPSocketResourceBase::AcceptImpl( PP_Resource* accepted_tcp_socket, scoped_refptr callback) { - if (!accepted_tcp_socket) + if (!accepted_tcp_socket) { + LOG(ERROR) << "Accepted TCP Socket is NULL"; return PP_ERROR_BADARGUMENT; - if (TrackedCallback::IsPending(accept_callback_)) + } + if (TrackedCallback::IsPending(accept_callback_)) { + LOG(ERROR) << "Accept is pending"; return PP_ERROR_INPROGRESS; - if (state_.state() != TCPSocketState::LISTENING) + } + if (state_.state() != TCPSocketState::LISTENING) { + LOG(ERROR) << "State is not equal to TCPSocketState::LISTENING"; return PP_ERROR_FAILED; + } accept_callback_ = callback; accepted_tcp_socket_ = accepted_tcp_socket; @@ -314,25 +369,34 @@ int32_t TCPSocketResourceBase::SetOptionImpl( SocketOptionData option_data; switch (name) { case PP_TCPSOCKET_OPTION_NO_DELAY: { - if (check_connect_state && !state_.IsConnected()) + if (check_connect_state && !state_.IsConnected()) { + LOG(ERROR) << "Socket is not connected"; return PP_ERROR_FAILED; + } - if (value.type != PP_VARTYPE_BOOL) + if (value.type != PP_VARTYPE_BOOL) { + LOG(ERROR) << "Wrong data type"; return PP_ERROR_BADARGUMENT; + } option_data.SetBool(PP_ToBool(value.value.as_bool)); break; } case PP_TCPSOCKET_OPTION_SEND_BUFFER_SIZE: case PP_TCPSOCKET_OPTION_RECV_BUFFER_SIZE: { - if (check_connect_state && !state_.IsConnected()) + if (check_connect_state && !state_.IsConnected()) { + LOG(ERROR) << "Socket is not connected"; return PP_ERROR_FAILED; + } - if (value.type != PP_VARTYPE_INT32) + if (value.type != PP_VARTYPE_INT32) { + LOG(ERROR) << "Wrong data type = " << value.type; return PP_ERROR_BADARGUMENT; + } option_data.SetInt32(value.value.as_int); break; } default: { + LOG(ERROR); NOTREACHED(); return PP_ERROR_BADARGUMENT; } diff --git a/ppapi/proxy/udp_socket_filter.cc b/ppapi/proxy/udp_socket_filter.cc index 07e9b31..b197a52 100644 --- a/ppapi/proxy/udp_socket_filter.cc +++ b/ppapi/proxy/udp_socket_filter.cc @@ -89,6 +89,7 @@ int32_t UDPSocketFilter::RequestData( base::AutoLock acquire(lock_); auto it = queues_.find(resource); if (it == queues_.end()) { + LOG(ERROR); NOTREACHED(); return PP_ERROR_FAILED; } @@ -207,10 +208,14 @@ int32_t UDPSocketFilter::RecvQueue::RequestData( PP_Resource* addr_out, const scoped_refptr& callback) { ProxyLock::AssertAcquired(); - if (!buffer_out || num_bytes <= 0) + if (!buffer_out || num_bytes <= 0) { + LOG(ERROR) << "Buffer out is NULL or num_bytes <= 0, bytes = " << num_bytes; return PP_ERROR_BADARGUMENT; - if (TrackedCallback::IsPending(recvfrom_callback_)) + } + if (TrackedCallback::IsPending(recvfrom_callback_)) { + LOG(ERROR) << "RequestData is pending"; return PP_ERROR_INPROGRESS; + } if (recv_buffers_.empty()) { read_buffer_ = buffer_out; @@ -223,8 +228,12 @@ int32_t UDPSocketFilter::RecvQueue::RequestData( } else { RecvBuffer& front = recv_buffers_.front(); - if (static_cast(num_bytes) < front.data.size()) + if (static_cast(num_bytes) < front.data.size()) { + LOG(ERROR) << "Front data size is to small for that num_bytes, " + << "bytes = " << num_bytes + << ", font data size = " << front.data.size(); return PP_ERROR_MESSAGE_TOO_BIG; + } std::unique_ptr data_to_pass(new std::string); data_to_pass->swap(front.data); diff --git a/ppapi/proxy/udp_socket_private_resource.cc b/ppapi/proxy/udp_socket_private_resource.cc index ce6cf77..6be1ee2 100644 --- a/ppapi/proxy/udp_socket_private_resource.cc +++ b/ppapi/proxy/udp_socket_private_resource.cc @@ -36,8 +36,10 @@ int32_t UDPSocketPrivateResource::SetSocketFeature( public_name = PP_UDPSOCKET_OPTION_BROADCAST; break; case PP_UDPSOCKETFEATURE_PRIVATE_COUNT: + LOG(ERROR); return PP_ERROR_BADARGUMENT; default: + LOG(ERROR); NOTREACHED(); return PP_ERROR_BADARGUMENT; } diff --git a/ppapi/proxy/uma_private_resource.cc b/ppapi/proxy/uma_private_resource.cc index 1590097..994c884 100644 --- a/ppapi/proxy/uma_private_resource.cc +++ b/ppapi/proxy/uma_private_resource.cc @@ -5,6 +5,7 @@ #include "ppapi/proxy/uma_private_resource.h" #include "base/bind.h" +#include "base/logging.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/proxy/resource_message_params.h" #include "ppapi/shared_impl/var.h" @@ -87,8 +88,10 @@ void UMAPrivateResource::HistogramEnumeration( int32_t UMAPrivateResource::IsCrashReportingEnabled( PP_Instance instance, scoped_refptr callback) { - if (pending_callback_.get() != NULL) + if (pending_callback_.get() != NULL) { + LOG(ERROR) << "CrashReporting pending"; return PP_ERROR_INPROGRESS; + } pending_callback_ = callback; Call( RENDERER, PpapiHostMsg_UMA_IsCrashReportingEnabled(), diff --git a/ppapi/proxy/url_loader_resource.cc b/ppapi/proxy/url_loader_resource.cc index 72a1ec5..cfd75c2 100644 --- a/ppapi/proxy/url_loader_resource.cc +++ b/ppapi/proxy/url_loader_resource.cc @@ -80,6 +80,7 @@ int32_t URLLoaderResource::Open(PP_Resource request_id, "PPB_URLLoader.Open: invalid request resource ID. (Hint to C++ wrapper" " users: use the ResourceRequest constructor that takes an instance or" " else the request will be null.)"); + LOG(ERROR) << "Enter URLRequestInfo failed"; return PP_ERROR_BADARGUMENT; } return Open(enter_request.object()->GetData(), 0, callback); @@ -92,8 +93,10 @@ int32_t URLLoaderResource::Open( int32_t rv = ValidateCallback(callback); if (rv != PP_OK) return rv; - if (mode_ != MODE_WAITING_TO_OPEN) + if (mode_ != MODE_WAITING_TO_OPEN) { + LOG(ERROR) << "URLLoader already opened"; return PP_ERROR_INPROGRESS; + } request_data_ = request_data; @@ -110,8 +113,10 @@ int32_t URLLoaderResource::FollowRedirect( int32_t rv = ValidateCallback(callback); if (rv != PP_OK) return rv; - if (mode_ != MODE_OPENING) + if (mode_ != MODE_OPENING) { + LOG(ERROR) << "URLLoader already opened"; return PP_ERROR_INPROGRESS; + } SetDefersLoading(false); // Allow the redirect to continue. RegisterCallback(callback); @@ -156,11 +161,16 @@ int32_t URLLoaderResource::ReadResponseBody( int32_t rv = ValidateCallback(callback); if (rv != PP_OK) return rv; - if (!response_info_.get()) + if (!response_info_.get()) { + LOG(ERROR) << "Cannot get response info"; return PP_ERROR_FAILED; + } - if (bytes_to_read <= 0 || !buffer) + if (bytes_to_read <= 0 || !buffer) { + LOG(ERROR) << "Buffer is " << buffer + << ", bytes to read = " << bytes_to_read; return PP_ERROR_BADARGUMENT; + } user_buffer_ = static_cast(buffer); user_buffer_size_ = bytes_to_read; @@ -308,8 +318,10 @@ void URLLoaderResource::SetDefersLoading(bool defers_loading) { int32_t URLLoaderResource::ValidateCallback( scoped_refptr callback) { DCHECK(callback.get()); - if (TrackedCallback::IsPending(pending_callback_)) + if (TrackedCallback::IsPending(pending_callback_)) { + LOG(ERROR) << "Validate is pending"; return PP_ERROR_INPROGRESS; + } return PP_OK; } diff --git a/ppapi/proxy/video_capture_resource.cc b/ppapi/proxy/video_capture_resource.cc index 825568a..eab57a9 100644 --- a/ppapi/proxy/video_capture_resource.cc +++ b/ppapi/proxy/video_capture_resource.cc @@ -7,6 +7,7 @@ #include #include "base/bind.h" +#include "base/logging.h" #include "ppapi/c/dev/ppp_video_capture_dev.h" #include "ppapi/proxy/dispatch_reply_message.h" #include "ppapi/proxy/plugin_dispatcher.h" @@ -82,11 +83,15 @@ int32_t VideoCaptureResource::Open( const PP_VideoCaptureDeviceInfo_Dev& requested_info, uint32_t buffer_count, scoped_refptr callback) { - if (open_state_ != BEFORE_OPEN) + if (open_state_ != BEFORE_OPEN) { + LOG(ERROR) << "Video capture resource was already opened"; return PP_ERROR_FAILED; + } - if (TrackedCallback::IsPending(open_callback_)) + if (TrackedCallback::IsPending(open_callback_)) { + LOG(ERROR) << "Open is pending"; return PP_ERROR_INPROGRESS; + } open_callback_ = callback; @@ -98,23 +103,31 @@ int32_t VideoCaptureResource::Open( } int32_t VideoCaptureResource::StartCapture() { - if (open_state_ != OPENED) + if (open_state_ != OPENED) { + LOG(ERROR) << "Video capture resource not opened"; return PP_ERROR_FAILED; + } Post(RENDERER, PpapiHostMsg_VideoCapture_StartCapture()); return PP_OK; } int32_t VideoCaptureResource::ReuseBuffer(uint32_t buffer) { - if (buffer >= buffer_in_use_.size() || !buffer_in_use_[buffer]) + if (buffer >= buffer_in_use_.size() || !buffer_in_use_[buffer]) { + LOG(ERROR) << "Wrong buffer ID = " << buffer << ", should be less than" + << buffer_in_use_.size() + << "or buffer ID is not busy = " << buffer_in_use_[buffer]; return PP_ERROR_BADARGUMENT; + } Post(RENDERER, PpapiHostMsg_VideoCapture_ReuseBuffer(buffer)); return PP_OK; } int32_t VideoCaptureResource::StopCapture() { - if (open_state_ != OPENED) + if (open_state_ != OPENED) { + LOG(ERROR) << "Video capture resource not opened"; return PP_ERROR_FAILED; + } Post(RENDERER, PpapiHostMsg_VideoCapture_StopCapture()); return PP_OK; diff --git a/ppapi/proxy/video_decoder_resource.cc b/ppapi/proxy/video_decoder_resource.cc index 98f43fb..5f344a3 100644 --- a/ppapi/proxy/video_decoder_resource.cc +++ b/ppapi/proxy/video_decoder_resource.cc @@ -7,6 +7,7 @@ #include #include "base/bind.h" +#include "base/logging.h" #include "gpu/command_buffer/client/gles2_cmd_helper.h" #include "gpu/command_buffer/client/gles2_implementation.h" #include "gpu/command_buffer/common/mailbox.h" @@ -123,16 +124,27 @@ int32_t VideoDecoderResource::Initialize( PP_HardwareAcceleration acceleration, uint32_t min_picture_count, scoped_refptr callback) { - if (initialized_) + if (initialized_) { + LOG(ERROR) << "Already initialized"; return PP_ERROR_FAILED; - if (profile < 0 || profile > PP_VIDEOPROFILE_MAX) + } + if (profile < 0 || profile > PP_VIDEOPROFILE_MAX) { + LOG(ERROR) << "Wrong profile = " << static_cast(profile); return PP_ERROR_BADARGUMENT; - if (min_picture_count > kMaximumPictureCount) + } + if (min_picture_count > kMaximumPictureCount) { + LOG(ERROR) << "min_picture_count = " << min_picture_count + << "should be less or equal to " << kMaximumPictureCount; return PP_ERROR_BADARGUMENT; - if (initialize_callback_.get()) + } + if (initialize_callback_.get()) { + LOG(ERROR) << "Initialize is pending"; return PP_ERROR_INPROGRESS; - if (!graphics_context) + } + if (!graphics_context) { + LOG(ERROR) << "Graphics context is NULL"; return PP_ERROR_BADRESOURCE; + } min_picture_count_ = min_picture_count; @@ -142,8 +154,10 @@ int32_t VideoDecoderResource::Initialize( // share with the plugin. We can't use the plugin's Graphics3D, since we // create textures on a proxy thread, and would interfere with the plugin. thunk::EnterResourceCreationNoLock enter_create(pp_instance()); - if (enter_create.failed()) + if (enter_create.failed()) { + LOG(ERROR) << "Enter pp_instance failed"; return PP_ERROR_FAILED; + } int32_t attrib_list[] = {PP_GRAPHICS3DATTRIB_NONE}; graphics3d_ = ScopedPPResource(ScopedPPResource::PassRef(), @@ -151,8 +165,10 @@ int32_t VideoDecoderResource::Initialize( pp_instance(), graphics_context, attrib_list)); EnterResourceNoLock enter_graphics(graphics3d_.get(), false); - if (enter_graphics.failed()) + if (enter_graphics.failed()) { + LOG(ERROR) << "Enter Graphics3D failed"; return PP_ERROR_BADRESOURCE; + } PPB_Graphics3D_Shared* ppb_graphics3d_shared = static_cast(enter_graphics.object()); @@ -178,12 +194,18 @@ int32_t VideoDecoderResource::Decode(uint32_t decode_id, scoped_refptr callback) { if (decoder_last_error_) return decoder_last_error_; - if (flush_callback_.get() || reset_callback_.get()) + if (flush_callback_.get() || reset_callback_.get()) { + LOG(ERROR) << "Get flush_callback or reset_callback"; return PP_ERROR_FAILED; - if (decode_callback_.get()) + } + if (decode_callback_.get()) { + LOG(ERROR) << "Decode is pending"; return PP_ERROR_INPROGRESS; - if (size > kMaximumBitstreamBufferSize) + } + if (size > kMaximumBitstreamBufferSize) { + LOG(ERROR) << "Wrong size = " << size; return PP_ERROR_NOMEMORY; + } // If we allow the plugin to call Decode again, we must have somewhere to // copy their buffer. @@ -223,19 +245,27 @@ int32_t VideoDecoderResource::Decode(uint32_t decode_id, PpapiHostMsg_VideoDecoder_GetShm(shm_id, size), &reply, &reply_params); - if (result != PP_OK) + if (result != PP_OK) { + LOG(ERROR) << "Error in GenericSyncCall, result =" << result; return PP_ERROR_FAILED; + } if (!UnpackMessage(reply, - &shm_size)) + &shm_size)) { + LOG(ERROR) << "Cannot unpack message"; return PP_ERROR_FAILED; + } base::UnsafeSharedMemoryRegion shm_region; if (!reply_params.TakeUnsafeSharedMemoryRegionAtIndex(0, &shm_region) || - !shm_region.IsValid() || shm_region.GetSize() != shm_size) + !shm_region.IsValid() || shm_region.GetSize() != shm_size) { + LOG(ERROR) << "Cannot take shared memory handle at index 0"; return PP_ERROR_NOMEMORY; + } std::unique_ptr shm_buffer( new ShmBuffer(std::move(shm_region), shm_id)); - if (!shm_buffer->addr) + if (!shm_buffer->addr) { + LOG(ERROR) << "shm_buffer->addr is NULL"; return PP_ERROR_NOMEMORY; + } available_shm_buffers_.push_back(shm_buffer.get()); if (shm_buffers_.size() < kMaximumPendingDecodes) @@ -280,10 +310,14 @@ int32_t VideoDecoderResource::GetPicture( scoped_refptr callback) { if (decoder_last_error_) return decoder_last_error_; - if (reset_callback_.get()) + if (reset_callback_.get()) { + LOG(ERROR) << "Got reset callback"; return PP_ERROR_FAILED; - if (get_picture_callback_.get()) + } + if (get_picture_callback_.get()) { + LOG(ERROR) << "GetPicture is pending"; return PP_ERROR_INPROGRESS; + } get_picture_ = picture; @@ -308,10 +342,14 @@ void VideoDecoderResource::RecyclePicture(const PP_VideoPicture* picture) { int32_t VideoDecoderResource::Flush(scoped_refptr callback) { if (decoder_last_error_) return decoder_last_error_; - if (reset_callback_.get()) + if (reset_callback_.get()) { + LOG(ERROR) << "Got reset callback"; return PP_ERROR_FAILED; - if (flush_callback_.get()) + } + if (flush_callback_.get()) { + LOG(ERROR) << "Flush is pending"; return PP_ERROR_INPROGRESS; + } flush_callback_ = callback; Call( @@ -324,10 +362,14 @@ int32_t VideoDecoderResource::Flush(scoped_refptr callback) { int32_t VideoDecoderResource::Reset(scoped_refptr callback) { if (decoder_last_error_) return decoder_last_error_; - if (flush_callback_.get()) + if (flush_callback_.get()) { + LOG(ERROR) << "Got flush callback"; return PP_ERROR_FAILED; - if (reset_callback_.get()) + } + if (reset_callback_.get()) { + LOG(ERROR) << "Reset is pending"; return PP_ERROR_INPROGRESS; + } reset_callback_ = callback; // Cause any pending Decode or GetPicture callbacks to abort after we return, diff --git a/ppapi/proxy/video_encoder_resource.cc b/ppapi/proxy/video_encoder_resource.cc index 877ace6..dd1062a 100644 --- a/ppapi/proxy/video_encoder_resource.cc +++ b/ppapi/proxy/video_encoder_resource.cc @@ -8,6 +8,7 @@ #include #include "base/bind.h" +#include "base/logging.h" #include "base/memory/unsafe_shared_memory_region.h" #include "base/numerics/safe_conversions.h" #include "ppapi/c/pp_array_output.h" @@ -97,8 +98,10 @@ PPB_VideoEncoder_API* VideoEncoderResource::AsPPB_VideoEncoder_API() { int32_t VideoEncoderResource::GetSupportedProfiles( const PP_ArrayOutput& output, const scoped_refptr& callback) { - if (TrackedCallback::IsPending(get_supported_profiles_callback_)) + if (TrackedCallback::IsPending(get_supported_profiles_callback_)) { + LOG(ERROR) << "GetSupportedProfiles is pending"; return PP_ERROR_INPROGRESS; + } get_supported_profiles_callback_ = callback; Call( @@ -112,8 +115,10 @@ int32_t VideoEncoderResource::GetSupportedProfiles( int32_t VideoEncoderResource::GetSupportedProfiles0_1( const PP_ArrayOutput& output, const scoped_refptr& callback) { - if (TrackedCallback::IsPending(get_supported_profiles_callback_)) + if (TrackedCallback::IsPending(get_supported_profiles_callback_)) { + LOG(ERROR) << "GetSupportedProfiles0_1 is pending"; return PP_ERROR_INPROGRESS; + } get_supported_profiles_callback_ = callback; Call( @@ -144,10 +149,14 @@ int32_t VideoEncoderResource::Initialize( uint32_t initial_bitrate, PP_HardwareAcceleration acceleration, const scoped_refptr& callback) { - if (initialized_) + if (initialized_) { + LOG(ERROR) << "Already initialized"; return PP_ERROR_FAILED; - if (TrackedCallback::IsPending(initialize_callback_)) + } + if (TrackedCallback::IsPending(initialize_callback_)) { + LOG(ERROR) << "Initialize is pending"; return PP_ERROR_INPROGRESS; + } initialize_callback_ = callback; Call( @@ -165,8 +174,10 @@ int32_t VideoEncoderResource::GetVideoFrame( if (encoder_last_error_) return encoder_last_error_; - if (TrackedCallback::IsPending(get_video_frame_callback_)) + if (TrackedCallback::IsPending(get_video_frame_callback_)) { + LOG(ERROR) << "GetVideoFrame is pending"; return PP_ERROR_INPROGRESS; + } get_video_frame_data_ = video_frame; get_video_frame_callback_ = callback; @@ -192,9 +203,11 @@ int32_t VideoEncoderResource::Encode( return encoder_last_error_; VideoFrameMap::iterator it = video_frames_.find(video_frame); - if (it == video_frames_.end()) + if (it == video_frames_.end()) { // TODO(llandwerlin): accept MediaStreamVideoTrack's video frames. + LOG(ERROR) << "Video frame not found"; return PP_ERROR_BADRESOURCE; + } scoped_refptr frame_resource = it->second; @@ -219,8 +232,10 @@ int32_t VideoEncoderResource::GetBitstreamBuffer( const scoped_refptr& callback) { if (encoder_last_error_) return encoder_last_error_; - if (TrackedCallback::IsPending(get_bitstream_buffer_callback_)) + if (TrackedCallback::IsPending(get_bitstream_buffer_callback_)) { + LOG(ERROR) << "GetBitstreamBuffer is pending"; return PP_ERROR_INPROGRESS; + } get_bitstream_buffer_callback_ = callback; get_bitstream_buffer_data_ = bitstream_buffer; diff --git a/ppapi/proxy/websocket_resource.cc b/ppapi/proxy/websocket_resource.cc index f3d9fe7..d38df0d 100644 --- a/ppapi/proxy/websocket_resource.cc +++ b/ppapi/proxy/websocket_resource.cc @@ -12,6 +12,7 @@ #include #include "base/bind.h" +#include "base/logging.h" #include "base/numerics/safe_conversions.h" #include "ppapi/c/pp_errors.h" #include "ppapi/proxy/dispatch_reply_message.h" @@ -82,18 +83,24 @@ int32_t WebSocketResource::Connect( const PP_Var protocols[], uint32_t protocol_count, scoped_refptr callback) { - if (TrackedCallback::IsPending(connect_callback_)) + if (TrackedCallback::IsPending(connect_callback_)) { + LOG(ERROR) << "Connect is pending"; return PP_ERROR_INPROGRESS; + } // Connect() can be called at most once. - if (state_ != PP_WEBSOCKETREADYSTATE_INVALID) + if (state_ != PP_WEBSOCKETREADYSTATE_INVALID) { + LOG(ERROR) << "Connect can be called at most once"; return PP_ERROR_INPROGRESS; + } state_ = PP_WEBSOCKETREADYSTATE_CLOSED; // Get the URL. url_ = StringVar::FromPPVar(url); - if (!url_.get()) + if (!url_.get()) { + LOG(ERROR) << "Invalid URL"; return PP_ERROR_BADARGUMENT; + } // Get the protocols. std::set protocol_set; @@ -103,12 +110,16 @@ int32_t WebSocketResource::Connect( scoped_refptr protocol(StringVar::FromPPVar(protocols[i])); // Check invalid and empty entries. - if (!protocol.get() || !protocol->value().length()) + if (!protocol.get() || !protocol->value().length()) { + LOG(ERROR) << "Invalid protocol"; return PP_ERROR_BADARGUMENT; + } // Check duplicated protocol entries. - if (protocol_set.find(protocol->value()) != protocol_set.end()) + if (protocol_set.find(protocol->value()) != protocol_set.end()) { + LOG(ERROR) << "Duplicate protocol entry"; return PP_ERROR_BADARGUMENT; + } protocol_set.insert(protocol->value()); protocol_strings.push_back(protocol->value()); @@ -132,10 +143,14 @@ int32_t WebSocketResource::Connect( int32_t WebSocketResource::Close(uint16_t code, const PP_Var& reason, scoped_refptr callback) { - if (TrackedCallback::IsPending(close_callback_)) + if (TrackedCallback::IsPending(close_callback_)) { + LOG(ERROR) << "Close is pending"; return PP_ERROR_INPROGRESS; - if (state_ == PP_WEBSOCKETREADYSTATE_INVALID) + } + if (state_ == PP_WEBSOCKETREADYSTATE_INVALID) { + LOG(ERROR) << "Close can be called at most once"; return PP_ERROR_FAILED; + } // Validate |code| and |reason|. scoped_refptr reason_string_var; @@ -143,11 +158,13 @@ int32_t WebSocketResource::Close(uint16_t code, if (code != PP_WEBSOCKETSTATUSCODE_NOT_SPECIFIED) { if (code != PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE && (code < PP_WEBSOCKETSTATUSCODE_USER_REGISTERED_MIN || - code > PP_WEBSOCKETSTATUSCODE_USER_PRIVATE_MAX)) + code > PP_WEBSOCKETSTATUSCODE_USER_PRIVATE_MAX)) { // RFC 6455 limits applications to use reserved connection close code in // section 7.4.2.. The WebSocket API (http://www.w3.org/TR/websockets/) // defines this out of range error as InvalidAccessError in JavaScript. + LOG(ERROR) << "Insufficient permissions"; return PP_ERROR_NOACCESS; + } // |reason| must be ignored if it is PP_VARTYPE_UNDEFINED or |code| is // PP_WEBSOCKETSTATUSCODE_NOT_SPECIFIED. @@ -155,15 +172,19 @@ int32_t WebSocketResource::Close(uint16_t code, // Validate |reason|. reason_string_var = StringVar::FromPPVar(reason); if (!reason_string_var.get() || - reason_string_var->value().size() > kMaxReasonSizeInBytes) + reason_string_var->value().size() > kMaxReasonSizeInBytes) { + LOG(ERROR) << "Invalid close reason string"; return PP_ERROR_BADARGUMENT; + } reason_string = reason_string_var->value(); } } // Check state. - if (state_ == PP_WEBSOCKETREADYSTATE_CLOSING) + if (state_ == PP_WEBSOCKETREADYSTATE_CLOSING) { + LOG(ERROR) << "Close is pending"; return PP_ERROR_INPROGRESS; + } if (state_ == PP_WEBSOCKETREADYSTATE_CLOSED) return PP_OK; @@ -202,13 +223,17 @@ int32_t WebSocketResource::Close(uint16_t code, int32_t WebSocketResource::ReceiveMessage( PP_Var* message, scoped_refptr callback) { - if (TrackedCallback::IsPending(receive_callback_)) + if (TrackedCallback::IsPending(receive_callback_)) { + LOG(ERROR) << "ReceiveMessage is pending"; return PP_ERROR_INPROGRESS; + } // Check state. if (state_ == PP_WEBSOCKETREADYSTATE_INVALID || - state_ == PP_WEBSOCKETREADYSTATE_CONNECTING) + state_ == PP_WEBSOCKETREADYSTATE_CONNECTING) { + LOG(ERROR) << "WebSocket not connected"; return PP_ERROR_BADARGUMENT; + } // Just return received message if any received message is queued. if (!received_messages_.empty()) { @@ -217,13 +242,17 @@ int32_t WebSocketResource::ReceiveMessage( } // Check state again. In CLOSED state, no more messages will be received. - if (state_ == PP_WEBSOCKETREADYSTATE_CLOSED) + if (state_ == PP_WEBSOCKETREADYSTATE_CLOSED) { + LOG(ERROR) << "WebSocket already closed"; return PP_ERROR_BADARGUMENT; + } // Returns PP_ERROR_FAILED after an error is received and received messages // is exhausted. - if (error_was_received_) + if (error_was_received_) { + LOG(ERROR) << "Received an error"; return PP_ERROR_FAILED; + } // Or retain |message| as buffer to store and install |callback|. receive_callback_var_ = message; @@ -235,8 +264,10 @@ int32_t WebSocketResource::ReceiveMessage( int32_t WebSocketResource::SendMessage(const PP_Var& message) { // Check state. if (state_ == PP_WEBSOCKETREADYSTATE_INVALID || - state_ == PP_WEBSOCKETREADYSTATE_CONNECTING) + state_ == PP_WEBSOCKETREADYSTATE_CONNECTING) { + LOG(ERROR) << "Wrong state"; return PP_ERROR_BADARGUMENT; + } if (state_ == PP_WEBSOCKETREADYSTATE_CLOSING || state_ == PP_WEBSOCKETREADYSTATE_CLOSED) { @@ -253,12 +284,14 @@ int32_t WebSocketResource::SendMessage(const PP_Var& message) { payload_size += message_array_buffer->ByteLength(); } else { // TODO(toyoshim): Support Blob. + LOG(ERROR) << message.type << " is not supported"; return PP_ERROR_NOTSUPPORTED; } buffered_amount_after_close_ = SaturateAdd(buffered_amount_after_close_, GetFrameSize(payload_size)); + LOG(ERROR); return PP_ERROR_FAILED; } @@ -266,15 +299,19 @@ int32_t WebSocketResource::SendMessage(const PP_Var& message) { if (message.type == PP_VARTYPE_STRING) { // Convert message to std::string, then send it. scoped_refptr message_string = StringVar::FromPPVar(message); - if (!message_string.get()) + if (!message_string.get()) { + LOG(ERROR) << "message_string is NULL"; return PP_ERROR_BADARGUMENT; + } Post(RENDERER, PpapiHostMsg_WebSocket_SendText(message_string->value())); } else if (message.type == PP_VARTYPE_ARRAY_BUFFER) { // Convert message to std::vector, then send it. scoped_refptr message_arraybuffer = ArrayBufferVar::FromPPVar(message); - if (!message_arraybuffer.get()) + if (!message_arraybuffer.get()) { + LOG(ERROR) << "Cannot get message_arraybuffer"; return PP_ERROR_BADARGUMENT; + } uint8_t* message_data = static_cast(message_arraybuffer->Map()); uint32_t message_length = message_arraybuffer->ByteLength(); std::vector message_vector(message_data, @@ -282,6 +319,7 @@ int32_t WebSocketResource::SendMessage(const PP_Var& message) { Post(RENDERER, PpapiHostMsg_WebSocket_SendBinary(message_vector)); } else { // TODO(toyoshim): Support Blob. + LOG(ERROR) << message.type << " is not supported"; return PP_ERROR_NOTSUPPORTED; } return PP_OK; diff --git a/ppapi/shared_impl/file_io_state_manager.cc b/ppapi/shared_impl/file_io_state_manager.cc index 4783aef..b8f9e2b 100644 --- a/ppapi/shared_impl/file_io_state_manager.cc +++ b/ppapi/shared_impl/file_io_state_manager.cc @@ -5,6 +5,7 @@ #include "ppapi/shared_impl/file_io_state_manager.h" #include "base/check_op.h" +#include "base/logging.h" #include "ppapi/c/pp_errors.h" namespace ppapi { @@ -19,16 +20,22 @@ void FileIOStateManager::SetOpenSucceed() { file_open_ = true; } int32_t FileIOStateManager::CheckOperationState(OperationType new_op, bool should_be_open) { if (should_be_open) { - if (!file_open_) + if (!file_open_) { + LOG(ERROR) << "File not opened"; return PP_ERROR_FAILED; + } } else { - if (file_open_) + if (file_open_) { + LOG(ERROR) << "File already opened"; return PP_ERROR_FAILED; + } } if (pending_op_ != OPERATION_NONE && - (pending_op_ != new_op || pending_op_ == OPERATION_EXCLUSIVE)) + (pending_op_ != new_op || pending_op_ == OPERATION_EXCLUSIVE)) { + LOG(ERROR) << "Operation is in progress"; return PP_ERROR_INPROGRESS; + } return PP_OK; } diff --git a/ppapi/shared_impl/media_stream_buffer_manager.cc b/ppapi/shared_impl/media_stream_buffer_manager.cc index 225de5d..d4a0a38 100644 --- a/ppapi/shared_impl/media_stream_buffer_manager.cc +++ b/ppapi/shared_impl/media_stream_buffer_manager.cc @@ -9,6 +9,7 @@ #include #include "base/check_op.h" +#include "base/logging.h" #include "ppapi/c/pp_errors.h" #include "ppapi/shared_impl/media_stream_buffer.h" @@ -57,8 +58,10 @@ bool MediaStreamBufferManager::SetBuffers(int32_t number_of_buffers, } int32_t MediaStreamBufferManager::DequeueBuffer() { - if (buffer_queue_.empty()) + if (buffer_queue_.empty()) { + LOG(ERROR) << "Buffer queue is empty"; return PP_ERROR_FAILED; + } int32_t buffer = buffer_queue_.front(); buffer_queue_.pop_front(); return buffer; diff --git a/ppapi/shared_impl/ppb_graphics_3d_shared.cc b/ppapi/shared_impl/ppb_graphics_3d_shared.cc index b771dbb..0689f60 100644 --- a/ppapi/shared_impl/ppb_graphics_3d_shared.cc +++ b/ppapi/shared_impl/ppb_graphics_3d_shared.cc @@ -35,16 +35,19 @@ thunk::PPB_Graphics3D_API* PPB_Graphics3D_Shared::AsPPB_Graphics3D_API() { int32_t PPB_Graphics3D_Shared::GetAttribs(int32_t attrib_list[]) { // TODO(alokp): Implement me. + LOG(ERROR) << "Method not implemented"; return PP_ERROR_FAILED; } int32_t PPB_Graphics3D_Shared::SetAttribs(const int32_t attrib_list[]) { // TODO(alokp): Implement me. + LOG(ERROR) << "Method not implemented"; return PP_ERROR_FAILED; } int32_t PPB_Graphics3D_Shared::GetError() { // TODO(alokp): Implement me. + LOG(ERROR) << "Method not implemented"; return PP_ERROR_FAILED; } @@ -82,6 +85,7 @@ int32_t PPB_Graphics3D_Shared::SwapBuffersWithSyncToken( int32_t PPB_Graphics3D_Shared::GetAttribMaxValue(int32_t attribute, int32_t* value) { // TODO(alokp): Implement me. + LOG(ERROR) << "Method not implemented"; return PP_ERROR_FAILED; } diff --git a/ppapi/shared_impl/ppb_instance_shared.cc b/ppapi/shared_impl/ppb_instance_shared.cc index f0d470e..b5e6936 100644 --- a/ppapi/shared_impl/ppb_instance_shared.cc +++ b/ppapi/shared_impl/ppb_instance_shared.cc @@ -6,6 +6,7 @@ #include +#include "base/logging.h" #include "base/threading/platform_thread.h" #include "base/trace_event/trace_event.h" #include "ppapi/c/pp_errors.h" @@ -47,12 +48,16 @@ int32_t PPB_Instance_Shared::ValidateRequestInputEvents( bool is_filtering, uint32_t event_classes) { // See if any bits are set we don't know about. - if (event_classes & ~static_cast(PP_INPUTEVENT_CLASS_MOUSE | + uint32_t result = + event_classes & ~static_cast(PP_INPUTEVENT_CLASS_MOUSE | PP_INPUTEVENT_CLASS_KEYBOARD | PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_TOUCH | - PP_INPUTEVENT_CLASS_IME)) + PP_INPUTEVENT_CLASS_IME); + if (result) { + LOG(ERROR) << "Not supported input event, result = " << result; return PP_ERROR_NOTSUPPORTED; + } // Everything else is valid. return PP_OK; diff --git a/ppapi/thunk/ppb_tcp_server_socket_private_thunk.cc b/ppapi/thunk/ppb_tcp_server_socket_private_thunk.cc index 91fbdf4..944085a 100644 --- a/ppapi/thunk/ppb_tcp_server_socket_private_thunk.cc +++ b/ppapi/thunk/ppb_tcp_server_socket_private_thunk.cc @@ -4,6 +4,7 @@ #include +#include "base/logging.h" #include "ppapi/c/pp_errors.h" #include "ppapi/c/private/ppb_tcp_server_socket_private.h" #include "ppapi/shared_impl/tracked_callback.h" @@ -54,8 +55,10 @@ int32_t Accept(PP_Resource tcp_server_socket, int32_t GetLocalAddress(PP_Resource tcp_server_socket, PP_NetAddress_Private* addr) { EnterTCPServer enter(tcp_server_socket, true); - if (enter.failed()) + if (enter.failed()) { + LOG(ERROR) << "Enter tcp server socket failed"; return PP_ERROR_BADRESOURCE; + } return enter.object()->GetLocalAddress(addr); } diff --git a/ppapi/thunk/ppb_udp_socket_private_thunk.cc b/ppapi/thunk/ppb_udp_socket_private_thunk.cc index 0375282..4bebc2f 100644 --- a/ppapi/thunk/ppb_udp_socket_private_thunk.cc +++ b/ppapi/thunk/ppb_udp_socket_private_thunk.cc @@ -4,6 +4,7 @@ #include +#include "base/logging.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_errors.h" #include "ppapi/c/private/ppb_udp_socket_private.h" @@ -36,8 +37,10 @@ int32_t SetSocketFeature(PP_Resource udp_socket, PP_UDPSocketFeature_Private name, PP_Var value) { EnterUDP enter(udp_socket, true); - if (enter.failed()) + if (enter.failed()) { + LOG(ERROR) << "Enter udpsocket failed"; return PP_ERROR_BADRESOURCE; + } return enter.object()->SetSocketFeature(name, value); } -- 2.7.4