From 903a554f50298b3404e909343aa370b683911fb1 Mon Sep 17 00:00:00 2001 From: jiangyuwei Date: Thu, 23 Mar 2023 15:43:29 +0800 Subject: [PATCH 01/16] [M108 Migration][VD] Enable Suspend & resume feature Because RenderViewObserverEfl unavailable in M108, so need to implement in widget.mojom References: - https://review.tizen.org/gerrit/284921/ Change-Id: Ib558fcb5a21f34c0aaf7946b07c161342ee74e1a Signed-off-by: jiangyuwei --- .../renderer_host/render_widget_host_impl.cc | 10 +++++ .../renderer_host/render_widget_host_impl.h | 5 +++ content/public/browser/render_view_host.h | 5 +++ .../public/mojom/widget/platform_widget.mojom | 6 +++ third_party/blink/public/web/web_view.h | 5 +++ .../blink/renderer/core/exported/web_view_impl.cc | 49 ++++++++++++++++++++++ .../blink/renderer/core/exported/web_view_impl.h | 5 +++ .../renderer/core/frame/web_frame_widget_impl.cc | 10 +++++ .../renderer/core/frame/web_frame_widget_impl.h | 5 +++ third_party/blink/renderer/core/page/page.cc | 9 ++++ third_party/blink/renderer/core/page/page.h | 24 +++++++++++ .../blink/renderer/platform/widget/widget_base.cc | 10 +++++ .../blink/renderer/platform/widget/widget_base.h | 6 +++ .../renderer/platform/widget/widget_base_client.h | 5 +++ .../efl_integration/common/render_messages_ewk.h | 2 - tizen_src/ewk/efl_integration/eweb_view.cc | 21 +++------- 16 files changed, 160 insertions(+), 17 deletions(-) diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc index 02d6156..05c1be4 100644 --- a/content/browser/renderer_host/render_widget_host_impl.cc +++ b/content/browser/renderer_host/render_widget_host_impl.cc @@ -592,6 +592,16 @@ void RenderWidgetHostImpl::SetView(RenderWidgetHostViewBase* view) { } } +#if BUILDFLAG(IS_TIZEN) +void RenderWidgetHostImpl::PauseScheduledTasks() { + blink_widget_->PauseScheduledTasks(); +} + +void RenderWidgetHostImpl::UnPauseScheduledTasks() { + blink_widget_->UnPauseScheduledTasks(); +} +#endif + // static const base::TimeDelta RenderWidgetHostImpl::kActivationNotificationExpireTime = base::Milliseconds(300); diff --git a/content/browser/renderer_host/render_widget_host_impl.h b/content/browser/renderer_host/render_widget_host_impl.h index 99f88c4..937c437 100644 --- a/content/browser/renderer_host/render_widget_host_impl.h +++ b/content/browser/renderer_host/render_widget_host_impl.h @@ -469,6 +469,11 @@ class CONTENT_EXPORT RenderWidgetHostImpl #endif #endif +#if BUILDFLAG(IS_TIZEN) + void PauseScheduledTasks(); + void UnPauseScheduledTasks(); +#endif + // Returns true if the RenderWidget is hidden. bool is_hidden() const { return is_hidden_; } diff --git a/content/public/browser/render_view_host.h b/content/public/browser/render_view_host.h index 9979c25..821d751 100644 --- a/content/public/browser/render_view_host.h +++ b/content/public/browser/render_view_host.h @@ -71,6 +71,11 @@ class CONTENT_EXPORT RenderViewHost { // Instructs the `blink::WebView` to send back updates to the preferred size. virtual void EnablePreferredSizeMode() = 0; +#if BUILDFLAG(IS_TIZEN) + // Returns true if the RenderView is active and has not crashed. + virtual bool IsRenderViewLive() const = 0; +#endif + using TraceProto = perfetto::protos::pbzero::RenderViewHost; // Write a representation of this object into a trace. virtual void WriteIntoTrace( diff --git a/third_party/blink/public/mojom/widget/platform_widget.mojom b/third_party/blink/public/mojom/widget/platform_widget.mojom index b222ca4..1e348d4 100644 --- a/third_party/blink/public/mojom/widget/platform_widget.mojom +++ b/third_party/blink/public/mojom/widget/platform_widget.mojom @@ -143,6 +143,12 @@ interface Widget { [EnableIf=is_efl] PrintToPdf(uint32 width, uint32 height, mojo_base.mojom.FilePath filename); + [EnableIf=is_tizen] + PauseScheduledTasks(); + + [EnableIf=is_tizen] + UnPauseScheduledTasks(); + [EnableIf=is_efl] QueryInputType() => (bool input_type); diff --git a/third_party/blink/public/web/web_view.h b/third_party/blink/public/web/web_view.h index 608a2ee..3f8f71a 100644 --- a/third_party/blink/public/web/web_view.h +++ b/third_party/blink/public/web/web_view.h @@ -412,6 +412,11 @@ class BLINK_EXPORT WebView { // Freezes or unfreezes the page and all the local frames. virtual void SetPageFrozen(bool frozen) = 0; +#if BUILDFLAG(IS_TIZEN) + virtual void PauseScheduledTasks() = 0; + virtual void UnpauseScheduledTasks() = 0; +#endif + // Autoplay configuration ----------------------------------------------- // Sets the autoplay flags for this webview's page. diff --git a/third_party/blink/renderer/core/exported/web_view_impl.cc b/third_party/blink/renderer/core/exported/web_view_impl.cc index ad878e5..ef2abd1 100644 --- a/third_party/blink/renderer/core/exported/web_view_impl.cc +++ b/third_party/blink/renderer/core/exported/web_view_impl.cc @@ -184,6 +184,10 @@ #include "ui/base/ui_base_features.h" #include "ui/gfx/geometry/skia_conversions.h" +#if BUILDFLAG(IS_TIZEN_TV) +#include "third_party/blink/public/platform/web_application_type.h" +#endif + #if !BUILDFLAG(IS_MAC) #include "skia/ext/legacy_display_globals.h" #include "third_party/blink/public/platform/web_font_render_style.h" @@ -1287,6 +1291,51 @@ void WebViewImpl::DidUpdateBrowserControls() { } } +#if BUILDFLAG(IS_TIZEN) +void WebViewImpl::PauseScheduledTasks() { + if (!MainFrameImpl()) + return; + + if (Page* page = GetPage()) { + page->SetIsSuspended(true); + page->SetPaused(true); + } + +#if BUILDFLAG(IS_TIZEN_TV) + // when browser/app switch to BG and did not hidden webview ,the behavior cause + // high cpu issue.So we need to suspend compositor thread. + LOG(INFO) << "APP now suspend"; + MainFrameImpl()->FrameWidgetImpl()->SetCompositorVisible(false); +#endif +} + +void WebViewImpl::UnpauseScheduledTasks() { + if (!MainFrameImpl()) + return; + Page* page = GetPage(); + if (!page) + return; +#if BUILDFLAG(IS_TIZEN_TV) + // If floating video window existed and not current page, need to prevent + // media resume + LOG(INFO) << "APP now resume"; + if (IsWebBrowser()) { + if (Client()->HasFloatingVideoWindowOn() && + page->IsFloatingPage()) { + LOG(INFO) << "Floating video window existed, but not current page"; + page->NotifyViewResumedByTabSwitching(true); + } else { + page->NotifyViewResumedByTabSwitching(false); + } + } + MainFrameImpl()->FrameWidgetImpl()->SetCompositorVisible(true); +#endif + + page->SetIsSuspended(false); + page->SetPaused(false); +} +#endif + BrowserControls& WebViewImpl::GetBrowserControls() { return GetPage()->GetBrowserControls(); } diff --git a/third_party/blink/renderer/core/exported/web_view_impl.h b/third_party/blink/renderer/core/exported/web_view_impl.h index 18d4dd8..3c1075a 100644 --- a/third_party/blink/renderer/core/exported/web_view_impl.h +++ b/third_party/blink/renderer/core/exported/web_view_impl.h @@ -522,6 +522,11 @@ class CORE_EXPORT WebViewImpl final : public WebView, WebSettingsImpl* SettingsImpl(); +#if BUILDFLAG(IS_TIZEN) + virtual void PauseScheduledTasks(); + virtual void UnpauseScheduledTasks(); +#endif + BrowserControls& GetBrowserControls(); // Called anytime browser controls layout height or content offset have // changed. diff --git a/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc b/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc index 3f8d61b..8b057e4 100644 --- a/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc +++ b/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc @@ -4328,6 +4328,16 @@ void WebFrameWidgetImpl::OrientationChanged() { local_root_->SendOrientationChangeEvent(); } +#if BUILDFLAG(IS_TIZEN) +void WebFrameWidgetImpl::PauseScheduledTasks() { + View()->PauseScheduledTasks(); +} + +void WebFrameWidgetImpl::UnPauseScheduledTasks() { + View()->UnpauseScheduledTasks(); +} +#endif + void WebFrameWidgetImpl::DidUpdateSurfaceAndScreen( const display::ScreenInfos& previous_original_screen_infos) { display::ScreenInfo screen_info = widget_base_->GetScreenInfo(); diff --git a/third_party/blink/renderer/core/frame/web_frame_widget_impl.h b/third_party/blink/renderer/core/frame/web_frame_widget_impl.h index 833586a..b97c4a9 100644 --- a/third_party/blink/renderer/core/frame/web_frame_widget_impl.h +++ b/third_party/blink/renderer/core/frame/web_frame_widget_impl.h @@ -743,6 +743,11 @@ class CORE_EXPORT WebFrameWidgetImpl #endif #endif +#if BUILDFLAG(IS_TIZEN) + void PauseScheduledTasks() override; + void UnPauseScheduledTasks() override; +#endif + void OrientationChanged() override; void DidUpdateSurfaceAndScreen( const display::ScreenInfos& previous_original_screen_infos) override; diff --git a/third_party/blink/renderer/core/page/page.cc b/third_party/blink/renderer/core/page/page.cc index 2ad0cb0..2985dc4 100644 --- a/third_party/blink/renderer/core/page/page.cc +++ b/third_party/blink/renderer/core/page/page.cc @@ -229,6 +229,9 @@ Page::Page(base::PassKey, next_related_page_(this), prev_related_page_(this), autoplay_flags_(0), +#if BUILDFLAG(IS_TIZEN) + m_isSuspended(false), +#endif web_text_autosizer_page_info_({0, 0, 1.f}) { DCHECK(!AllPages().Contains(this)); AllPages().insert(this); @@ -1144,6 +1147,12 @@ void Page::SetVisionDeficiency(VisionDeficiency new_vision_deficiency) { } } +#if BUILDFLAG(IS_TIZEN) +void Page::SetIsSuspended(bool isSuspended) { + m_isSuspended = isSuspended; +} +#endif + void Page::Animate(base::TimeTicks monotonic_frame_begin_time) { GetAutoscrollController().Animate(); Animator().ServiceScriptedAnimations(monotonic_frame_begin_time); diff --git a/third_party/blink/renderer/core/page/page.h b/third_party/blink/renderer/core/page/page.h index e165464..0414e1f 100644 --- a/third_party/blink/renderer/core/page/page.h +++ b/third_party/blink/renderer/core/page/page.h @@ -361,6 +361,12 @@ class CORE_EXPORT Page final : public GarbageCollected, const mojom::blink::TextAutosizerPageInfo& page_info) { web_text_autosizer_page_info_ = page_info; } + +#if BUILDFLAG(IS_TIZEN) + void SetIsSuspended(bool); + bool IsSuspended() const { return m_isSuspended; }; +#endif + const mojom::blink::TextAutosizerPageInfo& TextAutosizerPageInfo() const { return web_text_autosizer_page_info_; } @@ -410,6 +416,16 @@ class CORE_EXPORT Page final : public GarbageCollected, static void PrepareForLeakDetection(); +#if BUILDFLAG(IS_TIZEN_TV) + bool IsFloatingPage() const { return is_floating_page_; } + void NotifyViewResumedByTabSwitching(bool enable) { + is_view_resumed_by_tab_switching_ = enable; + } + bool IsViewResumedByTabSwitching() const { + return is_view_resumed_by_tab_switching_; + } +#endif + // Fully invalidate paint of all local frames in this page. void InvalidatePaint(); @@ -519,6 +535,10 @@ class CORE_EXPORT Page final : public GarbageCollected, int subframe_count_; +#if BUILDFLAG(IS_TIZEN_TV) + bool is_view_resumed_by_tab_switching_ = false; +#endif + HeapHashSet> plugins_changed_observers_; // A circular, double-linked list of pages that are related to the current @@ -538,6 +558,10 @@ class CORE_EXPORT Page final : public GarbageCollected, // Emulated vision deficiency, set from DevTools. VisionDeficiency vision_deficiency_ = VisionDeficiency::kNoVisionDeficiency; +#if BUILDFLAG(IS_TIZEN) + bool m_isSuspended; +#endif + int32_t autoplay_flags_; // Accessed by frames to determine whether to expose the PortalHost object. diff --git a/third_party/blink/renderer/platform/widget/widget_base.cc b/third_party/blink/renderer/platform/widget/widget_base.cc index 63fdc24..e585cd2 100644 --- a/third_party/blink/renderer/platform/widget/widget_base.cc +++ b/third_party/blink/renderer/platform/widget/widget_base.cc @@ -552,6 +552,16 @@ void WidgetBase::WasHidden() { client_->WasHidden(); } +#if BUILDFLAG(IS_TIZEN) +void WidgetBase::PauseScheduledTasks() { + client_->PauseScheduledTasks(); +} + +void WidgetBase::UnPauseScheduledTasks() { + client_->UnPauseScheduledTasks(); +} +#endif + void WidgetBase::WasShown(bool was_evicted, mojom::blink::RecordContentToVisibleTimeRequestPtr record_tab_switch_time_request) { diff --git a/third_party/blink/renderer/platform/widget/widget_base.h b/third_party/blink/renderer/platform/widget/widget_base.h index 665bdcf..9c9b39e 100644 --- a/third_party/blink/renderer/platform/widget/widget_base.h +++ b/third_party/blink/renderer/platform/widget/widget_base.h @@ -159,6 +159,12 @@ class PLATFORM_EXPORT WidgetBase : public mojom::blink::Widget, void RequestSelectionRect(RequestSelectionRectCallback callback) override; void ResetLastInteractedElements() override; #endif + +#if BUILDFLAG(IS_TIZEN) + void PauseScheduledTasks() override; + void UnPauseScheduledTasks() override; +#endif + void WasHidden() override; void WasShown(bool was_evicted, mojom::blink::RecordContentToVisibleTimeRequestPtr diff --git a/third_party/blink/renderer/platform/widget/widget_base_client.h b/third_party/blink/renderer/platform/widget/widget_base_client.h index 4b4bd1e6..51910af 100644 --- a/third_party/blink/renderer/platform/widget/widget_base_client.h +++ b/third_party/blink/renderer/platform/widget/widget_base_client.h @@ -197,6 +197,11 @@ class WidgetBaseClient { #endif +#if BUILDFLAG(IS_TIZEN) + virtual void PauseScheduledTasks() {} + virtual void UnPauseScheduledTasks() {} +#endif + // Convert screen coordinates to device emulated coordinates (scaled // coordinates when devtools is used). This occurs for popups where their // window bounds are emulated. diff --git a/tizen_src/ewk/efl_integration/common/render_messages_ewk.h b/tizen_src/ewk/efl_integration/common/render_messages_ewk.h index b2ed7f2..b211d96 100644 --- a/tizen_src/ewk/efl_integration/common/render_messages_ewk.h +++ b/tizen_src/ewk/efl_integration/common/render_messages_ewk.h @@ -147,8 +147,6 @@ IPC_MESSAGE_ROUTED4(EwkViewMsg_DoHitTestAsync, // Tells the renderer to clear the cache. IPC_MESSAGE_ROUTED0(EwkViewMsg_UseSettingsFont) IPC_MESSAGE_ROUTED0(EwkViewMsg_SetBrowserFont) -IPC_MESSAGE_ROUTED0(EwkViewMsg_SuspendScheduledTask) -IPC_MESSAGE_ROUTED0(EwkViewMsg_ResumeScheduledTasks) IPC_MESSAGE_ROUTED2(EwkViewMsg_SetScroll, int, /* horizontal position */ diff --git a/tizen_src/ewk/efl_integration/eweb_view.cc b/tizen_src/ewk/efl_integration/eweb_view.cc index f3909f7..5ba9fd0 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.cc +++ b/tizen_src/ewk/efl_integration/eweb_view.cc @@ -757,13 +757,10 @@ void EWebView::Suspend() { #if !defined(EWK_BRINGUP) // FIXME: m69 bringup rfh->BlockRequestsForFrame(); #endif -#if 0 - content::GetIOThreadTaskRunner({})->PostTask(FROM_HERE, base::BindOnce( - &content::ResourceDispatcherHost::BlockRequestsForFrameFromUI, rfh)); - - if (rvh) - rvh->Send(new EwkViewMsg_SuspendScheduledTask(rvh->GetRoutingID())); -#endif + if (rvh->IsRenderViewLive()) { + RenderWidgetHostImpl* rwhi = static_cast(rvh->GetWidget()); + rwhi->PauseScheduledTasks(); + } } void EWebView::Resume() { @@ -775,14 +772,8 @@ void EWebView::Resume() { #if !defined(EWK_BRINGUP) // FIXME: m69 bringup rfh->ResumeBlockedRequestsForFrame(); #endif -#if 0 - content::GetIOThreadTaskRunner({})->PostTask(FROM_HERE, base::BindOnce( - &content::ResourceDispatcherHost::ResumeBlockedRequestsForFrameFromUI, - rfh)); - - if (rvh) - rvh->Send(new EwkViewMsg_ResumeScheduledTasks(rvh->GetRoutingID())); -#endif + if (rvh->IsRenderViewLive() && rwhva()) + rwhva()->host()->UnPauseScheduledTasks(); } #if BUILDFLAG(IS_TIZEN_TV) -- 2.7.4 From 93499dc65a8b237c3a21e873db49bf4286fa9705 Mon Sep 17 00:00:00 2001 From: v-saha Date: Fri, 24 Mar 2023 18:32:47 +0530 Subject: [PATCH 02/16] Fix critical SVACE issue This patch fixes some critical SVACE issues. Change-Id: I48296ccf49643421f7210d8d8d0502f31f38705a Signed-off-by: v-saha --- .../renderer/xwalk_extension_renderer_controller.cc | 2 +- tizen_src/chromium_impl/content/browser/media/tizen_renderer_impl.h | 4 ++-- .../chromium_impl/content/browser/selection/selection_handle_efl.h | 2 +- .../content/browser/selection/selection_magnifier_efl.h | 6 +++--- .../content/browser/web_contents/web_contents_impl_efl.cc | 6 +++--- .../ewk/efl_integration/browser/web_view_browser_message_filter.cc | 2 ++ tizen_src/ewk/efl_integration/eweb_context.h | 2 +- 7 files changed, 13 insertions(+), 11 deletions(-) diff --git a/tizen_src/chromium_impl/components/xwalk_extensions/renderer/xwalk_extension_renderer_controller.cc b/tizen_src/chromium_impl/components/xwalk_extensions/renderer/xwalk_extension_renderer_controller.cc index 71ac916..37c5198 100644 --- a/tizen_src/chromium_impl/components/xwalk_extensions/renderer/xwalk_extension_renderer_controller.cc +++ b/tizen_src/chromium_impl/components/xwalk_extensions/renderer/xwalk_extension_renderer_controller.cc @@ -210,7 +210,7 @@ int32_t XWalkExtensionRendererController::CreateInstance( return 0; } - int32_t id; + int32_t id = 0; browser_->CreateInstance(module->GetName(), &id, &jscode); instance_map_[id] = module; return id; diff --git a/tizen_src/chromium_impl/content/browser/media/tizen_renderer_impl.h b/tizen_src/chromium_impl/content/browser/media/tizen_renderer_impl.h index f11164e..532b99d 100644 --- a/tizen_src/chromium_impl/content/browser/media/tizen_renderer_impl.h +++ b/tizen_src/chromium_impl/content/browser/media/tizen_renderer_impl.h @@ -165,8 +165,8 @@ class CONTENT_EXPORT TizenRendererImpl // Identifiers to find the RenderFrameHost that created |this|. // NOTE: We store these IDs rather than a RenderFrameHost* because we do not // know when the RenderFrameHost is destroyed. - int render_process_id_; - int routing_id_; + int render_process_id_ = 0; + int routing_id_ = 0; // Temporary callback used for Initialize(). media::PipelineStatusCallback init_cb_; diff --git a/tizen_src/chromium_impl/content/browser/selection/selection_handle_efl.h b/tizen_src/chromium_impl/content/browser/selection/selection_handle_efl.h index a886fbf..5fe2795 100644 --- a/tizen_src/chromium_impl/content/browser/selection/selection_handle_efl.h +++ b/tizen_src/chromium_impl/content/browser/selection/selection_handle_efl.h @@ -85,7 +85,7 @@ class SelectionHandleEfl { SelectionControllerEfl& controller_; // Handle object - Evas_Object* handle_; + Evas_Object* handle_ = nullptr; // Is pressed bool pressed_; diff --git a/tizen_src/chromium_impl/content/browser/selection/selection_magnifier_efl.h b/tizen_src/chromium_impl/content/browser/selection/selection_magnifier_efl.h index a693783..50dd9af 100644 --- a/tizen_src/chromium_impl/content/browser/selection/selection_magnifier_efl.h +++ b/tizen_src/chromium_impl/content/browser/selection/selection_magnifier_efl.h @@ -42,16 +42,16 @@ class SelectionMagnifierEfl { SelectionControllerEfl* controller_; // Magnifier - Evas_Object* container_; + Evas_Object* container_ = nullptr; // Image displayed on popup Evas_Object* content_image_; // Magnifier Height - int height_; + int height_ = 0; // Magnifier width - int width_; + int width_ = 0; // Is magnifier showing bool shown_; diff --git a/tizen_src/chromium_impl/content/browser/web_contents/web_contents_impl_efl.cc b/tizen_src/chromium_impl/content/browser/web_contents/web_contents_impl_efl.cc index b122681..d61070d 100644 --- a/tizen_src/chromium_impl/content/browser/web_contents/web_contents_impl_efl.cc +++ b/tizen_src/chromium_impl/content/browser/web_contents/web_contents_impl_efl.cc @@ -135,9 +135,9 @@ FrameTree* WebContentsImplEfl::CreateNewWindow( if (efl_delegate_) { if (efl_delegate_->WebContentsCreateAsync(std::move(callback))) { - DCHECK(new_contents); - return &( - static_cast(new_contents)->GetPrimaryFrameTree()); + return new_contents ? &(static_cast(new_contents) + ->GetPrimaryFrameTree()) + : nullptr; } else { return nullptr; } diff --git a/tizen_src/ewk/efl_integration/browser/web_view_browser_message_filter.cc b/tizen_src/ewk/efl_integration/browser/web_view_browser_message_filter.cc index 96a0cd3..139d271 100644 --- a/tizen_src/ewk/efl_integration/browser/web_view_browser_message_filter.cc +++ b/tizen_src/ewk/efl_integration/browser/web_view_browser_message_filter.cc @@ -41,6 +41,8 @@ class WebViewBrowserMessageFilterPrivate CHECK(web_view_); } + virtual ~WebViewBrowserMessageFilterPrivate() = default; + void OnReceivedHitTestData(int render_view, const Hit_Test_Params& params) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); diff --git a/tizen_src/ewk/efl_integration/eweb_context.h b/tizen_src/ewk/efl_integration/eweb_context.h index dab08bc..eb910a2 100644 --- a/tizen_src/ewk/efl_integration/eweb_context.h +++ b/tizen_src/ewk/efl_integration/eweb_context.h @@ -216,7 +216,7 @@ class EWebContext { private: EWebContext(bool incognito, const std::string& injectedBundlePath); - ~EWebContext(); + virtual ~EWebContext(); friend class Ewk_Context; static void LocalStorageUsageForOrigin( const GURL& origin, -- 2.7.4 From b78bf4001233fc893c5ecc47db0c28fc92c81305 Mon Sep 17 00:00:00 2001 From: jingjieli Date: Mon, 13 Mar 2023 13:29:10 +0800 Subject: [PATCH 03/16] [M108 Migration][VD]Dummy Implementation for web security API ewk_settings_web_security_enabled_set/get Reference: https://review.tizen.org/gerrit/#/c/256343 Change-Id: I7bcf6fa71c953bcdbe5fc5831f09114693fa6d32 Signed-off-by: jingjieli --- tizen_src/ewk/efl_integration/public/ewk_settings.cc | 14 ++++++++++++++ .../ewk/efl_integration/public/ewk_settings_product.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/tizen_src/ewk/efl_integration/public/ewk_settings.cc b/tizen_src/ewk/efl_integration/public/ewk_settings.cc index 36284d3..0a22f8b 100644 --- a/tizen_src/ewk/efl_integration/public/ewk_settings.cc +++ b/tizen_src/ewk/efl_integration/public/ewk_settings.cc @@ -846,6 +846,20 @@ Eina_Bool ewk_settings_viewport_meta_tag_get(const Ewk_Settings *settings) return EINA_FALSE; } +#if BUILDFLAG(IS_TIZEN_TV) +Eina_Bool ewk_settings_web_security_enabled_set(Ewk_Settings* settings, Eina_Bool enable) +{ + LOG_EWK_API_MOCKUP("Only for Tizen TV."); + return EINA_FALSE; +} + +Eina_Bool ewk_settings_web_security_enabled_get(const Ewk_Settings* settings) +{ + LOG_EWK_API_MOCKUP(); + return EINA_FALSE; +} +#endif + void ewk_settings_spatial_navigation_enabled_set(Ewk_Settings* settings, Eina_Bool enable) { #if BUILDFLAG(IS_TIZEN_TV) diff --git a/tizen_src/ewk/efl_integration/public/ewk_settings_product.h b/tizen_src/ewk/efl_integration/public/ewk_settings_product.h index 9f97dc9..387f598 100644 --- a/tizen_src/ewk/efl_integration/public/ewk_settings_product.h +++ b/tizen_src/ewk/efl_integration/public/ewk_settings_product.h @@ -439,6 +439,7 @@ EXPORT_API void ewk_settings_disable_webgl_set(Ewk_Settings* settings, Eina_Bool /** * Enables/disables web security. + * This interface was deprecated since M94. * * By default, the web security is enabled. * @@ -454,6 +455,7 @@ EXPORT_API Eina_Bool ewk_settings_web_security_enabled_set(Ewk_Settings *setting /** * Returns whether the web security is enabled. + * This interface was deprecated since M94. * * @param settings settings object to query whether web security is enabled * -- 2.7.4 From b55d8865bf46e1bdf1a07137abd82f0b397ad043 Mon Sep 17 00:00:00 2001 From: xiafeng Date: Thu, 16 Mar 2023 11:18:27 +0800 Subject: [PATCH 04/16] [M108 Migration][VD]Implement ewk_settings_allow_file_access_from_external_url_set Some specific case in Tizen TV, we need to enable this. When hosted applications want to use tv device api, load file://opt/usr/apps/pepper/webapis.js located in local. But, they cannot access local because of security vulnerability(SOP) Policy of webapis.js is only located in local. Reference: https://review.tizen.org/gerrit/282771/ Change-Id: Id7e29a72dd5571770ae196d5387d97d98eb9d326 Signed-off-by: xiafeng --- content/browser/web_contents/web_contents_impl.cc | 5 +++++ content/renderer/render_frame_impl.cc | 6 ++++++ .../common/web_preferences/web_preferences_mojom_traits.cc | 4 ++++ .../blink/public/common/web_preferences/web_preferences.h | 6 ++++++ .../common/web_preferences/web_preferences_mojom_traits.h | 7 +++++++ .../blink/public/mojom/webpreferences/web_preferences.mojom | 3 +++ third_party/blink/public/web/web_document.h | 4 ++++ third_party/blink/public/web/web_settings.h | 5 +++++ third_party/blink/renderer/core/exported/web_document.cc | 11 +++++++++++ third_party/blink/renderer/core/exported/web_settings_impl.cc | 10 ++++++++++ third_party/blink/renderer/core/exported/web_settings_impl.h | 5 +++++ third_party/blink/renderer/core/exported/web_view_impl.cc | 5 +++++ third_party/blink/renderer/core/frame/settings.json5 | 5 +++++ tizen_src/ewk/efl_integration/public/ewk_settings.cc | 10 +++++++++- 14 files changed, 85 insertions(+), 1 deletion(-) diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index 6b0ee8b..0b918d6 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -2966,6 +2966,11 @@ const blink::web_pref::WebPreferences WebContentsImpl::ComputeWebPreferences() { // GuestViews in the same StoragePartition need to find each other's frames. prefs.renderer_wide_named_frame_lookup = IsGuest(); +#if BUILDFLAG(IS_TIZEN_TV) + // Disallow file access from external urls by default. + prefs.allow_file_access_from_external_urls = false; +#endif + GetContentClient()->browser()->OverrideWebkitPrefs(this, &prefs); return prefs; } diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc index 242f20d..00e3526 100644 --- a/content/renderer/render_frame_impl.cc +++ b/content/renderer/render_frame_impl.cc @@ -3660,6 +3660,12 @@ void RenderFrameImpl::DidCommitNavigation( CHECK_EQ(NavigationCommitState::kWillCommit, navigation_commit_state_); navigation_commit_state_ = NavigationCommitState::kDidCommit; +#if BUILDFLAG(IS_TIZEN_TV) + if (GetWebView() && GetWebView()->GetSettings() + ->AllowFileAccessFromExternalURLs()) + frame_->GetDocument().GrantLoadLocalResources(); +#endif + WebDocumentLoader* document_loader = frame_->GetDocumentLoader(); DocumentState* document_state = DocumentState::FromDocumentLoader(document_loader); diff --git a/third_party/blink/common/web_preferences/web_preferences_mojom_traits.cc b/third_party/blink/common/web_preferences/web_preferences_mojom_traits.cc index 7bb384f..8359c4d 100644 --- a/third_party/blink/common/web_preferences/web_preferences_mojom_traits.cc +++ b/third_party/blink/common/web_preferences/web_preferences_mojom_traits.cc @@ -245,6 +245,10 @@ bool StructTraitswebxr_immersive_ar_allowed = data.webxr_immersive_ar_allowed(); out->renderer_wide_named_frame_lookup = data.renderer_wide_named_frame_lookup(); +#if BUILDFLAG(IS_TIZEN_TV) + out->allow_file_access_from_external_urls = + data.allow_file_access_from_external_urls(); +#endif return true; } diff --git a/third_party/blink/public/common/web_preferences/web_preferences.h b/third_party/blink/public/common/web_preferences/web_preferences.h index 0b1b1e8..604d4f6 100644 --- a/third_party/blink/public/common/web_preferences/web_preferences.h +++ b/third_party/blink/public/common/web_preferences/web_preferences.h @@ -408,6 +408,12 @@ struct BLINK_COMMON_EXPORT WebPreferences { // (false). Used by StrictMimetypeCheckForWorkerScriptsEnabled policy. bool strict_mime_type_check_for_worker_scripts_enabled = true; +#if BUILDFLAG(IS_TIZEN_TV) + // Hosted app need to get local access privilege when they use tv device api + // located in local path(file://usr/apps/pepper/webapis/webapis.js) + bool allow_file_access_from_external_urls = false; +#endif + // We try to keep the default values the same as the default values in // chrome, except for the cases where it would require lots of extra work for // the embedder to use the same default value. diff --git a/third_party/blink/public/common/web_preferences/web_preferences_mojom_traits.h b/third_party/blink/public/common/web_preferences/web_preferences_mojom_traits.h index f63111c..5fd26e0 100644 --- a/third_party/blink/public/common/web_preferences/web_preferences_mojom_traits.h +++ b/third_party/blink/public/common/web_preferences/web_preferences_mojom_traits.h @@ -174,6 +174,13 @@ struct BLINK_COMMON_EXPORT StructTraitsIsSecureContext(); } +#if BUILDFLAG(IS_TIZEN_TV) +void WebDocument::GrantLoadLocalResources() { + if (Document* document = Unwrap()) + document->domWindow()->GetMutableSecurityOrigin()->GrantLoadLocalResources(); +} +#endif + WebString WebDocument::Encoding() const { return ConstUnwrap()->EncodingName(); } diff --git a/third_party/blink/renderer/core/exported/web_settings_impl.cc b/third_party/blink/renderer/core/exported/web_settings_impl.cc index ffe4a2c..f83cd48 100644 --- a/third_party/blink/renderer/core/exported/web_settings_impl.cc +++ b/third_party/blink/renderer/core/exported/web_settings_impl.cc @@ -805,6 +805,16 @@ bool WebSettingsImpl::UsesEncodingDetector() const { } #endif +#if BUILDFLAG(IS_TIZEN_TV) +void WebSettingsImpl::SetAllowFileAccessFromExternalURLs(bool allow) { + settings_->SetAllowFileAccessFromExternalURLs(allow); +} + +bool WebSettingsImpl::AllowFileAccessFromExternalURLs() { + return settings_->GetAllowFileAccessFromExternalURLs(); +} +#endif + #if defined(TIZEN_ATK_SUPPORT) void WebSettingsImpl::SetAccessibilityEnabled(bool enabled) { settings_->SetAccessibilityEnabled(enabled); diff --git a/third_party/blink/renderer/core/exported/web_settings_impl.h b/third_party/blink/renderer/core/exported/web_settings_impl.h index 3d896b7..6a506d3 100644 --- a/third_party/blink/renderer/core/exported/web_settings_impl.h +++ b/third_party/blink/renderer/core/exported/web_settings_impl.h @@ -234,6 +234,11 @@ class CORE_EXPORT WebSettingsImpl final : public WebSettings { bool UsesEncodingDetector() const override; #endif +#if BUILDFLAG(IS_TIZEN_TV) + void SetAllowFileAccessFromExternalURLs(bool) override; + bool AllowFileAccessFromExternalURLs() override; +#endif + #if defined(TIZEN_ATK_SUPPORT) void SetAccessibilityEnabled(bool) override; bool GetAccessibilityEnabled() override; diff --git a/third_party/blink/renderer/core/exported/web_view_impl.cc b/third_party/blink/renderer/core/exported/web_view_impl.cc index ef2abd1..c0ebd19 100644 --- a/third_party/blink/renderer/core/exported/web_view_impl.cc +++ b/third_party/blink/renderer/core/exported/web_view_impl.cc @@ -1752,6 +1752,11 @@ void WebView::ApplyWebPreferences(const web_pref::WebPreferences& prefs, settings->SetAccessibilityEnabled(prefs.atk_enabled); #endif +#if BUILDFLAG(IS_TIZEN_TV) + settings->SetAllowFileAccessFromExternalURLs( + prefs.allow_file_access_from_external_urls); +#endif + #if BUILDFLAG(IS_EFL) settings->SetTizenVersion(prefs.tizen_version_major, prefs.tizen_version_minor, diff --git a/third_party/blink/renderer/core/frame/settings.json5 b/third_party/blink/renderer/core/frame/settings.json5 index 5331ed9..0f0a46ed 100644 --- a/third_party/blink/renderer/core/frame/settings.json5 +++ b/third_party/blink/renderer/core/frame/settings.json5 @@ -1065,5 +1065,10 @@ initial: false, type: "bool" }, + { + name: "allowFileAccessFromExternalURLs", + initial: false, + type: "bool" + }, ], } diff --git a/tizen_src/ewk/efl_integration/public/ewk_settings.cc b/tizen_src/ewk/efl_integration/public/ewk_settings.cc index 0a22f8b..1ba1b66 100644 --- a/tizen_src/ewk/efl_integration/public/ewk_settings.cc +++ b/tizen_src/ewk/efl_integration/public/ewk_settings.cc @@ -885,8 +885,16 @@ Eina_Bool ewk_settings_ime_panel_enabled_get(const Ewk_Settings *settings) Eina_Bool ewk_settings_allow_file_access_from_external_url_set(Ewk_Settings* settings, Eina_Bool allow) { - LOG_EWK_API_MOCKUP(); +#if BUILDFLAG(IS_TIZEN_TV) + LOG(INFO) << "ewk_settings_allow_file_access_from_external_url_set, allow: " << (bool)allow; + EINA_SAFETY_ON_NULL_RETURN_VAL(settings, EINA_FALSE); + settings->getPreferences().allow_file_access_from_external_urls = allow; + ewkUpdateWebkitPreferences(settings->getEvasObject()); + return EINA_TRUE; +#else + LOG_EWK_API_MOCKUP("Only for Tizen TV"); return EINA_FALSE; +#endif } Eina_Bool ewk_settings_swipe_to_refresh_enabled_set(Ewk_Settings* settings, Eina_Bool enable) -- 2.7.4 From 03f774f4642389c25b4fb9c521c2eb1f3e006fb5 Mon Sep 17 00:00:00 2001 From: pengxia Date: Fri, 17 Mar 2023 11:55:12 +0800 Subject: [PATCH 05/16] [M108 Aura Migration][NaCl][PPFW] Fix crash when get render process in UnregisterPepperExtensionDelegate. EWeb View will destruct in EvasObjectDelete callback called. If ewk_shutdown called before EvasObjectDelete, it may cause crash during get render process in UnregisterPepperExtensionDelegate, which is in EWeb View destructor. This change is for DF190114-00719 from M94 Aura Patch: https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/279978/ Change-Id: I76685eb3ea0a9e2c1fcfc9aeedf476b52813ac05 Signed-off-by: pengxia --- tizen_src/ewk/efl_integration/eweb_view.cc | 27 ++++++++------------------- tizen_src/ewk/efl_integration/eweb_view.h | 3 +++ 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/tizen_src/ewk/efl_integration/eweb_view.cc b/tizen_src/ewk/efl_integration/eweb_view.cc index 5ba9fd0..ae65b38 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.cc +++ b/tizen_src/ewk/efl_integration/eweb_view.cc @@ -358,6 +358,9 @@ EWebView::EWebView(Ewk_Context* context, Evas_Object* object) use_early_rwi_(false), rwi_info_showed_(false), #endif +#if defined(TIZEN_PEPPER_EXTENSIONS) + render_frame_id_{0, 0}, +#endif is_initialized_(false) { LOG(INFO) << "EWebView: " << this; if (evas_object_) { @@ -3251,11 +3254,8 @@ EwkExtensionSystemDelegate* EWebView::GetExtensionDelegate() { if (!render_frame_host) return nullptr; - ExtensionSystemDelegateManager::RenderFrameID id; - id.render_process_id = render_frame_host->GetProcess()->GetID(); - id.render_frame_id = render_frame_host->GetRoutingID(); return static_cast( - ExtensionSystemDelegateManager::GetInstance()->GetDelegateForFrame(id)); + ExtensionSystemDelegateManager::GetInstance()->GetDelegateForFrame(render_frame_id_)); } void EWebView::SetWindowId() { @@ -3299,13 +3299,12 @@ void EWebView::RegisterPepperExtensionDelegate() { return; } - ExtensionSystemDelegateManager::RenderFrameID id; - id.render_process_id = render_frame_host->GetProcess()->GetID(); - id.render_frame_id = render_frame_host->GetRoutingID(); + render_frame_id_.render_process_id = render_frame_host->GetProcess()->GetID(); + render_frame_id_.render_frame_id = render_frame_host->GetRoutingID(); EwkExtensionSystemDelegate* delegate = new EwkExtensionSystemDelegate; ExtensionSystemDelegateManager::GetInstance()->RegisterDelegate( - id, std::unique_ptr{delegate}); + render_frame_id_, std::unique_ptr{delegate}); } void EWebView::UnregisterPepperExtensionDelegate() { @@ -3313,17 +3312,7 @@ void EWebView::UnregisterPepperExtensionDelegate() { LOG(WARNING) << "web_contents_ is nullptr, can't unregister delegate"; return; } - RenderFrameHost* render_frame_host = web_contents_->GetPrimaryMainFrame(); - if (!render_frame_host) { - LOG(WARNING) << "render_frame_host is nullptr, can't unregister delegate"; - return; - } - - ExtensionSystemDelegateManager::RenderFrameID id; - id.render_process_id = render_frame_host->GetProcess()->GetID(); - id.render_frame_id = render_frame_host->GetRoutingID(); - - if (!ExtensionSystemDelegateManager::GetInstance()->UnregisterDelegate(id)) + if (!ExtensionSystemDelegateManager::GetInstance()->UnregisterDelegate(render_frame_id_)) LOG(WARNING) << "Unregistering pepper extension delegate failed"; } #endif // defined(TIZEN_PEPPER_EXTENSIONS) diff --git a/tizen_src/ewk/efl_integration/eweb_view.h b/tizen_src/ewk/efl_integration/eweb_view.h index 981217e..ce0b1c1 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.h +++ b/tizen_src/ewk/efl_integration/eweb_view.h @@ -974,6 +974,9 @@ class EWebView { std::unique_ptr eweb_accessibility_; bool lazy_initialize_atk_ = false; #endif +#if defined(TIZEN_PEPPER_EXTENSIONS) + content::ExtensionSystemDelegateManager::RenderFrameID render_frame_id_; +#endif #if defined(TIZEN_VIDEO_HOLE) bool pending_video_hole_setting_ = false; #endif -- 2.7.4 From 6664264711345f8f6e0a93c91b9dbe70a2317854 Mon Sep 17 00:00:00 2001 From: Chandan Padhi Date: Mon, 27 Mar 2023 17:12:53 +0530 Subject: [PATCH 06/16] Disable debug package for aarch64 build Change-Id: Ib65aa864e272f4a3ce6d1f6f93ebf1b69fc0b724 Signed-off-by: Chandan Padhi --- packaging/chromium-efl.spec | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packaging/chromium-efl.spec b/packaging/chromium-efl.spec index 849920c..457ceec 100755 --- a/packaging/chromium-efl.spec +++ b/packaging/chromium-efl.spec @@ -16,6 +16,10 @@ License: LGPL-2.1 or BSD-2-Clause Source0: %{name}-%{version}.tar.gz Source1: content_shell.in +%ifarch aarch64 +%define _nodebug 1 +%endif + %if 0%{?_nodebug} %global __debug_install_post %{nil} %global debug_package %{nil} -- 2.7.4 From 191c6ca428b7d93bdc8cfa4a3fb6579c98b705a5 Mon Sep 17 00:00:00 2001 From: Gajendra N Date: Fri, 7 Oct 2022 14:22:44 +0530 Subject: [PATCH 07/16] [M108 Migration] Make sure device scale factor (DSF) is not less than 1.0 on any profile On RPI4 device, due to DPI value being low (120), DSF was computed as 0.75, this was causing some problems related to subpixel rendering on css related TCTs. This patch makes sure the DSF value is not lesser than 1.0. Change-Id: Ibde585f3a75793a4ac429e712a8572a0d922e488 Signed-off-by: Gajendra N (cherry picked from commit db4b64a66f803008fa66f08b156f31997ba9f385) --- tizen_src/chromium_impl/ui/display/device_display_info_efl.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tizen_src/chromium_impl/ui/display/device_display_info_efl.cc b/tizen_src/chromium_impl/ui/display/device_display_info_efl.cc index a39def2..a0a0f51 100644 --- a/tizen_src/chromium_impl/ui/display/device_display_info_efl.cc +++ b/tizen_src/chromium_impl/ui/display/device_display_info_efl.cc @@ -219,6 +219,12 @@ double DeviceDisplayInfoEfl::ComputeDIPScale(int dpi) const { double dip_scale = static_cast(GetDensityRange(dpi)); DCHECK(dip_scale); dip_scale /= kBaselineDPIDensity; + if (dip_scale < 1.0) { + // Scale factor should not be less than 1.0 on any profile. + // On RPI4, the computed dip_scale was 0.75 because of which subpixel + // rendering issue was seen on some css3 tct. + dip_scale = 1.0; + } return dip_scale; } else { // For platforms other than mobile, the user agents expect 1.0 as DIP scale -- 2.7.4 From 97d979a7d28607aea454cfcd4b86e2c2ede4faee Mon Sep 17 00:00:00 2001 From: wangjing Date: Fri, 24 Mar 2023 11:34:05 +0800 Subject: [PATCH 08/16] [M108 Migration] Check scroll area pointer before use -Check the pointer is not null before using, otherwise this causes the render process crashes. -Add some macro. reference: https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/274002/ Change-Id: I617b8c7ee002e9b3e185aa27c17d19c9c90bb4e5 Signed-off-by: wangjing --- third_party/blink/public/web/web_view.h | 2 ++ .../blink/renderer/core/input/scroll_manager.cc | 23 ++++++++++++++++++++-- .../blink/renderer/core/input/scroll_manager.h | 8 ++++++-- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/third_party/blink/public/web/web_view.h b/third_party/blink/public/web/web_view.h index 3f8f71a..74df924 100644 --- a/third_party/blink/public/web/web_view.h +++ b/third_party/blink/public/web/web_view.h @@ -43,7 +43,9 @@ #include "third_party/blink/public/platform/cross_variant_mojo_util.h" #include "third_party/blink/public/platform/scheduler/web_agent_group_scheduler.h" #include "third_party/blink/public/platform/web_common.h" +#if BUILDFLAG(IS_TIZEN_TV) #include "third_party/blink/renderer/core/scroll/scroll_types.h" +#endif #include "third_party/skia/include/core/SkColor.h" #include "ui/display/mojom/screen_orientation.mojom-shared.h" diff --git a/third_party/blink/renderer/core/input/scroll_manager.cc b/third_party/blink/renderer/core/input/scroll_manager.cc index 850c181..6aaf27b 100644 --- a/third_party/blink/renderer/core/input/scroll_manager.cc +++ b/third_party/blink/renderer/core/input/scroll_manager.cc @@ -318,8 +318,12 @@ bool ScrollManager::CanScroll(const ScrollState& scroll_state, bool ScrollManager::LogicalScroll(mojom::blink::ScrollDirection direction, ui::ScrollGranularity granularity, Node* start_node, - Node* mouse_press_node, - float data) { + Node* mouse_press_node +#if BUILDFLAG(IS_TIZEN_TV) + , + float data +#endif + ) { Node* node = start_node; if (!node) @@ -361,6 +365,13 @@ bool ScrollManager::LogicalScroll(mojom::blink::ScrollDirection direction, ScrollableArea* scrollable_area = ScrollableArea::GetForScrolling(box); DCHECK(scrollable_area); +#if BUILDFLAG(IS_TIZEN_TV) + if (!scrollable_area) { + LOG(ERROR) << " Scrollable area is NULL"; + return false; + } +#endif + ScrollOffset delta = ToScrollDelta(physical_direction, ScrollableArea::DirectionBasedScrollDelta(granularity)); @@ -405,10 +416,18 @@ bool ScrollManager::LogicalScroll(mojom::blink::ScrollDirection direction, area->OnScrollFinished(); }, WrapWeakPersistent(scrollable_area))); +#if BUILDFLAG(IS_TIZEN_TV) ScrollResult result = scrollable_area->UserScroll( granularity, ToScrollDelta(physical_direction, data), std::move(callback)); +#else + ScrollResult result = scrollable_area->UserScroll( + granularity, + ToScrollDelta(physical_direction, + ScrollableArea::DirectionBasedScrollDelta(granularity)), + std::move(callback)); +#endif if (result.DidScroll()) return true; diff --git a/third_party/blink/renderer/core/input/scroll_manager.h b/third_party/blink/renderer/core/input/scroll_manager.h index 576d519..6d092a6 100644 --- a/third_party/blink/renderer/core/input/scroll_manager.h +++ b/third_party/blink/renderer/core/input/scroll_manager.h @@ -71,8 +71,12 @@ class CORE_EXPORT ScrollManager : public GarbageCollected, bool LogicalScroll(mojom::blink::ScrollDirection, ui::ScrollGranularity, Node* start_node, - Node* mouse_press_node, - float data = 1.0); + Node* mouse_press_node +#if BUILDFLAG(IS_TIZEN_TV) + , + float data = 1.0 +#endif + ); // Performs a logical scroll that chains, crossing frames, starting from // the given node or a reasonable default (focus/last clicked). -- 2.7.4 From 3df9948f2d0ecc817c1b0723f9264f3c141eaa6e Mon Sep 17 00:00:00 2001 From: "yanting.hong" Date: Mon, 27 Mar 2023 11:18:30 +0800 Subject: [PATCH 09/16] [M108 Aura Migration] Setting demuxer memory limit Migrated from: https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/280160/ Change-Id: Ib78ab63a36ac9744313524baf884ac5cd6d5e1e6 Signed-off-by: yanting.hong --- media/base/BUILD.gn | 2 ++ media/base/demuxer_memory_limit.h | 10 ++++++ media/base/demuxer_memory_limit_product_tv.cc | 46 +++++++++++++++++++++++++++ media/filters/source_buffer_stream.cc | 4 +++ 4 files changed, 62 insertions(+) create mode 100644 media/base/demuxer_memory_limit_product_tv.cc diff --git a/media/base/BUILD.gn b/media/base/BUILD.gn index 42dfa5d..40d4f92 100644 --- a/media/base/BUILD.gn +++ b/media/base/BUILD.gn @@ -454,6 +454,8 @@ source_set("base") { sources += [ "demuxer_memory_limit_android.cc" ] } else if (is_castos) { sources += [ "demuxer_memory_limit_cast.cc" ] + } else if (tizen_product_tv) { + sources += [ "demuxer_memory_limit_product_tv.cc" ] } else if (is_fuchsia || tizen_multimedia) { sources += [ "demuxer_memory_limit_low.cc" ] } else { diff --git a/media/base/demuxer_memory_limit.h b/media/base/demuxer_memory_limit.h index 10f67400..9bf2262 100644 --- a/media/base/demuxer_memory_limit.h +++ b/media/base/demuxer_memory_limit.h @@ -23,6 +23,11 @@ MEDIA_EXPORT size_t GetDemuxerStreamVideoMemoryLimit(Demuxer::DemuxerTypes demuxer_type, const VideoDecoderConfig* video_config); +#if BUILDFLAG(IS_TIZEN_TV) +MEDIA_EXPORT size_t +UpdateDemuxerStreamVideoMemoryLimit(const VideoDecoderConfig* video_config); +#endif + // The maximum amount of data (in bytes) a demuxer can keep in memory overall. MEDIA_EXPORT size_t GetDemuxerMemoryLimit(Demuxer::DemuxerTypes demuxer_type); @@ -30,6 +35,11 @@ namespace internal { // These values should not be used directly, they are selected by functions // above based on platform capabilities. +#if BUILDFLAG(IS_TIZEN_TV) +constexpr size_t kDemuxerStreamVideoMemoryLimitTvUHD = 80 * 1024 * 1024; +constexpr size_t kDemuxerStreamVideoMemoryLimitTvDefault = 40 * 1024 * 1024; +constexpr size_t kDemuxerStreamAudioMemoryLimitTvDefault = 8 * 1024 * 1024; +#endif // Default audio memory limit: 12MB (5 minutes of 320Kbps content). // Medium audio memory limit: 5MB. diff --git a/media/base/demuxer_memory_limit_product_tv.cc b/media/base/demuxer_memory_limit_product_tv.cc new file mode 100644 index 0000000..f480ce3 --- /dev/null +++ b/media/base/demuxer_memory_limit_product_tv.cc @@ -0,0 +1,46 @@ +// Copyright 2019 Samsung Electronics Inc. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "media/base/demuxer_memory_limit.h" +#include "media/base/video_decoder_config.h" + +namespace media { + +size_t UpdateDemuxerStreamVideoMemoryLimit( + const VideoDecoderConfig* video_config) { + static size_t demuxer_stream_video_memory_limit = + internal::kDemuxerStreamVideoMemoryLimitTvDefault; + + if (!video_config) + return demuxer_stream_video_memory_limit; + + const int kFHDWidth = 1920; + const int kFHDHeight = 1080; + bool isUHDResolution = video_config->coded_size().width() > kFHDWidth || + video_config->coded_size().height() > kFHDHeight; + if (isUHDResolution) { + demuxer_stream_video_memory_limit = + internal::kDemuxerStreamVideoMemoryLimitTvUHD; + } + + return demuxer_stream_video_memory_limit; +} + +size_t GetDemuxerStreamVideoMemoryLimit( + Demuxer::DemuxerTypes /*demuxer_type*/, + const VideoDecoderConfig* video_config) { + return UpdateDemuxerStreamVideoMemoryLimit(video_config); +} + +size_t GetDemuxerStreamAudioMemoryLimit( + const AudioDecoderConfig* /*audio_config*/) { + return internal::kDemuxerStreamAudioMemoryLimitTvDefault; +} + +size_t GetDemuxerMemoryLimit(Demuxer::DemuxerTypes demuxer_type) { + return GetDemuxerStreamAudioMemoryLimit(nullptr) + + GetDemuxerStreamVideoMemoryLimit(demuxer_type, nullptr); +} + +} // namespace media diff --git a/media/filters/source_buffer_stream.cc b/media/filters/source_buffer_stream.cc index 123a941..6c74451 100644 --- a/media/filters/source_buffer_stream.cc +++ b/media/filters/source_buffer_stream.cc @@ -1864,6 +1864,10 @@ bool SourceBufferStream::UpdateVideoConfig(const VideoDecoderConfig& config, DVLOG(2) << "New video config - index: " << append_config_index_; video_configs_.resize(video_configs_.size() + 1); video_configs_[append_config_index_] = config; +#if BUILDFLAG(IS_TIZEN_TV) + size_t updated_memory_limit = UpdateDemuxerStreamVideoMemoryLimit(&config); + memory_limit_ = std::max(memory_limit_, updated_memory_limit); +#endif return true; } -- 2.7.4 From 28d51e5c0290ba22098bda7c17fbc85ab2d00a39 Mon Sep 17 00:00:00 2001 From: luyq Date: Fri, 24 Mar 2023 14:57:00 +0800 Subject: [PATCH 10/16] [M108 Migration][MPEG-H][Hbbtv][MSE] Add proper demuxing for MPEG-H codec Migration from https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/272960/ Change-Id: Ibf667810251a6fd0425dd3f9ce197162518ef122 Signed-off-by: luyq --- media/filters/source_buffer_range.cc | 64 ++++++++++++++++++++++++++++++++++ media/filters/source_buffer_range.h | 6 ++++ media/filters/source_buffer_stream.cc | 10 ++++++ media/formats/mp4/mp4_stream_parser.cc | 53 +++++++++++++++++++++++++++- media/formats/mp4/mp4_stream_parser.h | 6 ++++ 5 files changed, 138 insertions(+), 1 deletion(-) diff --git a/media/filters/source_buffer_range.cc b/media/filters/source_buffer_range.cc index 07ec131..c424931 100644 --- a/media/filters/source_buffer_range.cc +++ b/media/filters/source_buffer_range.cc @@ -7,6 +7,7 @@ #include #include #include +#include #include "base/logging.h" #include "media/base/stream_parser_buffer.h" @@ -182,6 +183,69 @@ void SourceBufferRange::Seek(base::TimeDelta timestamp) { CHECK_LT(next_buffer_index_, static_cast(buffers_.size())) << next_buffer_index_ << ", size = " << buffers_.size(); } +#if BUILDFLAG(IS_TIZEN_TV) +void SourceBufferRange::ModifyFirstFrameForMpeghCodec() { + DVLOG(1) << __func__; + DVLOG(4) << ToStringForDebugging(); + // MPEGH codec starting sequence + std::vector start_sequence = {0x01, 0x00, 0x00, 0x00, 0x18, + 0x00, 0x00, 0x00, 0x00}; + + if (buffers_.size() <= next_buffer_index_) + return; + + auto old_data_ = buffers_[next_buffer_index_]->data(); + auto old_data_size = buffers_[next_buffer_index_]->data_size(); + + // This is used to check whether we do not try to add starting sequence to + // frame that already had it added while demuxing ie. first uploaded frame + bool is_starting_sequence_already_present = true; + for (int i = 0; i < start_sequence.size() && i < old_data_size; i++) { + if (start_sequence[i] != old_data_[i]) { + is_starting_sequence_already_present = false; + break; + } + } + + if (is_starting_sequence_already_present && + old_data_size > start_sequence.size()) + return; + + // New container for old data with added starting sequence + std::vector new_data = + std::vector(old_data_size + start_sequence.size()); + + // Starting sequence inserted in front of new data + // new_data.insert(new_data.begin(),start_sequence.begin(),start_sequence.end()); + for (int i = 0; i < start_sequence.size(); i++) + new_data[i] = start_sequence[i]; + + // Loop copying old data to new container + for (int i = 0; i < old_data_size; i++) + new_data[i + start_sequence.size()] = old_data_[i]; + + // Creating new buffer based on changed data + auto new_buffer = StreamParserBuffer::CopyFrom( + &(new_data.front()), new_data.size(), + buffers_[next_buffer_index_]->side_data(), + buffers_[next_buffer_index_]->side_data_size(), + buffers_[next_buffer_index_]->is_key_frame(), + buffers_[next_buffer_index_]->type(), + buffers_[next_buffer_index_]->track_id()); + + // Setting other necessary data not copied by previous function + new_buffer->SetConfigId(buffers_[next_buffer_index_]->GetConfigId()); + new_buffer->SetDecodeTimestamp( + buffers_[next_buffer_index_]->GetDecodeTimestamp()); + new_buffer->set_is_duration_estimated( + buffers_[next_buffer_index_]->is_duration_estimated()); + new_buffer->set_duration(buffers_[next_buffer_index_]->duration()); + new_buffer->set_timestamp(buffers_[next_buffer_index_]->timestamp()); + + // Swapping old buffer to new buffer. Old buffer is discarded. + buffers_[next_buffer_index_].swap(new_buffer); +} +#endif bool SourceBufferRange::CanSeekTo(base::TimeDelta timestamp) const { DVLOG(1) << __func__; diff --git a/media/filters/source_buffer_range.h b/media/filters/source_buffer_range.h index 9a2f95dd..2770dc6 100644 --- a/media/filters/source_buffer_range.h +++ b/media/filters/source_buffer_range.h @@ -247,6 +247,12 @@ class MEDIA_EXPORT SourceBufferRange { base::TimeDelta end, BufferQueue* buffers) const; +#if BUILDFLAG(IS_TIZEN_TV) + // Adds neccessary staring codes to first frames. This starting codes are + // neccessary for propper decoding of mpeg-h coded audio content. + void ModifyFirstFrameForMpeghCodec(); +#endif + size_t size_in_bytes() const { return size_in_bytes_; } private: diff --git a/media/filters/source_buffer_stream.cc b/media/filters/source_buffer_stream.cc index 6c74451..0ee1f5c0 100644 --- a/media/filters/source_buffer_stream.cc +++ b/media/filters/source_buffer_stream.cc @@ -1506,6 +1506,16 @@ void SourceBufferStream::Seek(base::TimeDelta timestamp) { } SeekAndSetSelectedRange(itr->get(), timestamp); +#if BUILDFLAG(IS_TIZEN_TV) + // After seeking on audio stream coded with mpeg-h codec, there is a need to + // one more time inject starting sequence to first frame. + if (!audio_configs_.empty()) { + const auto& config = audio_configs_[(*itr)->GetConfigIdAtTime(timestamp)]; + if (config.codec() == AudioCodec::kMpegHAudio) { + (*itr)->ModifyFirstFrameForMpeghCodec(); + } + } +#endif seek_pending_ = false; } diff --git a/media/formats/mp4/mp4_stream_parser.cc b/media/formats/mp4/mp4_stream_parser.cc index e8ad908..52e6374 100644 --- a/media/formats/mp4/mp4_stream_parser.cc +++ b/media/formats/mp4/mp4_stream_parser.cc @@ -75,7 +75,8 @@ MP4StreamParser::MP4StreamParser(const std::set& audio_object_types, has_flac_(has_flac), num_empty_samples_skipped_(0), num_invalid_conversions_(0), - num_video_keyframe_mismatches_(0) {} + num_video_keyframe_mismatches_(0), + mpegh_first_audio_frame_(true) {} MP4StreamParser::~MP4StreamParser() = default; @@ -705,6 +706,47 @@ bool MP4StreamParser::PrepareAACBuffer( } #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) +#if BUILDFLAG(ENABLE_PLATFORM_MPEG_H_AUDIO) +bool MP4StreamParser::PrepareMPEGHBuffer( + std::vector* frame_buf, + std::vector* subsamples) { + // As above, adjust subsample information to account for the headers. AAC is + // not required to use subsample encryption, so we may need to add an entry. + uint32_t sample_size = frame_buf->size(); + + std::vector sample_size_buf = {static_cast(sample_size), + static_cast(sample_size >> 8), + static_cast(sample_size >> 16), + static_cast(sample_size >> 24)}; + + frame_buf->insert(frame_buf->begin(), sample_size_buf.begin(), + sample_size_buf.end()); + + if (mpegh_first_audio_frame_) { + std::vector start_code = {0x01, 0x00, 0x00, 0x00, 0x18, + 0x00, 0x00, 0x00, 0x00}; + frame_buf->insert(frame_buf->begin(), start_code.begin(), start_code.end()); + if (subsamples->empty()) { + subsamples->push_back(SubsampleEntry( + start_code.size() + sample_size_buf.size(), + frame_buf->size() - (start_code.size() + sample_size_buf.size()))); + } else { + (*subsamples)[0].clear_bytes += + start_code.size() + sample_size_buf.size(); + } + mpegh_first_audio_frame_ = false; + } else { + if (subsamples->empty()) { + subsamples->push_back(SubsampleEntry( + sample_size_buf.size(), frame_buf->size() - sample_size_buf.size())); + } else { + (*subsamples)[0].clear_bytes += sample_size_buf.size(); + } + } + return true; +} +#endif // BUILDFLAG(USE_PROPRIETARY_CODECS) + ParseResult MP4StreamParser::EnqueueSample(BufferQueueMap* buffers) { DCHECK_EQ(state_, kEmittingSamples); @@ -869,6 +911,15 @@ ParseResult MP4StreamParser::EnqueueSample(BufferQueueMap* buffers) { return ParseResult::kError; #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) } +#if BUILDFLAG(ENABLE_PLATFORM_MPEG_H_AUDIO) + if (audio_format == FOURCC_MHM1 || audio_format == FOURCC_MHA1) { + if (!PrepareMPEGHBuffer(&frame_buf, &subsamples)) { + MEDIA_LOG(ERROR, media_log_) + << "Failed to prepare MPEG-H sample for decode"; + return ParseResult::kError; + } + } +#endif // BUILDFLAG(ENABLE_PLATFORM_MPEG_H_AUDIO) } if (decrypt_config) { diff --git a/media/formats/mp4/mp4_stream_parser.h b/media/formats/mp4/mp4_stream_parser.h index 486fd47..ae26fbc 100644 --- a/media/formats/mp4/mp4_stream_parser.h +++ b/media/formats/mp4/mp4_stream_parser.h @@ -92,6 +92,10 @@ class MEDIA_EXPORT MP4StreamParser : public StreamParser { std::vector* frame_buf, std::vector* subsamples) const; #endif +#if BUILDFLAG(ENABLE_PLATFORM_MPEG_H_AUDIO) + bool PrepareMPEGHBuffer(std::vector* frame_buf, + std::vector* subsamples); +#endif ParseResult EnqueueSample(BufferQueueMap* buffers); bool SendAndFlushSamples(BufferQueueMap* buffers); @@ -153,6 +157,8 @@ class MEDIA_EXPORT MP4StreamParser : public StreamParser { // Tracks the number of MEDIA_LOGS for video keyframe MP4<->frame mismatch. int num_video_keyframe_mismatches_; + + bool mpegh_first_audio_frame_; }; } // namespace media::mp4 -- 2.7.4 From 93f2b2e9c30856717fedc19c0629022d1dd02d22 Mon Sep 17 00:00:00 2001 From: jinbei09 Date: Fri, 10 Mar 2023 10:21:34 +0800 Subject: [PATCH 11/16] [M108 Aura Migration][NaCl][PPAPI]Fix PPAPI unittest error This patch fixes below PPAPI unittest error: [1] var_value_converter_unittest.cc build error [2] MediaStreamBufferManager unittest execute error error[1] was already fixed in patch: [M108 Aura Migration][NaCl][PPFW] Enable VD Trusted Plugins functionality https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/289527/ Ported patch from tizen_7.0: https://review.tizen.org/gerrit/#/c/270688/ Change-Id: Id837625846669d5622da9ae167ac7071a97ef5e8 --- .../media_stream_buffer_manager_unittest.cc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/ppapi/shared_impl/media_stream_buffer_manager_unittest.cc b/ppapi/shared_impl/media_stream_buffer_manager_unittest.cc index 3e177c5..ed3b3fa 100644 --- a/ppapi/shared_impl/media_stream_buffer_manager_unittest.cc +++ b/ppapi/shared_impl/media_stream_buffer_manager_unittest.cc @@ -29,6 +29,23 @@ namespace ppapi { class MockDelegate : public MediaStreamBufferManager::Delegate { public: MockDelegate() : new_buffer_enqueue_counter_(0) {} + +#if !(defined(OFFICIAL_BUILD) && defined(NDEBUG)) + static bool HandleStandardLogMessage(int severity, + const char* file, + int line, + size_t message_start, + const std::string& str) { + if (severity == logging::LOG_FATAL) { + fprintf(stderr, str.c_str()); + } + // This function only used to monitor LogMessage, and should not + // block LogMessage from the original output destination. + // Return false to guarantee LogMessage reach original destination. + return false; + } +#endif //!(defined(OFFICIAL_BUILD) && defined(NDEBUG)) + void OnNewBufferEnqueued() override { new_buffer_enqueue_counter_++; } @@ -88,9 +105,14 @@ TEST(MediaStreamBufferManager, General) { EXPECT_DEATH(manager.EnqueueBuffer(-1), ""); EXPECT_DEATH(manager.EnqueueBuffer(kNumberOfBuffers), ""); #else + auto previous_handler = logging::GetLogMessageHandler(); + logging::SetLogMessageHandler(&MockDelegate::HandleStandardLogMessage); + EXPECT_DEATH(manager.EnqueueBuffer(-1), ".*Check failed: index >= 0.*"); EXPECT_DEATH(manager.EnqueueBuffer(kNumberOfBuffers), ".*Check failed: index < number_of_buffers_.*"); + + logging::SetLogMessageHandler(previous_handler); #endif } -- 2.7.4 From d093bf7a21ae808190bd8b91017f510c41a645cc Mon Sep 17 00:00:00 2001 From: jinbei09 Date: Fri, 10 Mar 2023 19:18:12 +0800 Subject: [PATCH 12/16] [M108 Aura Migration][NaCl][PPAPI] Crash during PPB_MessageLoop destruction When MessageLoop for PPAPI is destroyed it may happen that there are some unrun callbacks. Dtor of such callback tries to acquire global proxy lock. If such destroy is called from during call to method exposed via PPAPI to the plugin then deadlock occurs as global proxy lock is held EnterResource object form Thunk layer. Ported patch from Tizen 7.0: https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/280223/ Change-Id: If50242a099ce4c95f42148cd38c565314558359c Signed-off-by: jinbei09 --- ppapi/proxy/ppb_message_loop_proxy.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ppapi/proxy/ppb_message_loop_proxy.cc b/ppapi/proxy/ppb_message_loop_proxy.cc index 06aded8..e695734 100644 --- a/ppapi/proxy/ppb_message_loop_proxy.cc +++ b/ppapi/proxy/ppb_message_loop_proxy.cc @@ -124,7 +124,11 @@ int32_t MessageLoopResource::Run() { if (should_destroy_ && nested_invocations_ == 0) { task_runner_.reset(); - single_thread_task_executor_.reset(); + { + // Message Loop dtor may try to aquire lock. + ProxyAutoUnlock lock; + single_thread_task_executor_.reset(); + } destroyed_ = true; } return PP_OK; -- 2.7.4 From 4638554b13ccc2f4776efcd7723706cc2402c76c Mon Sep 17 00:00:00 2001 From: jinbei09 Date: Thu, 23 Mar 2023 13:46:47 +0800 Subject: [PATCH 13/16] [M108 Aura Migration][NaCl][PPAPI]Fix compilation warnings in media related components. * content/renderer/pepper/video_decoder_shim.cc In some scenarios IsCodecSupported did not returned any value. Now it returns false by default. Ported patch from: Fix compilation warnings in media related components https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/280521/ Change-Id: I6ccc63073536fd1ab1cbb60d49933680e59451c4 Signed-off-by: jinbei09 --- content/renderer/pepper/video_decoder_shim.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/renderer/pepper/video_decoder_shim.cc b/content/renderer/pepper/video_decoder_shim.cc index 09449e1..d987fa2 100644 --- a/content/renderer/pepper/video_decoder_shim.cc +++ b/content/renderer/pepper/video_decoder_shim.cc @@ -52,10 +52,10 @@ bool IsCodecSupported(media::VideoCodec codec) { #endif #if BUILDFLAG(ENABLE_FFMPEG_VIDEO_DECODERS) - return media::FFmpegVideoDecoder::IsCodecSupported(codec); -#else - return false; + if (media::FFmpegVideoDecoder::IsCodecSupported(codec)) + return true; #endif + return false; } } // namespace -- 2.7.4 From 2d96d4ef0b8b8d3408eae0286a6f38cdee37c6d9 Mon Sep 17 00:00:00 2001 From: jinbei09 Date: Fri, 24 Mar 2023 14:34:13 +0800 Subject: [PATCH 14/16] [M108 Aura Migration][NaCl][PPFWK] Add logs to indicate when pepper plugin process exit Ported patch from M94: https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/279690/ Change-Id: I6384673375c7a7ad99a79d7209c7cbed63b771cc Signed-off-by: jinbei09 --- content/renderer/pepper/pepper_plugin_instance_impl.cc | 1 + ppapi/proxy/plugin_globals.cc | 5 ++++- ppapi/proxy/ppp_instance_proxy.cc | 3 +++ ppapi/shared_impl/ppapi_globals.cc | 2 ++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc index 8218fcd..6dd7fb4 100644 --- a/content/renderer/pepper/pepper_plugin_instance_impl.cc +++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc @@ -608,6 +608,7 @@ v8::Local PepperPluginInstanceImpl::GetMainWorldContext() { } void PepperPluginInstanceImpl::Delete() { + LOG(ERROR) << "[PPFWK][PepperPluginInstanceImpl::Delete()][render-1]"; is_deleted_ = true; // Keep a reference on the stack. See NOTE above. diff --git a/ppapi/proxy/plugin_globals.cc b/ppapi/proxy/plugin_globals.cc index 283b22e..1633d21 100644 --- a/ppapi/proxy/plugin_globals.cc +++ b/ppapi/proxy/plugin_globals.cc @@ -5,7 +5,7 @@ #include "ppapi/proxy/plugin_globals.h" #include - +#include "base/logging.h" #include "base/message_loop/message_pump_type.h" #include "base/task/single_thread_task_runner.h" #include "base/task/task_runner.h" @@ -67,6 +67,7 @@ PluginGlobals::PluginGlobals( resource_reply_thread_registrar_( new ResourceReplyThreadRegistrar(GetMainThreadMessageLoop())), udp_socket_filter_(new UDPSocketFilter()) { + LOG(ERROR) << "[PPFWK][PluginGlobals::PluginGlobals_1]"; DCHECK(!plugin_globals_); plugin_globals_ = this; @@ -87,10 +88,12 @@ PluginGlobals::PluginGlobals( ipc_task_runner_(ipc_task_runner), resource_reply_thread_registrar_( new ResourceReplyThreadRegistrar(GetMainThreadMessageLoop())) { + LOG(ERROR) << "[PPFWK][PluginGlobals::PluginGlobals_2]"; DCHECK(!plugin_globals_); } PluginGlobals::~PluginGlobals() { + LOG(ERROR) << "[PPFWK][PluginGlobals::~PluginGlobals()]"; DCHECK(plugin_globals_ == this || !plugin_globals_); { ProxyAutoLock lock; diff --git a/ppapi/proxy/ppp_instance_proxy.cc b/ppapi/proxy/ppp_instance_proxy.cc index 27e8753..ef5d8c0 100644 --- a/ppapi/proxy/ppp_instance_proxy.cc +++ b/ppapi/proxy/ppp_instance_proxy.cc @@ -10,6 +10,7 @@ #include #include "base/bind.h" +#include "base/logging.h" #include "build/build_config.h" #include "ppapi/c/pp_var.h" #include "ppapi/c/ppb_core.h" @@ -60,6 +61,7 @@ PP_Bool DidCreate(PP_Instance instance, } void DidDestroy(PP_Instance instance) { + LOG(ERROR) << "[PPFWK][DidDestroy][render-2]"; HostDispatcher::GetForInstance(instance)->Send( new PpapiMsg_PPPInstance_DidDestroy(API_ID_PPP_INSTANCE, instance)); } @@ -186,6 +188,7 @@ void PPP_Instance_Proxy::OnPluginMsgDidCreate( } void PPP_Instance_Proxy::OnPluginMsgDidDestroy(PP_Instance instance) { + LOG(ERROR) << "[PPFWK][OnPluginMsgDidDestroy][plugin-1]"; combined_interface_->DidDestroy(instance); PpapiGlobals* globals = PpapiGlobals::Get(); diff --git a/ppapi/shared_impl/ppapi_globals.cc b/ppapi/shared_impl/ppapi_globals.cc index cf77f0c..79bbad1 100644 --- a/ppapi/shared_impl/ppapi_globals.cc +++ b/ppapi/shared_impl/ppapi_globals.cc @@ -6,6 +6,7 @@ #include "base/check.h" #include "base/lazy_instance.h" // For testing purposes only. +#include "base/logging.h" #include "base/task/single_thread_task_runner.h" #include "base/threading/thread_local.h" // For testing purposes only. #include "base/threading/thread_task_runner_handle.h" @@ -43,6 +44,7 @@ PpapiGlobals* PpapiGlobals::Get() { return ppapi_globals; // In unit tests, the following might be valid (see // SetPpapiGlobalsOnThreadForTest). Normally, this will just return NULL. + LOG(ERROR) << "[PPFWK][PpapiGlobals::Get()][ppapi_globals]=NULL"; return GetThreadLocalPointer(); } -- 2.7.4 From 233c82c862a66a0f34d97604e5a21f054f4f6c21 Mon Sep 17 00:00:00 2001 From: jinbei09 Date: Mon, 27 Mar 2023 14:48:47 +0800 Subject: [PATCH 15/16] [M108 Aura Migration][NaCl] Recover GetPrivilegeMapping function when checking privilege Migrated from tizen 7.0: https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/280677/ Change-Id: Ibe598e2cd12b337b204e148e296fb15bf66e8a92 Signed-off-by: jinbei09 --- packaging/chromium-efl.spec | 1 + tizen_src/build/BUILD.gn | 7 +++ tizen_src/ewk/efl_integration/BUILD.gn | 1 + .../ewk/efl_integration/ewk_privilege_checker.cc | 66 ++++++++++++++++++++-- 4 files changed, 71 insertions(+), 4 deletions(-) diff --git a/packaging/chromium-efl.spec b/packaging/chromium-efl.spec index 457ceec..314abc0 100755 --- a/packaging/chromium-efl.spec +++ b/packaging/chromium-efl.spec @@ -177,6 +177,7 @@ BuildRequires: pkgconfig(capi-stt-wrapper-tv) BuildRequires: pkgconfig(capi-system-display-rotator) BuildRequires: pkgconfig(capi-appfw-app-manager) BuildRequires: pkgconfig(cynara-client) +BuildRequires: pkgconfig(security-privilege-manager) BuildRequires: pkgconfig(drmdecrypt) BuildRequires: pkgconfig(efl-assist) BuildRequires: pkgconfig(hdmicec-api) diff --git a/tizen_src/build/BUILD.gn b/tizen_src/build/BUILD.gn index 712155b..8bd9d14 100644 --- a/tizen_src/build/BUILD.gn +++ b/tizen_src/build/BUILD.gn @@ -408,6 +408,13 @@ tizen_pkg_config("pkgmgr-info") { } } +tizen_pkg_config("security-privilege-manager") { + packages = [] + if (tizen_product_tv && tizen_pepper_extensions) { + packages = [ "security-privilege-manager" ] + } +} + tizen_pkg_config("tizen-extension-client") { packages = [] if (use_wayland) { diff --git a/tizen_src/ewk/efl_integration/BUILD.gn b/tizen_src/ewk/efl_integration/BUILD.gn index a374f4a..9827cc4 100644 --- a/tizen_src/ewk/efl_integration/BUILD.gn +++ b/tizen_src/ewk/efl_integration/BUILD.gn @@ -177,6 +177,7 @@ shared_library("chromium-ewk") { configs += [ "//tizen_src/build:cynara-client" ] configs += [ "//tizen_src/build:wayland-client" ] configs += [ "//tizen_src/build:tizen-extension-client" ] + configs += [ "//tizen_src/build:security-privilege-manager" ] } # TODO : Below dependency is set in chromium/device/battery_tizen.gypi, diff --git a/tizen_src/ewk/efl_integration/ewk_privilege_checker.cc b/tizen_src/ewk/efl_integration/ewk_privilege_checker.cc index 60524eb..264e60c 100644 --- a/tizen_src/ewk/efl_integration/ewk_privilege_checker.cc +++ b/tizen_src/ewk/efl_integration/ewk_privilege_checker.cc @@ -8,6 +8,7 @@ #include #include #include +#include #include #endif // BUILDFLAG(IS_TIZEN) @@ -68,6 +69,55 @@ bool GetPkgApiVersion(std::string* api_version) { return true; } +bool GetPrivilegeMapping(const std::string& privilege_name, + const std::string& api_version, + std::vector* privilege_mapping) { + if (!privilege_mapping) + return false; + char* local_privilege_name = strdup(privilege_name.c_str()); + GList* privilege_list = nullptr; + privilege_list = g_list_append(privilege_list, local_privilege_name); + + auto g_list_deleter = [](GList* p) { + [[maybe_unused]] auto data_deleter = [](gpointer data, gpointer user_data) { + char* char_data = static_cast(data); + free(char_data); + }; + p = g_list_first(p); + g_list_foreach(p, data_deleter, nullptr); + g_list_free(p); + }; + + auto privilege_list_holder = std::unique_ptr{ + privilege_list, g_list_deleter}; + + GList* mapped_privilege_list = nullptr; + int ret = privilege_manager_get_mapped_privilege_list( + api_version.c_str(), PRVMGR_PACKAGE_TYPE_WRT, privilege_list_holder.get(), + &mapped_privilege_list); + + auto mapped_list_holder = std::unique_ptr{ + mapped_privilege_list, g_list_deleter}; + if (ret != PRVMGR_ERR_NONE) { + LOG(ERROR) << "Mapping returned with code: " << ret; + return false; + } + + // If privilege was successfully resolved but returned empty list, we always + // return false for security reasons. + guint size = g_list_length(mapped_list_holder.get()); + if (!size) { + LOG(WARNING) << "No mapping for privilege " << privilege_name.c_str(); + return false; + } + GList* element = g_list_first(mapped_list_holder.get()); + while (element) { + char* privilege = static_cast(element->data); + privilege_mapping->emplace_back(privilege); + element = g_list_next(element); + } + return true; +} } // namespace #endif // BUILDFLAG(IS_TIZEN) @@ -114,14 +164,22 @@ bool EwkPrivilegeChecker::CheckPrivilege(const std::string& privilege_name) { << "Can`t resolve properly privilege mapping!"; return false; } - - ret = cynara_check(p_cynara, smack_label.c_str(), "", uid.c_str(), - privilege_name.c_str()); - if (ret != CYNARA_API_ACCESS_ALLOWED) { + // Resolve privileges for their requested api_version on currently running + // Tizen version. + std::vector privilege_mapping; + if (!GetPrivilegeMapping(privilege_name, api_version, &privilege_mapping)) { LOG(ERROR) << "Failed to acquire mapping for privilege: " << privilege_name.c_str(); return false; } + + for (const auto& str : privilege_mapping) { + ret = cynara_check(p_cynara, smack_label.c_str(), "", uid.c_str(), + str.c_str()); + if (ret != CYNARA_API_ACCESS_ALLOWED) { + return false; + } + } return true; #else // BUILDFLAG(IS_TIZEN) ALLOW_UNUSED_LOCAL(privilege_name); -- 2.7.4 From 1ca3d9fe25e86b5553b971a0f6f081883888f3aa Mon Sep 17 00:00:00 2001 From: jinbei09 Date: Fri, 24 Mar 2023 17:02:16 +0800 Subject: [PATCH 16/16] [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