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

Unified Diff: content/browser/compositor/browser_compositor_view_mac.mm

Issue 394883007: Mac: Shift more code into C++ classes from ObjC classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@flip_fix
Patch Set: Rebase 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/compositor/browser_compositor_view_mac.mm
diff --git a/content/browser/compositor/browser_compositor_view_mac.mm b/content/browser/compositor/browser_compositor_view_mac.mm
index 2151c638e3e70785a538d37b32bf11a9bae4068f..622977f18c6b8cac79b3149a5487245a1951fb5a 100644
--- a/content/browser/compositor/browser_compositor_view_mac.mm
+++ b/content/browser/compositor/browser_compositor_view_mac.mm
@@ -40,12 +40,12 @@ namespace {
// The number of placeholder objects allocated. If this reaches zero, then
// the BrowserCompositorViewCocoa being held on to for recycling,
-// |g_recyclable_cocoa_view|, will be freed.
+// |g_recyclable_internal_view|, will be freed.
uint32 g_placeholder_count = 0;
// A spare BrowserCompositorViewCocoa kept around for recycling.
-base::LazyInstance<base::scoped_nsobject<BrowserCompositorViewCocoa>>
- g_recyclable_cocoa_view;
+base::LazyInstance<scoped_ptr<BrowserCompositorViewMacInternal>>
+ g_recyclable_internal_view;
} // namespace
@@ -56,29 +56,26 @@ BrowserCompositorViewMac::BrowserCompositorViewMac(
// TODO(ccameron): If there exists a frame in flight (swap has been called
// by the compositor, but the frame has not arrived from the GPU process
// yet), then that frame may inappropriately flash in the new view.
- swap(g_recyclable_cocoa_view.Get(), cocoa_view_);
- if (!cocoa_view_)
- cocoa_view_.reset([[BrowserCompositorViewCocoa alloc] init]);
- [cocoa_view_ setClient:client_];
+ internal_view_ = g_recyclable_internal_view.Get().Pass();
+ if (!internal_view_)
+ internal_view_.reset(new BrowserCompositorViewMacInternal);
+ internal_view_->SetClient(client_);
}
BrowserCompositorViewMac::~BrowserCompositorViewMac() {
// Make this BrowserCompositorViewCocoa recyclable for future instances.
- [cocoa_view_ setClient:NULL];
- [g_recyclable_cocoa_view.Get() destroyCompositor];
- swap(g_recyclable_cocoa_view.Get(), cocoa_view_);
+ internal_view_->ResetClient();
+ g_recyclable_internal_view.Get() = internal_view_.Pass();
// If there are no placeholders allocated, destroy the recyclable
// BrowserCompositorViewCocoa that we just populated.
- if (!g_placeholder_count) {
- [g_recyclable_cocoa_view.Get() destroyCompositor];
- g_recyclable_cocoa_view.Get().reset();
- }
+ if (!g_placeholder_count)
+ g_recyclable_internal_view.Get().reset();
}
ui::Compositor* BrowserCompositorViewMac::GetCompositor() const {
- DCHECK(cocoa_view_);
- return [cocoa_view_ compositor];
+ DCHECK(internal_view_);
+ return internal_view_->compositor();
}
////////////////////////////////////////////////////////////////////////////////
@@ -94,10 +91,8 @@ BrowserCompositorViewPlaceholderMac::~BrowserCompositorViewPlaceholderMac() {
// If there are no placeholders allocated, destroy the recyclable
// BrowserCompositorViewCocoa.
- if (!g_placeholder_count) {
- [g_recyclable_cocoa_view.Get() destroyCompositor];
- g_recyclable_cocoa_view.Get().reset();
- }
+ if (!g_placeholder_count)
+ g_recyclable_internal_view.Get().reset();
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698