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

Side by Side Diff: content/browser/renderer_host/render_widget_helper_mac.mm

Issue 388793003: Mac ÜC: Fix white page hangs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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
« no previous file with comments | « content/browser/renderer_host/render_widget_helper.h ('k') | content/common/view_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/renderer_host/render_widget_helper.h" 5 #include "content/browser/renderer_host/render_widget_helper.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 #include <IOSurface/IOSurfaceAPI.h> 8 #include <IOSurface/IOSurfaceAPI.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
13 #include "content/browser/compositor/browser_compositor_view_mac.h" 13 #include "content/browser/compositor/browser_compositor_view_mac.h"
14 #include "content/browser/gpu/gpu_process_host.h" 14 #include "content/browser/gpu/gpu_process_host.h"
15 #include "content/browser/gpu/gpu_surface_tracker.h" 15 #include "content/browser/gpu/gpu_surface_tracker.h"
16 #include "content/common/gpu/gpu_messages.h" 16 #include "content/common/gpu/gpu_messages.h"
17 #include "content/common/gpu/surface_handle_types_mac.h" 17 #include "content/common/gpu/surface_handle_types_mac.h"
18 #include "content/common/view_messages.h" 18 #include "content/common/view_messages.h"
19 19
20 namespace content { 20 namespace content {
21 namespace { 21 namespace {
22 typedef std::map<gfx::AcceleratedWidget,std::pair<int,int>> WidgetMap; 22 typedef std::map<gfx::AcceleratedWidget,std::pair<int,int>> WidgetMap;
23 base::LazyInstance<WidgetMap> g_widget_map; 23 base::LazyInstance<WidgetMap> g_widget_map;
24 base::LazyInstance<base::Lock> g_lock; 24 base::LazyInstance<base::Lock> g_widget_map_lock;
25
26 typedef std::set<uint64> TokenSet;
27 base::LazyInstance<TokenSet> g_token_set;
28 uint64 g_token_last_issued = 0;
29 base::LazyInstance<base::Lock> g_token_set_lock;
25 } // namespace 30 } // namespace
26 31
27 // static 32 // static
28 void RenderWidgetHelper::SetRenderWidgetIDForWidget( 33 void RenderWidgetHelper::SetRenderWidgetIDForWidget(
29 gfx::AcceleratedWidget native_widget, 34 gfx::AcceleratedWidget native_widget,
30 int render_process_id, 35 int render_process_id,
31 int render_widget_id) { 36 int render_widget_id) {
32 base::AutoLock lock(g_lock.Get()); 37 base::AutoLock lock(g_widget_map_lock.Get());
33 g_widget_map.Get()[native_widget] = std::make_pair( 38 g_widget_map.Get()[native_widget] = std::make_pair(
34 render_process_id, render_widget_id); 39 render_process_id, render_widget_id);
35 } 40 }
36 41
37 // static 42 // static
38 void RenderWidgetHelper::ResetRenderWidgetIDForWidget( 43 void RenderWidgetHelper::ResetRenderWidgetIDForWidget(
39 gfx::AcceleratedWidget native_widget) { 44 gfx::AcceleratedWidget native_widget) {
40 base::AutoLock lock(g_lock.Get()); 45 base::AutoLock lock(g_widget_map_lock.Get());
41 g_widget_map.Get().erase(native_widget); 46 g_widget_map.Get().erase(native_widget);
42 } 47 }
43 48
44 // static 49 // static
45 bool RenderWidgetHelper::GetRenderWidgetIDForWidget( 50 bool RenderWidgetHelper::GetRenderWidgetIDForWidget(
46 gfx::AcceleratedWidget native_widget, 51 gfx::AcceleratedWidget native_widget,
47 int* render_process_id, 52 int* render_process_id,
48 int* render_widget_id) { 53 int* render_widget_id) {
49 base::AutoLock lock(g_lock.Get()); 54 base::AutoLock lock(g_widget_map_lock.Get());
50 55
51 auto found = g_widget_map.Get().find(native_widget); 56 auto found = g_widget_map.Get().find(native_widget);
52 if (found != g_widget_map.Get().end()) { 57 if (found != g_widget_map.Get().end()) {
53 *render_process_id = found->second.first; 58 *render_process_id = found->second.first;
54 *render_widget_id = found->second.second; 59 *render_widget_id = found->second.second;
55 return true; 60 return true;
56 } 61 }
57 62
58 *render_process_id = 0; 63 *render_process_id = 0;
59 *render_widget_id = 0; 64 *render_widget_id = 0;
60 return false; 65 return false;
61 } 66 }
62 67
68 uint64 RenderWidgetHelper::CreateNativeWidgetSwapToken() {
69 base::AutoLock lock(g_token_set_lock.Get());
70 g_token_last_issued += 1;
71 g_token_set.Get().insert(g_token_last_issued);
72 return g_token_last_issued;
73 }
74
63 // static 75 // static
64 void RenderWidgetHelper::OnNativeSurfaceBuffersSwappedOnUIThread( 76 void RenderWidgetHelper::OnNativeSurfaceBuffersSwappedOnUIThread(
65 const ViewHostMsg_CompositorSurfaceBuffersSwapped_Params& params) { 77 const ViewHostMsg_CompositorSurfaceBuffersSwapped_Params& params) {
78 {
79 base::AutoLock lock(g_token_set_lock.Get());
80 auto found = g_token_set.Get().find(params.native_widget_token);
81 if (found == g_token_set.Get().end())
82 return;
83 g_token_set.Get().erase(found);
84 }
85
66 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 86 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
67 gfx::AcceleratedWidget native_widget = 87 gfx::AcceleratedWidget native_widget =
68 content::GpuSurfaceTracker::Get()->AcquireNativeWidget(params.surface_id); 88 content::GpuSurfaceTracker::Get()->AcquireNativeWidget(params.surface_id);
69 IOSurfaceID io_surface_id = content::IOSurfaceIDFromSurfaceHandle( 89 IOSurfaceID io_surface_id = content::IOSurfaceIDFromSurfaceHandle(
70 params.surface_handle); 90 params.surface_handle);
71 [native_widget gotAcceleratedIOSurfaceFrame:io_surface_id 91 [native_widget gotAcceleratedIOSurfaceFrame:io_surface_id
72 withOutputSurfaceID:params.surface_id 92 withOutputSurfaceID:params.surface_id
73 withLatencyInfo:params.latency_info 93 withLatencyInfo:params.latency_info
74 withPixelSize:params.size 94 withPixelSize:params.size
75 withScaleFactor:params.scale_factor]; 95 withScaleFactor:params.scale_factor];
76 } 96 }
77 97
78 } // namespace content 98 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_helper.h ('k') | content/common/view_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698