Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(298)

Side by Side Diff: content/browser/media/android/browser_surface_view_manager.cc

Issue 2353063005: Refactor ContentViewClient (1/6) (Closed)
Patch Set: fix tests Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/media/android/browser_surface_view_manager.h" 5 #include "content/browser/media/android/browser_surface_view_manager.h"
6 6
7 #include "base/android/build_info.h" 7 #include "base/android/build_info.h"
8 #include "base/trace_event/trace_event.h" 8 #include "base/trace_event/trace_event.h"
9 #include "content/browser/android/child_process_launcher_android.h" 9 #include "content/browser/android/child_process_launcher_android.h"
10 #include "content/browser/android/content_view_core_impl.h" 10 #include "content/browser/android/content_view_core_impl.h"
11 #include "content/browser/gpu/gpu_process_host.h" 11 #include "content/browser/gpu/gpu_process_host.h"
12 #include "content/browser/gpu/gpu_surface_tracker.h" 12 #include "content/browser/gpu/gpu_surface_tracker.h"
13 #include "content/browser/web_contents/web_contents_impl.h" 13 #include "content/browser/web_contents/web_contents_impl.h"
14 #include "content/common/media/surface_view_manager_messages_android.h" 14 #include "content/common/media/surface_view_manager_messages_android.h"
15 #include "content/public/browser/render_frame_host.h" 15 #include "content/public/browser/render_frame_host.h"
16 #include "content/public/browser/web_contents_delegate.h"
16 #include "media/base/surface_manager.h" 17 #include "media/base/surface_manager.h"
17 #include "ui/gfx/geometry/size.h" 18 #include "ui/gfx/geometry/size.h"
18 19
19 namespace content { 20 namespace content {
20 namespace { 21 namespace {
21 void SendDestroyingVideoSurfaceOnIO(int surface_id, 22 void SendDestroyingVideoSurfaceOnIO(int surface_id,
22 const base::Closure& done_cb) { 23 const base::Closure& done_cb) {
23 GpuProcessHost* host = GpuProcessHost::Get( 24 GpuProcessHost* host = GpuProcessHost::Get(
24 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, false /* force_create */); 25 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, false /* force_create */);
25 if (host) 26 if (host)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 75 }
75 } 76 }
76 77
77 // If we don't own the fullscreen view, but one exists, it means another 78 // If we don't own the fullscreen view, but one exists, it means another
78 // WebContents has it. Ignore this request and return a null surface id. 79 // WebContents has it. Ignore this request and return a null surface id.
79 if (ContentVideoView::GetInstance()) { 80 if (ContentVideoView::GetInstance()) {
80 SendSurfaceID(media::SurfaceManager::kNoSurfaceID); 81 SendSurfaceID(media::SurfaceManager::kNoSurfaceID);
81 return; 82 return;
82 } 83 }
83 84
84 ContentViewCore* cvc = ContentViewCore::FromWebContents( 85 WebContents* web_contents =
85 WebContents::FromRenderFrameHost(render_frame_host_)); 86 WebContents::FromRenderFrameHost(render_frame_host_);
87 ContentViewCore* cvc = ContentViewCore::FromWebContents(web_contents);
86 content_video_view_.reset( 88 content_video_view_.reset(
87 new ContentVideoView(this, cvc, video_natural_size)); 89 new ContentVideoView(this, cvc,
90 web_contents->GetDelegate()->GetContentVideoViewEmbedder(),
boliu 2016/09/26 21:25:25 null check GetDelegate
Jinsuk Kim 2016/09/27 10:08:59 Done.
91 video_natural_size));
88 } 92 }
89 93
90 void BrowserSurfaceViewManager::OnNaturalSizeChanged(const gfx::Size& size) { 94 void BrowserSurfaceViewManager::OnNaturalSizeChanged(const gfx::Size& size) {
91 if (content_video_view_) 95 if (content_video_view_)
92 content_video_view_->OnVideoSizeChanged(size.width(), size.height()); 96 content_video_view_->OnVideoSizeChanged(size.width(), size.height());
93 } 97 }
94 98
95 bool BrowserSurfaceViewManager::SendSurfaceID(int surface_id) { 99 bool BrowserSurfaceViewManager::SendSurfaceID(int surface_id) {
96 return render_frame_host_->Send( 100 return render_frame_host_->Send(
97 new SurfaceViewManagerMsg_FullscreenSurfaceCreated( 101 new SurfaceViewManagerMsg_FullscreenSurfaceCreated(
(...skipping 14 matching lines...) Expand all
112 BrowserThread::IO, FROM_HERE, 116 BrowserThread::IO, FROM_HERE,
113 base::Bind(&SendDestroyingVideoSurfaceOnIO, surface_id, 117 base::Bind(&SendDestroyingVideoSurfaceOnIO, surface_id,
114 base::Bind(&base::WaitableEvent::Signal, 118 base::Bind(&base::WaitableEvent::Signal,
115 base::Unretained(&waiter))))) { 119 base::Unretained(&waiter))))) {
116 base::ThreadRestrictions::ScopedAllowWait allow_wait; 120 base::ThreadRestrictions::ScopedAllowWait allow_wait;
117 waiter.Wait(); 121 waiter.Wait();
118 } 122 }
119 } 123 }
120 124
121 } // namespace content 125 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698